Merge pull request #145 from mRemoteNG/MR-975_Replace_TreeView_with_TreeListview

MR-975 / #143 replace tree view with tree listview
This commit is contained in:
David Sparer
2016-10-04 15:28:11 -06:00
committed by GitHub
146 changed files with 10759 additions and 9071 deletions

View File

@@ -7,6 +7,7 @@
MR-366 - Show PuTTY type and version on components check screen
MR-938 - Adjust RDP Resolution list (ensure most common resolutions were available)
MR-586 - Reduce HTTP/HTTPS document title length that is appended to the connection tab title
MR-975 - Replaced TreeView with TreeListView for displaying connection tree. This was a large change which separated the GUI from the domain model.
Features/Enhancements:
----------------------

View File

@@ -1,32 +0,0 @@
using System;
using NUnit.Framework;
using mRemoteNG.Config.Connections;
using System.Data.SqlClient;
namespace mRemoteNGTests.Config.Connections
{
[TestFixture]
public class SqlUpdateQueryBuilderTest
{
private SqlUpdateQueryBuilder _sqlUpdateQueryBuilder;
[SetUp]
public void Setup()
{
_sqlUpdateQueryBuilder = new SqlUpdateQueryBuilder();
}
[TearDown]
public void Teardown()
{
_sqlUpdateQueryBuilder = null;
}
[Test]
public void SqlUpdateQueryBuilderReturnsSomeCommand()
{
SqlCommand command = _sqlUpdateQueryBuilder.BuildCommand();
Assert.AreNotEqual(command.CommandText, "");
}
}
}

View File

@@ -1,40 +0,0 @@
using mRemoteNG.Config.Connections;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Connections
{
[TestFixture]
public class SqlUpdateTimerTests
{
private SqlUpdateTimer sqlUpdateChecker;
[SetUp]
public void SetupSqlUpdateChecker()
{
sqlUpdateChecker = new SqlUpdateTimer();
}
[TearDown]
public void TearDownSqlUpdateChecker()
{
sqlUpdateChecker.Dispose();
sqlUpdateChecker = null;
}
[Test]
public void EnableSQLUpdating()
{
sqlUpdateChecker.Enable();
Assert.AreEqual(true, sqlUpdateChecker.IsUpdateCheckingEnabled());
}
[Test]
public void DisableSQLUpdating()
{
sqlUpdateChecker.Enable();
Assert.AreEqual(true, sqlUpdateChecker.IsUpdateCheckingEnabled());
sqlUpdateChecker.Disable();
Assert.AreEqual(false, sqlUpdateChecker.IsUpdateCheckingEnabled());
}
}
}

View File

@@ -0,0 +1,128 @@
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers
{
public class DataTableSerializerTests
{
private DataTableSerializer _dataTableSerializer;
private Save _saveFilter;
[SetUp]
public void Setup()
{
_saveFilter = new Save();
_dataTableSerializer = new DataTableSerializer(_saveFilter);
}
[TearDown]
public void Teardown()
{
_saveFilter = null;
_dataTableSerializer = null;
}
[Test]
public void AllItemsSerialized()
{
var model = CreateConnectionTreeModel();
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows.Count, Is.EqualTo(3));
}
[Test]
public void UsernameSerializedWhenSaveSecurityAllowsIt()
{
var model = CreateConnectionTreeModel();
_saveFilter.Username = true;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["Username"], Is.Not.EqualTo(""));
}
[Test]
public void DomainSerializedWhenSaveSecurityAllowsIt()
{
var model = CreateConnectionTreeModel();
_saveFilter.Domain = true;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["DomainName"], Is.Not.EqualTo(""));
}
[Test]
public void PasswordSerializedWhenSaveSecurityAllowsIt()
{
var model = CreateConnectionTreeModel();
_saveFilter.Password = true;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["Password"], Is.Not.EqualTo(""));
}
[Test]
public void InheritanceSerializedWhenSaveSecurityAllowsIt()
{
var model = CreateConnectionTreeModel();
_saveFilter.Inheritance = true;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["InheritUsername"], Is.Not.EqualTo(""));
}
[Test]
public void UsernameNotSerializedWhenSaveSecurityDisabled()
{
var model = CreateConnectionTreeModel();
_saveFilter.Username = false;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["Username"], Is.EqualTo(""));
}
[Test]
public void DomainNotSerializedWhenSaveSecurityDisabled()
{
var model = CreateConnectionTreeModel();
_saveFilter.Domain = false;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["DomainName"], Is.EqualTo(""));
}
[Test]
public void PasswordNotSerializedWhenSaveSecurityDisabled()
{
var model = CreateConnectionTreeModel();
_saveFilter.Password = false;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["Password"], Is.EqualTo(""));
}
[Test]
public void InheritanceNotSerializedWhenSaveSecurityDisabled()
{
var model = CreateConnectionTreeModel();
_saveFilter.Inheritance = false;
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows[0]["InheritUsername"], Is.False);
}
private ConnectionTreeModel CreateConnectionTreeModel()
{
var model = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
var folder1 = new ContainerInfo {Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1"};
var con1 = new ConnectionInfo {Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
var con2 = new ConnectionInfo {Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };
root.AddChild(folder1);
root.AddChild(con2);
folder1.AddChild(con1);
model.AddRootNode(root);
return model;
}
}
}

View File

@@ -0,0 +1,61 @@
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tools;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers
{
public class PortScanDeserializerTests
{
private PortScanDeserializer _deserializer;
private ConnectionInfo _importedConnectionInfo;
private const string ExpectedHostName = "server1.domain.com";
private const string ExpectedDisplayName = "server1";
private const ProtocolType ExpectedProtocolType = ProtocolType.SSH2;
[OneTimeSetUp]
public void OnetimeSetup()
{
var host = new ScanHost("10.20.30.40")
{
HostName = "server1.domain.com",
SSH = true
};
_deserializer = new PortScanDeserializer(new [] {host}, ProtocolType.SSH2);
_deserializer.Deserialize();
var connectionTreeModel = _deserializer.Deserialize();
var root = connectionTreeModel.RootNodes.First();
_importedConnectionInfo = root.Children.First();
}
[OneTimeTearDown]
public void OnetimeTeardown()
{
_deserializer = null;
_importedConnectionInfo = null;
}
[Test]
public void DisplayNameImported()
{
Assert.That(_importedConnectionInfo.Name, Is.EqualTo(ExpectedDisplayName));
}
[Test]
public void HostNameImported()
{
Assert.That(_importedConnectionInfo.Hostname, Is.EqualTo(ExpectedHostName));
}
[Test]
public void ProtocolImported()
{
Assert.That(_importedConnectionInfo.Protocol, Is.EqualTo(ExpectedProtocolType));
}
}
}

View File

@@ -0,0 +1,112 @@
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNGTests.Properties;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers
{
public class PuttyConnectionManagerDeserializerTests
{
private PuttyConnectionManagerDeserializer _deserializer;
private ContainerInfo _rootImportedFolder;
private const string ExpectedRootFolderName = "test_puttyConnectionManager_database";
private const string ExpectedConnectionDisplayName = "my ssh connection";
private const string ExpectedConnectionHostname = "server1.mydomain.com";
private const string ExpectedConnectionDescription = "My Description Here";
private const int ExpectedConnectionPort = 22;
private const ProtocolType ExpectedProtocolType = ProtocolType.SSH2;
private const string ExpectedPuttySession = "MyCustomPuttySession";
private const string ExpectedConnectionUsername = "mysshusername";
private const string ExpectedConnectionPassword = "password123";
[OneTimeSetUp]
public void OnetimeSetup()
{
var fileContents = Resources.test_puttyConnectionManager_database;
_deserializer = new PuttyConnectionManagerDeserializer(fileContents);
var connectionTreeModel = _deserializer.Deserialize();
var rootNode = connectionTreeModel.RootNodes.First();
_rootImportedFolder = rootNode.Children.Cast<ContainerInfo>().First();
}
[OneTimeTearDown]
public void OnetimeTeardown()
{
_deserializer = null;
_rootImportedFolder = null;
}
[Test]
public void RootFolderImportedWithCorrectName()
{
Assert.That(_rootImportedFolder.Name, Is.EqualTo(ExpectedRootFolderName));
}
[Test]
public void ConnectionDisplayNameImported()
{
var connection = GetSshConnection();
Assert.That(connection.Name, Is.EqualTo(ExpectedConnectionDisplayName));
}
[Test]
public void ConnectionHostNameImported()
{
var connection = GetSshConnection();
Assert.That(connection.Hostname, Is.EqualTo(ExpectedConnectionHostname));
}
[Test]
public void ConnectionDescriptionImported()
{
var connection = GetSshConnection();
Assert.That(connection.Description, Is.EqualTo(ExpectedConnectionDescription));
}
[Test]
public void ConnectionPortImported()
{
var connection = GetSshConnection();
Assert.That(connection.Port, Is.EqualTo(ExpectedConnectionPort));
}
[Test]
public void ConnectionProtocolTypeImported()
{
var connection = GetSshConnection();
Assert.That(connection.Protocol, Is.EqualTo(ExpectedProtocolType));
}
[Test]
public void ConnectionPuttySessionImported()
{
var connection = GetSshConnection();
Assert.That(connection.PuttySession, Is.EqualTo(ExpectedPuttySession));
}
[Test]
public void ConnectionUsernameImported()
{
var connection = GetSshConnection();
Assert.That(connection.Username, Is.EqualTo(ExpectedConnectionUsername));
}
[Test]
public void ConnectionPasswordImported()
{
var connection = GetSshConnection();
Assert.That(connection.Password, Is.EqualTo(ExpectedConnectionPassword));
}
private ConnectionInfo GetSshConnection()
{
var sshFolder = _rootImportedFolder.Children.OfType<ContainerInfo>().First(node => node.Name == "SSHFolder");
return sshFolder.Children.First();
}
}
}

View File

@@ -0,0 +1,185 @@
using System;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Tree;
using mRemoteNGTests.Properties;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers
{
public class RemoteDesktopConnectionDeserializerTests
{
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
private string[] _connectionFileContents;
private RemoteDesktopConnectionDeserializer _deserializer;
private ConnectionTreeModel _connectionTreeModel;
private const string ExpectedHostname = "testhostname.domain.com";
private const string ExpectedUserName = "myusernamehere";
private const string ExpectedDomain = "myspecialdomain";
private const string ExpectedGatewayHostname = "gatewayhostname.domain.com";
private const int ExpectedPort = 9933;
private const ProtocolRDP.RDPColors ExpectedColors = ProtocolRDP.RDPColors.Colors24Bit;
private const bool ExpectedBitmapCaching = false;
private const ProtocolRDP.RDPResolutions ExpectedResolutionMode = ProtocolRDP.RDPResolutions.FitToWindow;
private const bool ExpectedWallpaperDisplay = true;
private const bool ExpectedThemesDisplay = true;
private const bool ExpectedFontSmoothing = true;
private const bool ExpectedDesktopComposition = true;
private const bool ExpectedSmartcardRedirection = true;
private const bool ExpectedDriveRedirection = true;
private const bool ExpectedPortRedirection = true;
private const bool ExpectedPrinterRedirection = true;
private const ProtocolRDP.RDPSounds ExpectedSoundRedirection = ProtocolRDP.RDPSounds.BringToThisComputer;
[OneTimeSetUp]
public void OnetimeSetup()
{
_connectionFileContents = Resources.test_remotedesktopconnection_rdp.Split(Environment.NewLine.ToCharArray());
_deserializer = new RemoteDesktopConnectionDeserializer(_connectionFileContents);
_connectionTreeModel = _deserializer.Deserialize();
}
[OneTimeTearDown]
public void OnetimeTeardown()
{
_deserializer = null;
}
[Test]
public void ConnectionTreeModelHasARootNode()
{
var numberOfRootNodes = _connectionTreeModel.RootNodes.Count;
Assert.That(numberOfRootNodes, Is.GreaterThan(0));
}
[Test]
public void RootNodeHasConnectionInfo()
{
var rootNodeContents = _connectionTreeModel.RootNodes.First().Children.OfType<ConnectionInfo>();
Assert.That(rootNodeContents, Is.Not.Empty);
}
[Test]
public void HostnameImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Hostname, Is.EqualTo(ExpectedHostname));
}
[Test]
public void PortImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Port, Is.EqualTo(ExpectedPort));
}
[Test]
public void UsernameImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Username, Is.EqualTo(ExpectedUserName));
}
[Test]
public void DomainImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Domain, Is.EqualTo(ExpectedDomain));
}
[Test]
public void RdpColorsImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Colors, Is.EqualTo(ExpectedColors));
}
[Test]
public void BitmapCachingImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.CacheBitmaps, Is.EqualTo(ExpectedBitmapCaching));
}
[Test]
public void ResolutionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.Resolution, Is.EqualTo(ExpectedResolutionMode));
}
[Test]
public void DisplayWallpaperImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.DisplayWallpaper, Is.EqualTo(ExpectedWallpaperDisplay));
}
[Test]
public void DisplayThemesImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.DisplayThemes, Is.EqualTo(ExpectedThemesDisplay));
}
[Test]
public void FontSmoothingImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.EnableFontSmoothing, Is.EqualTo(ExpectedFontSmoothing));
}
[Test]
public void DesktopCompositionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.EnableDesktopComposition, Is.EqualTo(ExpectedDesktopComposition));
}
[Test]
public void SmartcardRedirectionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.RedirectSmartCards, Is.EqualTo(ExpectedSmartcardRedirection));
}
[Test]
public void DriveRedirectionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.RedirectDiskDrives, Is.EqualTo(ExpectedDriveRedirection));
}
[Test]
public void PortRedirectionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.RedirectPorts, Is.EqualTo(ExpectedPortRedirection));
}
[Test]
public void PrinterRedirectionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.RedirectPrinters, Is.EqualTo(ExpectedPrinterRedirection));
}
[Test]
public void SoundRedirectionImportedCorrectly()
{
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
Assert.That(connectionInfo.RedirectSound, Is.EqualTo(ExpectedSoundRedirection));
}
//[Test]
//public void GatewayHostnameImportedCorrectly()
//{
// var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
// Assert.That(connectionInfo.RDGatewayHostname, Is.EqualTo(_expectedGatewayHostname));
//}
}
}

View File

@@ -0,0 +1,335 @@
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNGTests.Properties;
using NUnit.Framework;
using System.IO;
namespace mRemoteNGTests.Config.Serializers
{
public class RemoteDesktopConnectionManagerDeserializerTests
{
private string _connectionFileContents;
private RemoteDesktopConnectionManagerDeserializer _deserializer;
private ConnectionTreeModel _connectionTreeModel;
private const string ExpectedName = "server1_displayname";
private const string ExpectedHostname = "server1";
private const string ExpectedDescription = "Comment text here";
private const string ExpectedUsername = "myusername1";
private const string ExpectedDomain = "mydomain";
private const string ExpectedPassword = "passwordHere!";
private const bool ExpectedUseConsoleSession = true;
private const int ExpectedPort = 9933;
private const ProtocolRDP.RDGatewayUsageMethod ExpectedGatewayUsageMethod = ProtocolRDP.RDGatewayUsageMethod.Always;
private const string ExpectedGatewayHostname = "gatewayserverhost.innerdomain.net";
private const string ExpectedGatewayUsername = "gatewayusername";
private const string ExpectedGatewayDomain = "innerdomain";
private const string ExpectedGatewayPassword = "gatewayPassword123";
private const ProtocolRDP.RDPResolutions ExpectedRdpResolution = ProtocolRDP.RDPResolutions.FitToWindow;
private const ProtocolRDP.RDPColors ExpectedRdpColorDepth = ProtocolRDP.RDPColors.Colors24Bit;
private const ProtocolRDP.RDPSounds ExpectedAudioRedirection = ProtocolRDP.RDPSounds.DoNotPlay;
private const bool ExpectedKeyRedirection = true;
private const bool ExpectedSmartcardRedirection = true;
private const bool ExpectedDriveRedirection = true;
private const bool ExpectedPortRedirection = true;
private const bool ExpectedPrinterRedirection = true;
private const ProtocolRDP.AuthenticationLevel ExpectedAuthLevel = ProtocolRDP.AuthenticationLevel.AuthRequired;
[OneTimeSetUp]
public void OnetimeSetup()
{
_connectionFileContents = Resources.test_rdcman_v2_2_schema1;
_deserializer = new RemoteDesktopConnectionManagerDeserializer(_connectionFileContents);
_connectionTreeModel = _deserializer.Deserialize();
}
[OneTimeTearDown]
public void OnetimeTeardown()
{
_deserializer = null;
}
[Test]
public void ConnectionTreeModelHasARootNode()
{
var numberOfRootNodes = _connectionTreeModel.RootNodes.Count;
Assert.That(numberOfRootNodes, Is.GreaterThan(0));
}
[Test]
public void RootNodeHasContents()
{
var rootNodeContents = _connectionTreeModel.RootNodes.First().Children;
Assert.That(rootNodeContents, Is.Not.Empty);
}
[Test]
public void AllSubRootFoldersImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var rootNodeContents = importedRdcmanRootNode.Children.Count(node => node.Name == "Group1" || node.Name == "Group2");
Assert.That(rootNodeContents, Is.EqualTo(2));
}
[Test]
public void ConnectionDisplayNameImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Name, Is.EqualTo(ExpectedName));
}
[Test]
public void ConnectionHostnameImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Hostname, Is.EqualTo(ExpectedHostname));
}
[Test]
public void ConnectionDescriptionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Description, Is.EqualTo(ExpectedDescription));
}
[Test]
public void ConnectionUsernameImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Username, Is.EqualTo(ExpectedUsername));
}
[Test]
public void ConnectionDomainImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Domain, Is.EqualTo(ExpectedDomain));
}
// Since password is encrypted with a machine key, cant test decryption on another machine
//[Test]
//public void ConnectionPasswordImported()
//{
// var rootNode = _connectionTreeModel.RootNodes.First();
// var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
// var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
// var connection = group1.Children.First();
// Assert.That(connection.Password, Is.EqualTo(ExpectedPassword));
//}
[Test]
public void ConnectionProtocolSetToRdp()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Protocol, Is.EqualTo(ProtocolType.RDP));
}
[Test]
public void ConnectionUseConsoleSessionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.UseConsoleSession, Is.EqualTo(ExpectedUseConsoleSession));
}
[Test]
public void ConnectionPortImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Port, Is.EqualTo(ExpectedPort));
}
[Test]
public void ConnectionGatewayUsageMethodImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RDGatewayUsageMethod, Is.EqualTo(ExpectedGatewayUsageMethod));
}
[Test]
public void ConnectionGatewayHostnameImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RDGatewayHostname, Is.EqualTo(ExpectedGatewayHostname));
}
[Test]
public void ConnectionGatewayUsernameImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RDGatewayUsername, Is.EqualTo(ExpectedGatewayUsername));
}
// Since password is encrypted with a machine key, cant test decryption on another machine
//[Test]
//public void ConnectionGatewayPasswordImported()
//{
// var rootNode = _connectionTreeModel.RootNodes.First();
// var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
// var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
// var connection = group1.Children.First();
// Assert.That(connection.RDGatewayPassword, Is.EqualTo(ExpectedGatewayPassword));
//}
[Test]
public void ConnectionGatewayDomainImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RDGatewayDomain, Is.EqualTo(ExpectedGatewayDomain));
}
[Test]
public void ConnectionResolutionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Resolution, Is.EqualTo(ExpectedRdpResolution));
}
[Test]
public void ConnectionColorDepthImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.Colors, Is.EqualTo(ExpectedRdpColorDepth));
}
[Test]
public void ConnectionAudioRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectSound, Is.EqualTo(ExpectedAudioRedirection));
}
[Test]
public void ConnectionKeyRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectKeys, Is.EqualTo(ExpectedKeyRedirection));
}
[Test]
public void ConnectionDriveRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectDiskDrives, Is.EqualTo(ExpectedDriveRedirection));
}
[Test]
public void ConnectionPortRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectPorts, Is.EqualTo(ExpectedPortRedirection));
}
[Test]
public void ConnectionPrinterRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectPrinters, Is.EqualTo(ExpectedPrinterRedirection));
}
[Test]
public void ConnectionSmartcardRedirectionImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RedirectSmartCards, Is.EqualTo(ExpectedSmartcardRedirection));
}
[Test]
public void ConnectionauthenticationLevelImported()
{
var rootNode = _connectionTreeModel.RootNodes.First();
var importedRdcmanRootNode = rootNode.Children.OfType<ContainerInfo>().First();
var group1 = importedRdcmanRootNode.Children.OfType<ContainerInfo>().First(node => node.Name == "Group1");
var connection = group1.Children.First();
Assert.That(connection.RDPAuthenticationLevel, Is.EqualTo(ExpectedAuthLevel));
}
[Test]
public void ExceptionThrownOnBadSchemaVersion()
{
var badFileContents = Resources.test_rdcman_v2_2_badschemaversion;
var deserializer = new RemoteDesktopConnectionManagerDeserializer(badFileContents);
Assert.That(() => deserializer.Deserialize(), Throws.TypeOf<FileFormatException>());
}
[Test]
public void ExceptionThrownOnUnsupportedVersion()
{
var badFileContents = Resources.test_rdcman_badVersionNumber;
var deserializer = new RemoteDesktopConnectionManagerDeserializer(badFileContents);
Assert.That(() => deserializer.Deserialize(), Throws.TypeOf<FileFormatException>());
}
[Test]
public void ExceptionThrownOnNoVersion()
{
var badFileContents = Resources.test_rdcman_noversion;
var deserializer = new RemoteDesktopConnectionManagerDeserializer(badFileContents);
Assert.That(() => deserializer.Deserialize(), Throws.TypeOf<FileFormatException>());
}
}
}

View File

@@ -0,0 +1,100 @@
using System.Collections.Generic;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNGTests.Properties;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers
{
public class XmlConnectionsDeserializerTests
{
private XmlConnectionsDeserializer _xmlConnectionsDeserializer;
private ConnectionTreeModel _connectionTreeModel;
[SetUp]
public void Setup()
{
_xmlConnectionsDeserializer = new XmlConnectionsDeserializer(Resources.TestConfCons);
_connectionTreeModel = _xmlConnectionsDeserializer.Deserialize();
}
[TearDown]
public void Teardown()
{
_xmlConnectionsDeserializer = null;
_connectionTreeModel = null;
}
[Test]
public void DeserializingCreatesRootNode()
{
Assert.That(_connectionTreeModel.RootNodes, Is.Not.Empty);
}
[Test]
public void RootNodeHasThreeChildren()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
Assert.That(connectionRoot.Children.Count, Is.EqualTo(3));
}
[Test]
public void RootContainsFolder1()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
Assert.That(ContainsNodeNamed("Folder1", connectionRoot.Children), Is.True);
}
[Test]
public void Folder1ContainsThreeConnections()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
var folder1 = GetFolderNamed("Folder1", connectionRoot.Children);
var folder1ConnectionCount = folder1?.Children.Count(node => !(node is ContainerInfo));
Assert.That(folder1ConnectionCount, Is.EqualTo(3));
}
[Test]
public void Folder2ContainsThreeNodes()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
var folder2 = GetFolderNamed("Folder2", connectionRoot.Children);
var folder1Count = folder2?.Children.Count();
Assert.That(folder1Count, Is.EqualTo(3));
}
[Test]
public void Folder21HasTwoNodes()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
var folder2 = GetFolderNamed("Folder2", connectionRoot.Children);
var folder21 = GetFolderNamed("Folder2.1", folder2.Children);
Assert.That(folder21.Children.Count, Is.EqualTo(2));
}
[Test]
public void Folder211HasOneConnection()
{
var connectionRoot = _connectionTreeModel.RootNodes[0];
var folder2 = GetFolderNamed("Folder2", connectionRoot.Children);
var folder21 = GetFolderNamed("Folder2.1", folder2.Children);
var folder211 = GetFolderNamed("Folder2.1.1", folder21.Children);
var connectionCount = folder211.Children.Count(node => !(node is ContainerInfo));
Assert.That(connectionCount, Is.EqualTo(1));
}
private bool ContainsNodeNamed(string name, IEnumerable<ConnectionInfo> list)
{
return list.Any(node => node.Name == name);
}
private ContainerInfo GetFolderNamed(string name, IEnumerable<ConnectionInfo> list)
{
var folder = list.First(node => (node is ContainerInfo && node.Name == name)) as ContainerInfo;
return folder;
}
}
}

View File

@@ -0,0 +1,507 @@
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using NUnit.Framework;
namespace mRemoteNGTests.Connection
{
public class AbstractConnectionInfoDataTests
{
private class TestAbstractConnectionInfoData : AbstractConnectionInfoData {}
private TestAbstractConnectionInfoData _testAbstractConnectionInfoData;
[SetUp]
public void Setup()
{
_testAbstractConnectionInfoData = new TestAbstractConnectionInfoData();
}
[TearDown]
public void Teardown()
{
_testAbstractConnectionInfoData = null;
}
[Test]
public void NameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Name = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void DescriptionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Description = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void IconNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Icon = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void PanelNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Panel = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void HostnameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Hostname = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void UsernameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Username = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void PasswordNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Password = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void DomainNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Domain = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void ProtocolNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Protocol = ProtocolType.HTTP;
Assert.That(wasCalled, Is.True);
}
[Test]
public void ExtAppNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.ExtApp = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void PortNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Port = 9999;
Assert.That(wasCalled, Is.True);
}
[Test]
public void PuttySessionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.PuttySession = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void IcaEncryptionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.ICAEncryptionStrength = ProtocolICA.EncryptionStrength.Encr128BitLogonOnly;
Assert.That(wasCalled, Is.True);
}
[Test]
public void UseConsoleSessionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.UseConsoleSession = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdpAuthenticationLevelNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.AuthRequired;
Assert.That(wasCalled, Is.True);
}
[Test]
public void LoadBalanceInfoNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.LoadBalanceInfo = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void RenderingEngineNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RenderingEngine = HTTPBase.RenderingEngine.Gecko;
Assert.That(wasCalled, Is.True);
}
[Test]
public void UseCredSspNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.UseCredSsp = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayUsageMethodNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUsageMethod = ProtocolRDP.RDGatewayUsageMethod.Always;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayHostnameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayHostname = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayUseConnectionCredentialsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUseConnectionCredentials = ProtocolRDP.RDGatewayUseConnectionCredentials.SmartCard;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayUsernameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUsername = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayPasswordNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayPassword = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void RdGatewayDomainNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayDomain = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void ResolutionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Resolution = ProtocolRDP.RDPResolutions.Res1366x768;
Assert.That(wasCalled, Is.True);
}
[Test]
public void AutomaticResizeNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.AutomaticResize = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void ColorsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Colors = ProtocolRDP.RDPColors.Colors16Bit;
Assert.That(wasCalled, Is.True);
}
[Test]
public void CacheBitmapsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.CacheBitmaps = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void DisplayWallpaperNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.DisplayWallpaper = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void DisplayThemesNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.DisplayThemes = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void EnableFontSmoothingNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.EnableFontSmoothing = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void EnableDesktopCompositionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.EnableDesktopComposition = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectKeysNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectKeys = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectDiskDrivesNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectDiskDrives = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectPrintersNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectPrinters = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectPortsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectPorts = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectSmartCardsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectSmartCards = true;
Assert.That(wasCalled, Is.True);
}
[Test]
public void RedirectSoundNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectSound = ProtocolRDP.RDPSounds.DoNotPlay;
Assert.That(wasCalled, Is.True);
}
[Test]
public void PreExtAppNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.PreExtApp = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void PostExtAppNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.PostExtApp = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void MacAddressNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.MacAddress = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void UserFieldNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.UserField = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncCompressionNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCCompression = ProtocolVNC.Compression.Comp5;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncEncodingNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCEncoding = ProtocolVNC.Encoding.EncTight;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncAuthModeNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCAuthMode = ProtocolVNC.AuthMode.AuthWin;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncProxyTypeNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCProxyType = ProtocolVNC.ProxyType.ProxyUltra;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncProxyIpNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCProxyIP = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncProxyPortNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCProxyPort = 9999;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncProxyUsernameNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCProxyUsername = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncProxyPasswordNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCProxyPassword = "a";
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncColorsNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCColors = ProtocolVNC.Colors.Col8Bit;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncSmartSizeModeNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCSmartSizeMode = ProtocolVNC.SmartSizeMode.SmartSFree;
Assert.That(wasCalled, Is.True);
}
[Test]
public void VncViewOnlyNotifiesOnValueChange()
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.VNCViewOnly = true;
Assert.That(wasCalled, Is.True);
}
}
}

View File

@@ -0,0 +1,42 @@
using System.ComponentModel;
using mRemoteNG.Connection;
using NUnit.Framework;
namespace mRemoteNGTests.Connection
{
public class ConnectionInfoComparerTests
{
private ConnectionInfo _con1;
private ConnectionInfo _con2;
[OneTimeSetUp]
public void OnetimeSetup()
{
_con1 = new ConnectionInfo { Name = "a" };
_con2 = new ConnectionInfo { Name = "b" };
}
[Test]
public void SortAscendingOnName()
{
var comparer = new ConnectionInfoComparer<string>(node => node.Name)
{
SortDirection = ListSortDirection.Ascending
};
var compareReturn = comparer.Compare(_con1, _con2);
Assert.That(compareReturn, Is.Negative);
}
[Test]
public void SortDescendingOnName()
{
var comparer = new ConnectionInfoComparer<string>(node => node.Name)
{
SortDirection = ListSortDirection.Descending
};
var compareReturn = comparer.Compare(_con1, _con2);
Assert.That(compareReturn, Is.Positive);
}
}
}

View File

@@ -42,7 +42,7 @@ namespace mRemoteNGTests.Connection
public void CopyCreatesMemberwiseCopy()
{
_connectionInfo.Domain = TestDomain;
var secondConnection = _connectionInfo.Copy();
var secondConnection = _connectionInfo.Clone();
Assert.That(secondConnection.Domain, Is.EqualTo(_connectionInfo.Domain));
}

View File

@@ -8,77 +8,228 @@ namespace mRemoteNGTests.Container
public class ContainerInfoTests
{
private ContainerInfo _containerInfo;
private ConnectionInfo _connectionInfo;
private ConnectionInfo _con1;
private ConnectionInfo _con2;
private ConnectionInfo _con3;
[SetUp]
public void Setup()
{
_containerInfo = new ContainerInfo();
_connectionInfo = new ConnectionInfo();
_con1 = new ConnectionInfo {Name = "a"};
_con2 = new ConnectionInfo {Name = "b"};
_con3 = new ConnectionInfo {Name = "c"};
}
[TearDown]
public void Teardown()
{
_containerInfo = null;
_connectionInfo = null;
_con1 = null;
_con2 = null;
_con3 = null;
}
[Test]
public void AddSetsParentPropertyOnTheChild()
{
_containerInfo.Add(_connectionInfo);
Assert.That(_connectionInfo.Parent, Is.EqualTo(_containerInfo));
_containerInfo.AddChild(_con1);
Assert.That(_con1.Parent, Is.EqualTo(_containerInfo));
}
[Test]
public void AddAddsChildToChildrenList()
{
_containerInfo.Add(_connectionInfo);
Assert.That(_containerInfo.Children, Does.Contain(_connectionInfo));
_containerInfo.AddChild(_con1);
Assert.That(_containerInfo.Children, Does.Contain(_con1));
}
[Test]
public void AddRangeAddsAllItems()
{
var collection = new[] {new ConnectionInfo(),new ConnectionInfo(), new ContainerInfo()};
_containerInfo.AddRange(collection);
var collection = new[] { _con1, _con2, _con3 };
_containerInfo.AddChildRange(collection);
Assert.That(_containerInfo.Children, Is.EquivalentTo(collection));
}
[Test]
public void RemoveUnsetsParentPropertyOnChild()
{
_containerInfo.Add(_connectionInfo);
_containerInfo.Remove(_connectionInfo);
Assert.That(_connectionInfo.Parent, Is.Not.EqualTo(_containerInfo));
_containerInfo.AddChild(_con1);
_containerInfo.RemoveChild(_con1);
Assert.That(_con1.Parent, Is.Not.EqualTo(_containerInfo));
}
[Test]
public void RemoveRemovesChildFromChildrenList()
{
_containerInfo.Add(_connectionInfo);
_containerInfo.Remove(_connectionInfo);
Assert.That(_containerInfo.Children, Does.Not.Contains(_connectionInfo));
_containerInfo.AddChild(_con1);
_containerInfo.RemoveChild(_con1);
Assert.That(_containerInfo.Children, Does.Not.Contains(_con1));
}
[Test]
public void RemoveRangeRemovesAllIndicatedItems()
{
var collection = new[] { new ConnectionInfo(), new ConnectionInfo(), new ContainerInfo() };
_containerInfo.AddRange(collection);
_containerInfo.RemoveRange(collection);
var collection = new[] { _con1, _con2, new ContainerInfo() };
_containerInfo.AddChildRange(collection);
_containerInfo.RemoveChildRange(collection);
Assert.That(_containerInfo.Children, Does.Not.Contains(collection[0]).And.Not.Contains(collection[1]).And.Not.Contains(collection[2]));
}
[Test]
public void RemoveRangeDoesNotRemoveUntargetedMembers()
{
var collection = new[] { new ConnectionInfo(), new ConnectionInfo(), new ContainerInfo() };
_containerInfo.AddRange(collection);
_containerInfo.Add(_connectionInfo);
_containerInfo.RemoveRange(collection);
Assert.That(_containerInfo.Children, Does.Contain(_connectionInfo));
var collection = new[] { _con1, _con2, new ContainerInfo() };
_containerInfo.AddChildRange(collection);
_containerInfo.AddChild(_con3);
_containerInfo.RemoveChildRange(collection);
Assert.That(_containerInfo.Children, Does.Contain(_con3));
}
[Test]
public void AddingChildTriggersCollectionChangedEvent()
{
var wasCalled = false;
_containerInfo.CollectionChanged += (sender, args) => wasCalled = true;
_containerInfo.AddChild(_con1);
Assert.That(wasCalled, Is.True);
}
[Test]
public void RemovingChildTriggersCollectionChangedEvent()
{
var wasCalled = false;
_containerInfo.AddChild(_con1);
_containerInfo.CollectionChanged += (sender, args) => wasCalled = true;
_containerInfo.RemoveChild(_con1);
Assert.That(wasCalled, Is.True);
}
[Test]
public void ChangingChildPropertyTriggersPropertyChangedEvent()
{
var wasCalled = false;
_containerInfo.AddChild(_con1);
_containerInfo.PropertyChanged += (sender, args) => wasCalled = true;
_con1.Name = "somethinghere";
Assert.That(wasCalled, Is.True);
}
[Test]
public void ChangingSubChildPropertyTriggersPropertyChangedEvent()
{
var wasCalled = false;
var container2 = new ContainerInfo();
_containerInfo.AddChild(container2);
container2.AddChild(_con1);
_containerInfo.PropertyChanged += (sender, args) => wasCalled = true;
_con1.Name = "somethinghere";
Assert.That(wasCalled, Is.True);
}
[Test]
public void SetChildPositionPutsChildInCorrectPosition()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
_containerInfo.SetChildPosition(_con2, 2);
Assert.That(_containerInfo.Children.IndexOf(_con2), Is.EqualTo(2));
}
[Test]
public void SettingChildPositionAboveArrayBoundsPutsItAtEndOfList()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var finalIndex = _containerInfo.Children.Count - 1;
_containerInfo.SetChildPosition(_con2, 5);
Assert.That(_containerInfo.Children.IndexOf(_con2), Is.EqualTo(finalIndex));
}
[Test]
public void SettingChildPositionBelowArrayBoundsDoesNotMoveTheChild()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var originalIndex = _containerInfo.Children.IndexOf(_con2);
_containerInfo.SetChildPosition(_con2, -1);
Assert.That(_containerInfo.Children.IndexOf(_con2), Is.EqualTo(originalIndex));
}
[Test]
public void SetChildAbovePutsChildInCorrectPosition()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var referenceChildIndexBeforeMove = _containerInfo.Children.IndexOf(_con2);
_containerInfo.SetChildAbove(_con3, _con2);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con3);
Assert.That(targetsNewIndex, Is.EqualTo(referenceChildIndexBeforeMove));
}
[Test]
public void SetChildBelowPutsChildInCorrectPosition()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var referenceChildIndexBeforeMove = _containerInfo.Children.IndexOf(_con1);
_containerInfo.SetChildBelow(_con3, _con1);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con3);
Assert.That(targetsNewIndex, Is.EqualTo(referenceChildIndexBeforeMove+1));
}
[Test]
public void PromoteChildMovesTargetUpOne()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var targetsIndexBeforeMove = _containerInfo.Children.IndexOf(_con3);
_containerInfo.PromoteChild(_con3);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con3);
Assert.That(targetsNewIndex, Is.EqualTo(targetsIndexBeforeMove - 1));
}
[Test]
public void PromoteChildDoesNothingWhenAlreadyAtTopOfList()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var targetsIndexBeforeMove = _containerInfo.Children.IndexOf(_con1);
_containerInfo.PromoteChild(_con1);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con1);
Assert.That(targetsNewIndex, Is.EqualTo(targetsIndexBeforeMove));
}
[Test]
public void DemoteChildMovesTargetDownOne()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var targetsIndexBeforeMove = _containerInfo.Children.IndexOf(_con1);
_containerInfo.DemoteChild(_con1);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con1);
Assert.That(targetsNewIndex, Is.EqualTo(targetsIndexBeforeMove + 1));
}
[Test]
public void DemoteChildDoesNothingWhenAlreadyAtTopOfList()
{
_containerInfo.AddChild(_con1);
_containerInfo.AddChild(_con2);
_containerInfo.AddChild(_con3);
var targetsIndexBeforeMove = _containerInfo.Children.IndexOf(_con3);
_containerInfo.DemoteChild(_con3);
var targetsNewIndex = _containerInfo.Children.IndexOf(_con3);
Assert.That(targetsNewIndex, Is.EqualTo(targetsIndexBeforeMove));
}
}
}

View File

@@ -39,9 +39,9 @@ namespace mRemoteNGTests.IntegrationTests
var connection1 = new ConnectionInfo();
var connection2 = new ConnectionInfo();
var connection3 = new ConnectionInfo {Inheritance = {Username = true}};
_rootNode.Add(folder1);
folder1.AddRange(new []{connection1, folder2, connection3});
folder2.Add(connection2);
_rootNode.AddChild(folder1);
folder1.AddChildRange(new []{connection1, folder2, connection3});
folder2.AddChild(connection2);
Assert.That(connection3.Username, Is.EqualTo(folder1.Username));
}
@@ -50,8 +50,8 @@ namespace mRemoteNGTests.IntegrationTests
{
var folder = new ContainerInfo() {Protocol = ProtocolType.SSH2, Username = "folderUser", Domain = "CoolDomain"};
var connection = new ConnectionInfo() {Inheritance = {EverythingInherited = true}};
_rootNode.Add(folder);
folder.Add(connection);
_rootNode.AddChild(folder);
folder.AddChild(connection);
Assert.That(new object[] { connection.Protocol, connection.Username, connection.Domain }, Is.EquivalentTo(new object[] {folder.Protocol, folder.Username, folder.Domain}));
}
@@ -62,10 +62,10 @@ namespace mRemoteNGTests.IntegrationTests
var folder2 = new ContainerInfo {Inheritance = {Username = true}};
var folder3 = new ContainerInfo {Inheritance = {Username = true}};
var connection = new ConnectionInfo {Inheritance = {Username = true}};
_rootNode.Add(folder1);
folder1.Add(folder2);
folder2.Add(folder3);
folder3.Add(connection);
_rootNode.AddChild(folder1);
folder1.AddChild(folder2);
folder2.AddChild(folder3);
folder3.AddChild(connection);
Assert.That(connection.Username, Is.EqualTo(folder1.Username));
}
}

View File

@@ -0,0 +1,218 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace mRemoteNGTests.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mRemoteNGTests.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to RmV7zw/a7ZRRzZdcTkrLDgBfyEmeh8OFMgg2OKFJnwg=.
/// </summary>
internal static string legacyrijndael_ciphertext {
get {
return ResourceManager.GetString("legacyrijndael_ciphertext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
///&lt;!-- ****************************************************************--&gt;
///&lt;!-- * *--&gt;
///&lt;!-- * PuTTY Configuration Manager save file - All right reserved. *--&gt;
///&lt;!-- * *--&gt;
///&lt;!-- ****************************************************************--&gt;
///&lt;!-- The following lines can be modified at your own risks. --&gt;
///&lt;configuration version=&quot;0.7.1.136&quot; [rest of string was truncated]&quot;;.
/// </summary>
internal static string test_puttyConnectionManager_database {
get {
return ResourceManager.GetString("test_puttyConnectionManager_database", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;RDCMan schemaVersion=&quot;1&quot;&gt;
/// &lt;version&gt;99.99&lt;/version&gt;
/// &lt;file&gt;
/// &lt;/file&gt;
///&lt;/RDCMan&gt;.
/// </summary>
internal static string test_rdcman_badVersionNumber {
get {
return ResourceManager.GetString("test_rdcman_badVersionNumber", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;RDCMan schemaVersion=&quot;1&quot;&gt;
/// &lt;file&gt;
/// &lt;/file&gt;
///&lt;/RDCMan&gt;.
/// </summary>
internal static string test_rdcman_noversion {
get {
return ResourceManager.GetString("test_rdcman_noversion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;RDCMan schemaVersion=&quot;-99&quot;&gt;
/// &lt;version&gt;2.2&lt;/version&gt;
/// &lt;file&gt;
/// &lt;/file&gt;
///&lt;/RDCMan&gt;.
/// </summary>
internal static string test_rdcman_v2_2_badschemaversion {
get {
return ResourceManager.GetString("test_rdcman_v2_2_badschemaversion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;RDCMan schemaVersion=&quot;1&quot;&gt;
/// &lt;version&gt;2.2&lt;/version&gt;
/// &lt;file&gt;
/// &lt;properties&gt;
/// &lt;name&gt;test_rdcman_v2_2_schema1&lt;/name&gt;
/// &lt;expanded&gt;True&lt;/expanded&gt;
/// &lt;comment /&gt;
/// &lt;logonCredentials inherit=&quot;FromParent&quot; /&gt;
/// &lt;connectionSettings inherit=&quot;FromParent&quot; /&gt;
/// &lt;gatewaySettings inherit=&quot;FromParent&quot; /&gt;
/// &lt;remoteDesktop inherit=&quot;FromParent&quot; /&gt;
/// &lt;localResources inherit=&quot;FromParent&quot; [rest of string was truncated]&quot;;.
/// </summary>
internal static string test_rdcman_v2_2_schema1 {
get {
return ResourceManager.GetString("test_rdcman_v2_2_schema1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;RDCMan programVersion=&quot;2.7&quot; schemaVersion=&quot;3&quot;&gt;
/// &lt;file&gt;
/// &lt;credentialsProfiles /&gt;
/// &lt;properties&gt;
/// &lt;expanded&gt;True&lt;/expanded&gt;
/// &lt;name&gt;test_RDCMan_connections&lt;/name&gt;
/// &lt;/properties&gt;
/// &lt;smartGroup&gt;
/// &lt;properties&gt;
/// &lt;expanded&gt;False&lt;/expanded&gt;
/// &lt;name&gt;AllServers&lt;/name&gt;
/// &lt;/properties&gt;
/// &lt;ruleGroup operator=&quot;All&quot;&gt;
/// &lt;rule&gt;
/// &lt;property&gt;DisplayName&lt;/property&gt;
/// &lt;operator&gt;Matches&lt;/operator&gt;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string test_rdcman_v2_7_schema3 {
get {
return ResourceManager.GetString("test_rdcman_v2_7_schema3", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to screen mode id:i:1
///use multimon:i:0
///desktopwidth:i:800
///desktopheight:i:600
///session bpp:i:24
///winposstr:s:0,3,0,0,800,600
///compression:i:1
///keyboardhook:i:2
///audiocapturemode:i:0
///videoplaybackmode:i:1
///connection type:i:7
///networkautodetect:i:1
///bandwidthautodetect:i:1
///displayconnectionbar:i:1
///username:s:myusernamehere
///enableworkspacereconnect:i:0
///disable wallpaper:i:1
///allow font smoothing:i:1
///allow desktop composition:i:1
///disable full window drag:i:1
///disable menu anims:i:1
///disable themes:i:1
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string test_remotedesktopconnection_rdp {
get {
return ResourceManager.GetString("test_remotedesktopconnection_rdp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;Connections Name=&quot;Connections&quot; Export=&quot;False&quot; Protected=&quot;95syzRuZ4mRxpNkZQzoyX8SDpQXLyMq3GncO8o4SyTBoYvn3TAWgn05ZEU2DrjkM&quot; ConfVersion=&quot;2.5&quot;&gt;
/// &lt;Node Name=&quot;Folder1&quot; Type=&quot;Container&quot; Expanded=&quot;True&quot; Descr=&quot;&quot; Icon=&quot;mRemoteNG&quot; Panel=&quot;General&quot; Username=&quot;&quot; Domain=&quot;&quot; Password=&quot;&quot; Hostname=&quot;&quot; Protocol=&quot;ICA&quot; PuttySession=&quot;Default Settings&quot; Port=&quot;1494&quot; ConnectToConsole=&quot;False&quot; UseCredSsp=&quot;True&quot; RenderingEngine=&quot;IE&quot; ICAEncryptionStrength=&quot;Encr128Bit&quot; RDPAuthenticationLevel=&quot; [rest of string was truncated]&quot;;.
/// </summary>
internal static string TestConfCons {
get {
return ResourceManager.GetString("TestConfCons", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="legacyrijndael_ciphertext" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\legacyrijndael_ciphertext.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="TestConfCons" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\TestConfCons.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="test_puttyConnectionManager_database" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_puttyConnectionManager_database.dat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>
<data name="test_rdcman_badVersionNumber" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_rdcman_badVersionNumber.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="test_rdcman_noversion" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_rdcman_noversion.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="test_rdcman_v2_2_badschemaversion" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_rdcman_v2_2_badschemaversion.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="test_rdcman_v2_2_schema1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_rdcman_v2_2_schema1.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="test_rdcman_v2_7_schema3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_RDCMan_v2_7_schema3.rdg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="test_remotedesktopconnection_rdp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_remotedesktopconnection.rdp;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>
</root>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Connections Name="Connections" Export="False" Protected="95syzRuZ4mRxpNkZQzoyX8SDpQXLyMq3GncO8o4SyTBoYvn3TAWgn05ZEU2DrjkM" ConfVersion="2.5">
<Node Name="Folder1" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="" Domain="" Password="" Hostname="" Protocol="ICA" PuttySession="Default Settings" Port="1494" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="Encr128Bit" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False">
<Node Name="Connection1.1" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder1" Domain="domainFolder1" Password="u1cFYiN+39rnIjT9JOVgqzF0LwDD08ON/32tXV6aMw8=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="Connection1.2" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder1" Domain="domainFolder1" Password="UVhIa8sJMvLGX56d8ZG4PMZak6lwURlkN4UYOksjeqw=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="Connection1.3" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder1" Domain="domainFolder1" Password="xxViioYX/CaoWnXsE1bZdE21Jj2qsz7Du3KbONMB2LU=" Hostname="" Protocol="SSH2" PuttySession="Default Settings" Port="22" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
</Node>
<Node Name="Folder2" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="folder2domain" Password="OG1YqC5B612X2z8mT8ujrcwjLB83TPEwzxpcAUfq8QI=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False">
<Node Name="Connection2.1" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="usernameC21" Domain="domainC21" Password="4k/KraVW2VBeMzDDP3DXCBpAnhTK8NfsLWAiWkoBSF8=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="Folder2.1" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="" Domain="" Password="" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False">
<Node Name="Connection2.1.1" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="usernameC211" Domain="domainC2111" Password="RnaM2Pe9Ksgiwudg5fnAr3Fc7oGLKq6rEpBVfzLgouE=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="Folder2.1.1" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="" Domain="" Password="" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False">
<Node Name="Connection2.1.1.1" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="usernameforC2111" Domain="domainC2111" Password="+CCNb8oURT36EdVuDshvgW4Y42U1OwvoKwZCvQ+Mwwo=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
</Node>
</Node>
<Node Name="Folder2.2" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="folder2domain" Password="ZPh3lumDECS6zgJFeXtWYScn4WCPPJahMkfkAoKdkC4=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="True" InheritIcon="False" InheritPanel="False" InheritPassword="True" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="True" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False">
<Node Name="InheritalAllConnection" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="folder2domain" Password="0RS1CG8gyibBDcj1LgOuUYR+BXtWkIvuwonoGZ1f9/0=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="True" InheritColors="True" InheritDescription="True" InheritDisplayThemes="True" InheritDisplayWallpaper="True" InheritEnableFontSmoothing="True" InheritEnableDesktopComposition="True" InheritDomain="True" InheritIcon="True" InheritPanel="True" InheritPassword="True" InheritPort="True" InheritProtocol="True" InheritPuttySession="True" InheritRedirectDiskDrives="True" InheritRedirectKeys="True" InheritRedirectPorts="True" InheritRedirectPrinters="True" InheritRedirectSmartCards="True" InheritRedirectSound="True" InheritResolution="True" InheritAutomaticResize="True" InheritUseConsoleSession="True" InheritUseCredSsp="True" InheritRenderingEngine="True" InheritUsername="True" InheritICAEncryptionStrength="True" InheritRDPAuthenticationLevel="True" InheritLoadBalanceInfo="True" InheritPreExtApp="True" InheritPostExtApp="True" InheritMacAddress="True" InheritUserField="True" InheritExtApp="True" InheritVNCCompression="True" InheritVNCEncoding="True" InheritVNCAuthMode="True" InheritVNCProxyType="True" InheritVNCProxyIP="True" InheritVNCProxyPort="True" InheritVNCProxyUsername="True" InheritVNCProxyPassword="True" InheritVNCColors="True" InheritVNCSmartSizeMode="True" InheritVNCViewOnly="True" InheritRDGatewayUsageMethod="True" InheritRDGatewayHostname="True" InheritRDGatewayUseConnectionCredentials="True" InheritRDGatewayUsername="True" InheritRDGatewayPassword="True" InheritRDGatewayDomain="True" />
<Node Name="Folder2.2.1 InheritAll" Type="Container" Expanded="True" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="folder2domain" Password="XfhhpQnL1lp34KZITCKTgDD3+7C7t8VW6y26rERXG+A=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="True" InheritColors="True" InheritDescription="True" InheritDisplayThemes="True" InheritDisplayWallpaper="True" InheritEnableFontSmoothing="True" InheritEnableDesktopComposition="True" InheritDomain="True" InheritIcon="True" InheritPanel="True" InheritPassword="True" InheritPort="True" InheritProtocol="True" InheritPuttySession="True" InheritRedirectDiskDrives="True" InheritRedirectKeys="True" InheritRedirectPorts="True" InheritRedirectPrinters="True" InheritRedirectSmartCards="True" InheritRedirectSound="True" InheritResolution="True" InheritAutomaticResize="True" InheritUseConsoleSession="True" InheritUseCredSsp="True" InheritRenderingEngine="True" InheritUsername="True" InheritICAEncryptionStrength="True" InheritRDPAuthenticationLevel="True" InheritLoadBalanceInfo="True" InheritPreExtApp="True" InheritPostExtApp="True" InheritMacAddress="True" InheritUserField="True" InheritExtApp="True" InheritVNCCompression="True" InheritVNCEncoding="True" InheritVNCAuthMode="True" InheritVNCProxyType="True" InheritVNCProxyIP="True" InheritVNCProxyPort="True" InheritVNCProxyUsername="True" InheritVNCProxyPassword="True" InheritVNCColors="True" InheritVNCSmartSizeMode="True" InheritVNCViewOnly="True" InheritRDGatewayUsageMethod="True" InheritRDGatewayHostname="True" InheritRDGatewayUseConnectionCredentials="True" InheritRDGatewayUsername="True" InheritRDGatewayPassword="True" InheritRDGatewayDomain="True">
<Node Name="Connection2.2.1.1 InheritAll" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="folder2domain" Password="i4LCsy8+QgJ7xsDHh8ckf1h4Kno3sQYN9QhGD7vaTTc=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="True" InheritColors="True" InheritDescription="True" InheritDisplayThemes="True" InheritDisplayWallpaper="True" InheritEnableFontSmoothing="True" InheritEnableDesktopComposition="True" InheritDomain="True" InheritIcon="True" InheritPanel="True" InheritPassword="True" InheritPort="True" InheritProtocol="True" InheritPuttySession="True" InheritRedirectDiskDrives="True" InheritRedirectKeys="True" InheritRedirectPorts="True" InheritRedirectPrinters="True" InheritRedirectSmartCards="True" InheritRedirectSound="True" InheritResolution="True" InheritAutomaticResize="True" InheritUseConsoleSession="True" InheritUseCredSsp="True" InheritRenderingEngine="True" InheritUsername="True" InheritICAEncryptionStrength="True" InheritRDPAuthenticationLevel="True" InheritLoadBalanceInfo="True" InheritPreExtApp="True" InheritPostExtApp="True" InheritMacAddress="True" InheritUserField="True" InheritExtApp="True" InheritVNCCompression="True" InheritVNCEncoding="True" InheritVNCAuthMode="True" InheritVNCProxyType="True" InheritVNCProxyIP="True" InheritVNCProxyPort="True" InheritVNCProxyUsername="True" InheritVNCProxyPassword="True" InheritVNCColors="True" InheritVNCSmartSizeMode="True" InheritVNCViewOnly="True" InheritRDGatewayUsageMethod="True" InheritRDGatewayHostname="True" InheritRDGatewayUseConnectionCredentials="True" InheritRDGatewayUsername="True" InheritRDGatewayPassword="True" InheritRDGatewayDomain="True" />
</Node>
<Node Name="InheritUsernameConnection" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="userFolder2" Domain="inheritUsernameDomain" Password="IaLl8+z9y4uk7hYIvgwpQzrSuo7MFvfTGPNzT19I1n4zDkZJwwLO6ba4UcFECDe8" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="True" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="InheritDomainConnection" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="inheritDomainUsername" Domain="folder2domain" Password="DH57coImERkLQr0VIhReTRlBEatv45F3Dtz0hfzqzv9Hbhx48maiZx4XOFn4ZYvS" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="True" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
<Node Name="InheritPasswordConnection" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="inheritDomainUsername" Domain="inheritUsernameDomain" Password="8Whb2isHSTBVrMSMDFCeSnNOA6l5n6GUmf1+9be0HUI=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="True" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
</Node>
</Node>
<Node Name="rootConnection" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="root" Domain="rootdomain" Password="W2KSje/AD81hhjqdZeg8gkVvLozkd++94zH5hjOSWc0=" Hostname="" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="False" UseCredSsp="True" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" LoadBalanceInfo="" Colors="Colors16Bit" Resolution="FitToWindow" AutomaticResize="True" DisplayWallpaper="False" DisplayThemes="False" EnableFontSmoothing="False" EnableDesktopComposition="False" CacheBitmaps="False" RedirectDiskDrives="False" RedirectPorts="False" RedirectPrinters="False" RedirectSmartCards="False" RedirectSound="DoNotPlay" RedirectKeys="False" Connected="False" PreExtApp="" PostExtApp="" MacAddress="" UserField="" ExtApp="" VNCCompression="CompNone" VNCEncoding="EncHextile" VNCAuthMode="AuthVNC" VNCProxyType="ProxyNone" VNCProxyIP="" VNCProxyPort="0" VNCProxyUsername="" VNCProxyPassword="" VNCColors="ColNormal" VNCSmartSizeMode="SmartSAspect" VNCViewOnly="False" RDGatewayUsageMethod="Never" RDGatewayHostname="" RDGatewayUseConnectionCredentials="Yes" RDGatewayUsername="" RDGatewayPassword="" RDGatewayDomain="" InheritCacheBitmaps="False" InheritColors="False" InheritDescription="False" InheritDisplayThemes="False" InheritDisplayWallpaper="False" InheritEnableFontSmoothing="False" InheritEnableDesktopComposition="False" InheritDomain="False" InheritIcon="False" InheritPanel="False" InheritPassword="False" InheritPort="False" InheritProtocol="False" InheritPuttySession="False" InheritRedirectDiskDrives="False" InheritRedirectKeys="False" InheritRedirectPorts="False" InheritRedirectPrinters="False" InheritRedirectSmartCards="False" InheritRedirectSound="False" InheritResolution="False" InheritAutomaticResize="False" InheritUseConsoleSession="False" InheritUseCredSsp="False" InheritRenderingEngine="False" InheritUsername="False" InheritICAEncryptionStrength="False" InheritRDPAuthenticationLevel="False" InheritLoadBalanceInfo="False" InheritPreExtApp="False" InheritPostExtApp="False" InheritMacAddress="False" InheritUserField="False" InheritExtApp="False" InheritVNCCompression="False" InheritVNCEncoding="False" InheritVNCAuthMode="False" InheritVNCProxyType="False" InheritVNCProxyIP="False" InheritVNCProxyPort="False" InheritVNCProxyUsername="False" InheritVNCProxyPassword="False" InheritVNCColors="False" InheritVNCSmartSizeMode="False" InheritVNCViewOnly="False" InheritRDGatewayUsageMethod="False" InheritRDGatewayHostname="False" InheritRDGatewayUseConnectionCredentials="False" InheritRDGatewayUsername="False" InheritRDGatewayPassword="False" InheritRDGatewayDomain="False" />
</Connections>

View File

@@ -0,0 +1 @@
RmV7zw/a7ZRRzZdcTkrLDgBfyEmeh8OFMgg2OKFJnwg=

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RDCMan schemaVersion="1">
<version>99.99</version>
<file>
</file>
</RDCMan>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RDCMan schemaVersion="1">
<file>
</file>
</RDCMan>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RDCMan schemaVersion="-99">
<version>2.2</version>
<file>
</file>
</RDCMan>

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<RDCMan schemaVersion="1">
<version>2.2</version>
<file>
<properties>
<name>test_rdcman_v2_2_schema1</name>
<expanded>True</expanded>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</properties>
<group>
<properties>
<name>Group1</name>
<expanded>True</expanded>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</properties>
<server>
<name>server1</name>
<displayName>server1_displayname</displayName>
<comment>Comment text here</comment>
<logonCredentials inherit="None">
<userName>myusername1</userName>
<domain>mydomain</domain>
<password storeAsClearText="False">AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA/jk3lWsW+ku0n4AOVYyLTAAAAAACAAAAAAAQZgAAAAEAACAAAABhmrmYHd+c7VjWfPvxJ8pgi55yeV2brJDV/i9XzGUz6wAAAAAOgAAAAAIAACAAAAACJMhtb6tmkJn9vSv9J4VMWgt3S7Ikmf63xK/uKQ+YuyAAAACD3mJOT1910KD71zqbi+m/F6A0LK0tu0BhpOhr9v0yH0AAAADrb+Uv2btNYhfTUDGbw5pT5dbp5oXzc3I8QO7X1vgMXiI5TkrSxfHP/2j+Yak++vAjpVtzlxk49hpDLNAZnnhg</password>
</logonCredentials>
<connectionSettings inherit="None">
<connectToConsole>True</connectToConsole>
<startProgram />
<workingDir />
<port>9933</port>
</connectionSettings>
<gatewaySettings inherit="None">
<userName>gatewayusername</userName>
<domain>innerdomain</domain>
<password storeAsClearText="False">AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA/jk3lWsW+ku0n4AOVYyLTAAAAAACAAAAAAAQZgAAAAEAACAAAACgU917evQ54VsDf3nkofPOAPj0icRejg3yfyUwZqV3DgAAAAAOgAAAAAIAACAAAACuPdtJTxd2yvFuTpSOeZz1loraPu2WFqUXiJp4cfjbJTAAAAB8L5YX93h6pQoKJozrk+Y+spHWqP+eqBUXRJ45oLreKslslSWCEO7VWg4rgr0FYsNAAAAAU1i5aSTlBy99EkNEd2inrAJAopCfNig6osiEVdvA6eYnCogG5mhzYEK5d5Wt49S8HbEyuLF/8IxV0PKG53vCZQ==</password>
<enabled>True</enabled>
<hostName>gatewayserverhost.innerdomain.net</hostName>
<logonMethod>4</logonMethod>
<localBypass>False</localBypass>
<credSharing>False</credSharing>
</gatewaySettings>
<remoteDesktop inherit="None">
<size>1024 x 768</size>
<sameSizeAsClientArea>True</sameSizeAsClientArea>
<fullScreen>False</fullScreen>
<colorDepth>24</colorDepth>
</remoteDesktop>
<localResources inherit="None">
<audioRedirection>2</audioRedirection>
<audioRedirectionQuality>0</audioRedirectionQuality>
<audioCaptureRedirection>0</audioCaptureRedirection>
<keyboardHook>1</keyboardHook>
<redirectClipboard>True</redirectClipboard>
<redirectDrives>True</redirectDrives>
<redirectPorts>True</redirectPorts>
<redirectPrinters>True</redirectPrinters>
<redirectSmartCards>True</redirectSmartCards>
</localResources>
<securitySettings inherit="None">
<authentication>1</authentication>
</securitySettings>
<displaySettings inherit="None">
<thumbnailScale>1</thumbnailScale>
</displaySettings>
</server>
<server>
<name>server2</name>
<displayName>server2</displayName>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</server>
</group>
<group>
<properties>
<name>Group2</name>
<expanded>True</expanded>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</properties>
<group>
<properties>
<name>Group3</name>
<expanded>True</expanded>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</properties>
<server>
<name>server3</name>
<displayName>server3</displayName>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</server>
<server>
<name>server4</name>
<displayName>server4</displayName>
<comment />
<logonCredentials inherit="FromParent" />
<connectionSettings inherit="FromParent" />
<gatewaySettings inherit="FromParent" />
<remoteDesktop inherit="FromParent" />
<localResources inherit="FromParent" />
<securitySettings inherit="FromParent" />
<displaySettings inherit="FromParent" />
</server>
</group>
</group>
</file>
</RDCMan>

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<RDCMan programVersion="2.7" schemaVersion="3">
<file>
<credentialsProfiles />
<properties>
<expanded>True</expanded>
<name>test_RDCMan_connections</name>
</properties>
<smartGroup>
<properties>
<expanded>False</expanded>
<name>AllServers</name>
</properties>
<ruleGroup operator="All">
<rule>
<property>DisplayName</property>
<operator>Matches</operator>
<value>server</value>
</rule>
</ruleGroup>
</smartGroup>
<group>
<properties>
<expanded>True</expanded>
<name>Group1</name>
</properties>
<server>
<properties>
<name>server1</name>
</properties>
<logonCredentials inherit="None">
<profileName scope="Local">Custom</profileName>
<userName>someusername1</userName>
<password>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA/jk3lWsW+ku0n4AOVYyLTAAAAAACAAAAAAAQZgAAAAEAACAAAACZryl2a4trJLcUdyg7jL/m51fxn4Vy+je6SBhT5FasmgAAAAAOgAAAAAIAACAAAAAcG6MQhKFvEcKRrRE74YKrrnYKxLFnVxbGzyfl7JoyvjAAAACAofcbQqcr6h9VQuwwWW5IBkW1zsugofl1MjsL9t2uWfuBgnrya1Xlyue5E7cG8BZAAAAApgx/XXqBqXhr6CV2SJTlXihg7n5epOIT02A8ymy3qRftDgXlmu3IaN7krK3gofv+iNdVrvIdJJMYCihm7dyqOw==</password>
<domain>mydomain</domain>
</logonCredentials>
<connectionSettings inherit="None">
<connectToConsole>False</connectToConsole>
<startProgram />
<workingDir />
<port>9933</port>
<loadBalanceInfo />
</connectionSettings>
<gatewaySettings inherit="None">
<enabled>True</enabled>
<hostName>gatewayserver.innerdomain.net</hostName>
<logonMethod>Any</logonMethod>
<localBypass>True</localBypass>
<credSharing>True</credSharing>
<profileName scope="Local">Custom</profileName>
<userName />
<password />
<domain />
</gatewaySettings>
<remoteDesktop inherit="None">
<sameSizeAsClientArea>False</sameSizeAsClientArea>
<fullScreen>True</fullScreen>
<colorDepth>24</colorDepth>
</remoteDesktop>
<localResources inherit="None">
<audioRedirection>Client</audioRedirection>
<audioRedirectionQuality>Dynamic</audioRedirectionQuality>
<audioCaptureRedirection>DoNotRecord</audioCaptureRedirection>
<keyboardHook>FullScreenClient</keyboardHook>
<redirectClipboard>True</redirectClipboard>
<redirectDrives>True</redirectDrives>
<redirectDrivesList>
<item>C:\</item>
<item>D:\</item>
<item>E:\</item>
<item>F:\</item>
<item>G:\</item>
</redirectDrivesList>
<redirectPrinters>True</redirectPrinters>
<redirectPorts>True</redirectPorts>
<redirectSmartCards>True</redirectSmartCards>
<redirectPnpDevices>True</redirectPnpDevices>
</localResources>
<displaySettings inherit="None">
<thumbnailScale>1</thumbnailScale>
<smartSizeDockedWindows>False</smartSizeDockedWindows>
<smartSizeUndockedWindows>False</smartSizeUndockedWindows>
</displaySettings>
<securitySettings inherit="None">
<authentication>Warn</authentication>
</securitySettings>
</server>
<server>
<properties>
<name>server2</name>
</properties>
</server>
</group>
<group>
<properties>
<expanded>True</expanded>
<name>Group2</name>
</properties>
<group>
<properties>
<expanded>True</expanded>
<name>Group3</name>
</properties>
<server>
<properties>
<name>server3</name>
</properties>
</server>
<server>
<properties>
<name>server4</name>
</properties>
</server>
</group>
</group>
</file>
<connected />
<favorites />
<recentlyUsed />
</RDCMan>

View File

@@ -1,17 +1,19 @@
using System.Security;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNGTests.Properties;
using NUnit.Framework;
namespace mRemoteNGTests.Security
{
[TestFixture()]
public class LegacyRijndaelCryptographyProviderTests
{
private ICryptographyProvider _rijndaelCryptographyProvider;
private SecureString _encryptionKey;
private string _plainText;
private string _importedCipherText = Resources.legacyrijndael_ciphertext;
[SetUp]
public void SetUp()
@@ -55,5 +57,12 @@ namespace mRemoteNGTests.Security
var cipherText2 = _rijndaelCryptographyProvider.Encrypt(_plainText, _encryptionKey);
Assert.That(cipherText1, Is.Not.EqualTo(cipherText2));
}
[Test]
public void DecryptingFromPreviousApplicationExecutionWorks()
{
var decryptedCipherText = _rijndaelCryptographyProvider.Decrypt(_importedCipherText, _encryptionKey);
Assert.That(decryptedCipherText, Is.EqualTo(_plainText));
}
}
}

View File

@@ -0,0 +1,100 @@
using mRemoteNG.Connection;
using mRemoteNG.Tools;
using NUnit.Framework;
namespace mRemoteNGTests.Tools
{
public class ExternalToolsArgumentParserTests
{
private ExternalToolArgumentParser _argumentParser;
private const string TestString = @"()%!^abc123*<>&|""'\";
private const string StringAfterMetacharacterEscaping = @"^(^)^%^!^^abc123*^<^>^&^|^""'\";
private const string StringAfterAllEscaping = @"^(^)^%^!^^abc123*^<^>^&^|\^""'\";
private const string StringAfterNoEscaping = TestString;
private const int Port = 9933;
private const string PortAsString = "9933";
private const string SampleCommandString = @"/k echo ()%!^abc123*<>&|""'\";
[OneTimeSetUp]
public void Setup()
{
var connectionInfo = new ConnectionInfo
{
Name = TestString,
Hostname = TestString,
Port = Port,
Username = TestString,
Password = TestString,
Domain = TestString,
Description = TestString,
MacAddress = TestString,
UserField = TestString
};
_argumentParser = new ExternalToolArgumentParser(connectionInfo);
}
[OneTimeTearDown]
public void Teardown()
{
_argumentParser = null;
}
[TestCase("%NAME%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-NAME%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!NAME%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%HOSTNAME%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-HOSTNAME%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!HOSTNAME%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%PORT%", ExpectedResult = PortAsString)]
[TestCase("%-PORT%", ExpectedResult = PortAsString)]
[TestCase("%!PORT%", ExpectedResult = PortAsString)]
[TestCase("%USERNAME%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-USERNAME%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!USERNAME%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%PASSWORD%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-PASSWORD%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!PASSWORD%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%DOMAIN%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-DOMAIN%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!DOMAIN%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%DESCRIPTION%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-DESCRIPTION%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!DESCRIPTION%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%MACADDRESS%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-MACADDRESS%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!MACADDRESS%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%USERFIELD%", ExpectedResult = StringAfterAllEscaping)]
[TestCase("%-USERFIELD%", ExpectedResult = StringAfterMetacharacterEscaping)]
[TestCase("%!USERFIELD%", ExpectedResult = StringAfterNoEscaping)]
[TestCase("%%", ExpectedResult = "%%", TestName = "EmptyVariableTagsNotParsed")]
[TestCase("/k echo %!USERNAME%", ExpectedResult = SampleCommandString, TestName = "ParsingWorksWhenVariableIsNotInFirstPosition")]
[TestCase("%COMSPEC%", ExpectedResult = @"C:\Windows\system32\cmd.exe", TestName = "EnvironmentVariablesParsed")]
[TestCase("%UNSUPPORTEDPARAMETER%", ExpectedResult = "%UNSUPPORTEDPARAMETER%", TestName = "UnsupportedParametersNotParsed")]
[TestCase(@"\%COMSPEC\%", ExpectedResult = @"C:\Windows\system32\cmd.exe", TestName = "BackslashEscapedEnvironmentVariablesParsed")]
[TestCase(@"^%COMSPEC^%", ExpectedResult = "%COMSPEC%", TestName = "ChevronEscapedEnvironmentVariablesNotParsed")]
public string ParserTests(string argumentString)
{
return _argumentParser.ParseArguments(argumentString);
}
[Test]
public void NullConnectionInfoResultsInEmptyVariables()
{
var parser = new ExternalToolArgumentParser(null);
var parsedText = parser.ParseArguments("test %USERNAME% test");
Assert.That(parsedText, Is.EqualTo("test test"));
}
}
}

View File

@@ -0,0 +1,288 @@
using System.Windows.Forms;
using BrightIdeasSoftware;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Root.PuttySessions;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Tree
{
public class ConnectionTreeDragAndDropHandlerTests
{
private ConnectionTreeDragAndDropHandler _dragAndDropHandler;
private RootNodeInfo _rootNode;
private ContainerInfo _container1;
private ContainerInfo _container2;
private ContainerInfo _container3;
private ConnectionInfo _connection1;
private ConnectionInfo _connection2;
private ConnectionInfo _connection3;
private ConnectionInfo _connection4;
private ConnectionInfo _connection5;
[SetUp]
public void Setup()
{
_dragAndDropHandler = new ConnectionTreeDragAndDropHandler();
InitializeNodes();
CreateSimpleTreeModel();
}
[TearDown]
public void Teardown()
{
_dragAndDropHandler = null;
DestroyNodes();
}
[Test]
public void CanDragConnectionOntoContainer()
{
var source = _connection3;
var target = _container1;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.Move));
}
[Test]
public void CanDragContainerOntoContainer()
{
var source = _container1;
var target = _container2;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.Move));
}
[Test]
public void CanDragContainerBetweenContainers()
{
var source = _container3;
var target = _container2;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.AboveItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.Move));
}
[Test]
public void CanDragConnectionBetweenConnections()
{
var source = _connection1;
var target = _connection4;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.AboveItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.Move));
}
[Test]
public void CantDragConnectionOntoItself()
{
var source = _connection1;
var target = _connection1;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragContainerOntoItself()
{
var source = _container1;
var target = _container1;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragContainerOntoItsChild()
{
var source = _container2;
var target = _container3;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragContainerBetweenItsChildren()
{
var source = _container3;
var target = _connection4;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.BelowItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragNodeOntoItsCurrentParent()
{
var source = _container3;
var target = _container2;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragRootNodeInfo()
{
var source = _rootNode;
var target = new ContainerInfo();
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragNodeAboveRootNodeInfo()
{
var source = _connection1;
var target = _rootNode;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.AboveItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragNodeBelowRootNodeInfo()
{
var source = _connection1;
var target = _rootNode;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.BelowItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragPuttySessionInfo()
{
var source = new PuttySessionInfo();
var target = _container2;
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragConnectionOntoRootPuttySessionNode()
{
var source = _connection1;
var target = new RootPuttySessionsNodeInfo();
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragContainerOntoRootPuttySessionNode()
{
var source = _container1;
var target = new RootPuttySessionsNodeInfo();
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragNodeAbovePuttySessionNodes()
{
var source = _connection1;
var target = new PuttySessionInfo();
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.AboveItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void CantDragNodeBelowPuttySessionNodes()
{
var source = _connection1;
var target = new PuttySessionInfo();
var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.BelowItem);
Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
}
[Test]
public void DraggingNodeBelowSiblingRearrangesTheUnderlyingModelCorrectly()
{
var source = _connection3;
var target = _connection5;
var location = DropTargetLocation.BelowItem;
_dragAndDropHandler.DropModel(source, target, location);
var actualIndex = _container3.Children.IndexOf(source);
var expectedIndex = _container3.Children.IndexOf(target) + 1;
Assert.That(actualIndex, Is.EqualTo(expectedIndex));
}
[Test]
public void DraggingNodeAboveSiblingRearrangesTheUnderlyingModelCorrectly()
{
var source = _connection3;
var target = _connection5;
var location = DropTargetLocation.AboveItem;
_dragAndDropHandler.DropModel(source, target, location);
var actualIndex = _container3.Children.IndexOf(source);
var expectedIndex = _container3.Children.IndexOf(target) - 1;
Assert.That(actualIndex, Is.EqualTo(expectedIndex));
}
[Test]
public void DraggingNodeToNewContainerAddsNodeToTheNewContainer()
{
var source = _connection3;
var target = _container1;
var location = DropTargetLocation.Item;
_dragAndDropHandler.DropModel(source, target, location);
Assert.That(target.Children.Contains(source));
}
[Test]
public void DraggingNodeToNewContainerRemovesNodeFromOldContainer()
{
var source = _connection3;
var target = _container1;
var location = DropTargetLocation.Item;
_dragAndDropHandler.DropModel(source, target, location);
Assert.That(!_container3.Children.Contains(source));
}
private void InitializeNodes()
{
_rootNode = new RootNodeInfo(RootNodeType.Connection);
_container1 = new ContainerInfo();
_container2 = new ContainerInfo();
_container3 = new ContainerInfo();
_connection1 = new ConnectionInfo();
_connection2 = new ConnectionInfo();
_connection3 = new ConnectionInfo();
_connection4 = new ConnectionInfo();
_connection5 = new ConnectionInfo();
}
private void CreateSimpleTreeModel()
{
/*
* Root
* |-- container1
* | L-- connection1
* L-- container2
* |-- container3
* | |-- connection3
* | |-- connection4
* | L-- connection5
* L-- connection2
*/
_rootNode.AddChild(_container1);
_rootNode.AddChild(_container2);
_container1.AddChild(_connection1);
_container2.AddChild(_container3);
_container2.AddChild(_connection2);
_container3.AddChild(_connection3);
_container3.AddChild(_connection4);
_container3.AddChild(_connection5);
}
private void DestroyNodes()
{
_rootNode = null;
_container1 = null;
_container2 = null;
_container3 = null;
_connection1 = null;
_connection2 = null;
_connection3 = null;
_connection4 = null;
_connection5 = null;
}
}
}

View File

@@ -0,0 +1,40 @@
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using NUnit.Framework;
namespace mRemoteNGTests.Tree
{
public class ConnectionTreeModelTests
{
private ConnectionTreeModel _connectionTreeModel;
[SetUp]
public void Setup()
{
_connectionTreeModel = new ConnectionTreeModel();
}
[TearDown]
public void Teardown()
{
_connectionTreeModel = null;
}
[Test]
public void GetChildListProvidesAllChildren()
{
var root = new ContainerInfo();
var folder1 = new ContainerInfo();
var folder2 = new ContainerInfo();
var con1 = new ConnectionInfo();
root.AddChild(folder1);
folder1.AddChild(folder2);
root.AddChild(con1);
_connectionTreeModel.AddRootNode(root);
var connectionList = _connectionTreeModel.GetRecursiveChildList(root);
Assert.That(connectionList, Is.EquivalentTo(new[] {folder1,folder2,con1}));
}
}
}

View File

@@ -73,6 +73,10 @@
<Reference Include="NUnitForms">
<HintPath>nUnitForms\bin\NUnitForms.dll</HintPath>
</Reference>
<Reference Include="ObjectListView, Version=2.9.1.1072, Culture=neutral, PublicKeyToken=b1c5bf581481bcd4, processorArchitecture=MSIL">
<HintPath>..\packages\ObjectListView.Official.2.9.1\lib\net20\ObjectListView.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -86,6 +90,7 @@
<HintPath>..\packages\DockPanelSuite.ThemeVS2012Light.2.10.0\lib\net40\WeifenLuo.WinFormsUI.Docking.ThemeVS2012Light.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
@@ -102,6 +107,17 @@
<ItemGroup>
<Compile Include="App\LoggerTests.cs" />
<Compile Include="BinaryFileTests.cs" />
<Compile Include="Config\Serializers\DataTableSerializerTests.cs" />
<Compile Include="Config\Serializers\PortScanDeserializerTests.cs" />
<Compile Include="Config\Serializers\PuttyConnectionManagerDeserializerTests.cs" />
<Compile Include="Config\Serializers\XmlConnectionsDeserializerTests.cs" />
<Compile Include="Config\Serializers\RemoteDesktopConnectionDeserializerTests.cs" />
<Compile Include="Config\Serializers\RemoteDesktopConnectionManagerDeserializerTests.cs" />
<Compile Include="Connection\AbstractConnectionInfoDataTests.cs" />
<Compile Include="Connection\ConnectionInfoComparerTests.cs" />
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
<Compile Include="Tree\ConnectionTreeDragAndDropHandlerTests.cs" />
<Compile Include="Tree\ConnectionTreeModelTests.cs" />
<Compile Include="Connection\ConnectionInfoInheritanceTests.cs" />
<Compile Include="Connection\ConnectionInfoTests.cs" />
<Compile Include="Connection\DefaultConnectionInfoTests.cs" />
@@ -110,9 +126,12 @@
<Compile Include="IntegrationTests\ConnectionInheritanceIntegrationTests.cs" />
<Compile Include="ListViewTester.cs" />
<Compile Include="Config\Connections\SqlConnectionUpdateCheckerTests.cs" />
<Compile Include="Config\Connections\SqlUpdateQueryBuilderTest.cs" />
<Compile Include="Config\Connections\SqlUpdateTimerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Security\AeadCryptographyProviderTests.cs" />
<Compile Include="Security\CryptographyProviderFactoryTests.cs" />
<Compile Include="Security\EncryptedSecureStringTests.cs" />
@@ -138,10 +157,26 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UI\Controls\TestForm.resx">
<DependentUpon>TestForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\legacyrijndael_ciphertext.txt" />
<Content Include="Resources\TestConfCons.xml" />
<None Include="Resources\test_puttyConnectionManager_database.dat" />
<None Include="Resources\test_rdcman_badVersionNumber.rdg" />
<None Include="Resources\test_rdcman_noversion.rdg" />
<None Include="Resources\test_rdcman_v2_2_badschemaversion.rdg" />
<None Include="Resources\test_rdcman_v2_2_schema1.rdg" />
<None Include="Resources\test_RDCMan_v2_7_schema3.rdg" />
<None Include="Resources\test_remotedesktopconnection.rdp" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>

View File

@@ -5,4 +5,5 @@
<package id="DockPanelSuite.ThemeVS2012Light" version="2.10.0" targetFramework="net45" />
<package id="NSubstitute" version="1.10.0.0" targetFramework="net45" />
<package id="NUnit" version="3.4.1" targetFramework="net45" />
<package id="ObjectListView.Official" version="2.9.1" targetFramework="net45" />
</packages>

View File

@@ -1,6 +1,14 @@
using System;
using System.Linq;
using System.Windows.Forms;
using mRemoteNG.Config.Connections;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Forms;
@@ -8,43 +16,37 @@ namespace mRemoteNG.App
{
public static class Export
{
public static void ExportToFile(TreeNode rootTreeNode, TreeNode selectedTreeNode)
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
{
try
{
Security.Save saveSecurity = new Security.Save();
var saveSecurity = new Save();
using (ExportForm exportForm = new ExportForm())
using (var exportForm = new ExportForm())
{
if (Tree.ConnectionTreeNode.GetNodeType(selectedTreeNode) == Tree.TreeNodeType.Container)
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
exportForm.SelectedFolder = selectedNode as ContainerInfo;
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
{
exportForm.SelectedFolder = selectedTreeNode;
}
else if (Tree.ConnectionTreeNode.GetNodeType(selectedTreeNode) == Tree.TreeNodeType.Connection)
{
if (Tree.ConnectionTreeNode.GetNodeType(selectedTreeNode.Parent) == Tree.TreeNodeType.Container)
{
exportForm.SelectedFolder = selectedTreeNode.Parent;
}
exportForm.SelectedConnection = selectedTreeNode;
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
exportForm.SelectedFolder = selectedNode.Parent;
exportForm.SelectedConnection = selectedNode;
}
if (exportForm.ShowDialog(frmMain.Default) != DialogResult.OK)
{
return ;
}
TreeNode exportTreeNode;
ConnectionInfo exportTarget;
switch (exportForm.Scope)
{
case ExportForm.ExportScope.SelectedFolder:
exportTreeNode = exportForm.SelectedFolder;
exportTarget = exportForm.SelectedFolder;
break;
case ExportForm.ExportScope.SelectedConnection:
exportTreeNode = exportForm.SelectedConnection;
exportTarget = exportForm.SelectedConnection;
break;
default:
exportTreeNode = rootTreeNode;
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
break;
}
@@ -53,7 +55,7 @@ namespace mRemoteNG.App
saveSecurity.Domain = exportForm.IncludeDomain;
saveSecurity.Inheritance = exportForm.IncludeInheritance;
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, exportTreeNode, saveSecurity);
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveSecurity, exportTarget);
}
}
@@ -63,37 +65,39 @@ namespace mRemoteNG.App
}
}
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, TreeNode rootNode, Security.Save saveSecurity)
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, Save saveSecurity, ConnectionInfo exportTarget)
{
try
{
if (Runtime.SQLConnProvider != null)
{
Runtime.SQLConnProvider.Disable();
}
ConnectionsSaver connectionsSave = new ConnectionsSaver
ISerializer<string> serializer;
switch (saveFormat)
{
Export = true,
ConnectionFileName = fileName,
SaveFormat = saveFormat,
ConnectionList = Runtime.ConnectionList,
ContainerList = Runtime.ContainerList,
RootTreeNode = rootNode,
SaveSecurity = saveSecurity
};
connectionsSave.SaveConnections();
case ConnectionsSaver.Format.mRXML:
serializer = new XmlConnectionsSerializer();
((XmlConnectionsSerializer) serializer).SaveSecurity = saveSecurity;
break;
case ConnectionsSaver.Format.mRCSV:
serializer = new CsvConnectionsSerializerMremotengFormat();
((CsvConnectionsSerializerMremotengFormat)serializer).SaveSecurity = saveSecurity;
break;
case ConnectionsSaver.Format.vRDCSV:
serializer = new CsvConnectionsSerializerRemoteDesktop2008Format();
((CsvConnectionsSerializerRemoteDesktop2008Format)serializer).SaveSecurity = saveSecurity;
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);
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
}
finally
{
if (Runtime.SQLConnProvider != null)
{
Runtime.SQLConnProvider.Enable();
}
Runtime.RemoteConnectionsSyncronizer?.Enable();
}
}
}

View File

@@ -1,20 +1,17 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using mRemoteNG.Config.Import;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.UI.TaskDialog;
using mRemoteNG.Tools;
namespace mRemoteNG.App
{
public class Import
{
#region Private Enumerations
private enum FileType
{
Unknown = 0,
@@ -25,12 +22,8 @@ namespace mRemoteNG.App
PuttyConnectionManager
}
#endregion
#region Public Methods
public static void ImportFromFile(TreeNode rootTreeNode, TreeNode selectedTreeNode,
bool alwaysUseSelectedTreeNode = false)
public static void ImportFromFile(ContainerInfo importDestinationContainer, bool alwaysUseSelectedTreeNode = false)
{
try
{
@@ -51,37 +44,31 @@ namespace mRemoteNG.App
openFileDialog.Filter = string.Join("|", fileTypes.ToArray());
if (openFileDialog.ShowDialog() != DialogResult.OK)
{
return;
}
var parentTreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode, alwaysUseSelectedTreeNode);
if (parentTreeNode == null)
{
return;
}
foreach (var fileName in openFileDialog.FileNames)
{
try
{
IConnectionImporter importer;
switch (DetermineFileType(fileName))
{
case FileType.mRemoteXml:
Config.Import.mRemoteNGImporter.Import(fileName, parentTreeNode);
importer = new mRemoteNGImporter();
break;
case FileType.RemoteDesktopConnection:
RemoteDesktopConnection.Import(fileName, parentTreeNode);
importer = new RemoteDesktopConnectionImporter();
break;
case FileType.RemoteDesktopConnectionManager:
RemoteDesktopConnectionManager.Import(fileName, parentTreeNode);
importer = new RemoteDesktopConnectionManagerImporter();
break;
case FileType.PuttyConnectionManager:
PuttyConnectionManager.Import(fileName, parentTreeNode);
importer = new PuttyConnectionManagerImporter();
break;
default:
throw new FileFormatException("Unrecognized file format.");
}
importer.Import(fileName, importDestinationContainer);
}
catch (Exception ex)
{
@@ -91,14 +78,7 @@ namespace mRemoteNG.App
}
}
parentTreeNode.Expand();
var parentContainer = (ContainerInfo) parentTreeNode.Tag;
if (parentContainer != null)
{
parentContainer.IsExpanded = true;
}
Runtime.SaveConnectionsBG();
Runtime.SaveConnectionsAsync();
}
}
catch (Exception ex)
@@ -107,60 +87,27 @@ namespace mRemoteNG.App
}
}
public static void ImportFromActiveDirectory(string ldapPath)
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer)
{
try
{
var rootTreeNode = ConnectionTree.TreeView.Nodes[0];
var selectedTreeNode = ConnectionTree.TreeView.SelectedNode;
var parentTreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode);
if (parentTreeNode == null)
{
return;
}
ActiveDirectory.Import(ldapPath, parentTreeNode);
parentTreeNode.Expand();
var parentContainer = (ContainerInfo) parentTreeNode.Tag;
if (parentContainer != null)
{
parentContainer.IsExpanded = true;
}
Runtime.SaveConnectionsBG();
var importer = new ActiveDirectoryImporter();
importer.Import(ldapPath, importDestinationContainer);
Runtime.SaveConnectionsAsync();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromActiveDirectory() failed.", ex,
logOnly: true);
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromActiveDirectory() failed.", ex, logOnly: true);
}
}
public static void ImportFromPortScan(IEnumerable hosts, ProtocolType protocol)
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
{
try
{
var rootTreeNode = ConnectionTree.TreeView.Nodes[0];
var selectedTreeNode = ConnectionTree.TreeView.SelectedNode;
var parentTreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode);
if (parentTreeNode == null)
{
return;
}
PortScan.Import(hosts, protocol, parentTreeNode);
parentTreeNode.Expand();
var parentContainer = (ContainerInfo) parentTreeNode.Tag;
if (parentContainer != null)
{
parentContainer.IsExpanded = true;
}
Runtime.SaveConnectionsBG();
var importer = new PortScanImporter(protocol);
importer.Import(hosts, importDestinationContainer);
Runtime.SaveConnectionsAsync();
}
catch (Exception ex)
{
@@ -168,65 +115,8 @@ namespace mRemoteNG.App
logOnly: true);
}
}
#endregion
#region Private Methods
private static TreeNode GetParentTreeNode(TreeNode rootTreeNode, TreeNode selectedTreeNode,
bool alwaysUseSelectedTreeNode = false)
{
TreeNode parentTreeNode;
selectedTreeNode = GetContainerTreeNode(selectedTreeNode);
if (selectedTreeNode == null || selectedTreeNode == rootTreeNode)
{
parentTreeNode = rootTreeNode;
}
else
{
if (alwaysUseSelectedTreeNode)
{
parentTreeNode = GetContainerTreeNode(selectedTreeNode);
}
else
{
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strImportLocationMainInstruction,
Language.strImportLocationContent, "", "", "",
string.Format(Language.strImportLocationCommandButtons, Environment.NewLine, rootTreeNode.Text,
selectedTreeNode.Text), true, ESysIcons.Question, 0);
switch (CTaskDialog.CommandButtonResult)
{
case 0: // Root
parentTreeNode = rootTreeNode;
break;
case 1: // Selected Folder
parentTreeNode = GetContainerTreeNode(selectedTreeNode);
break;
default: // Cancel
parentTreeNode = null;
break;
}
}
}
return parentTreeNode;
}
private static TreeNode GetContainerTreeNode(TreeNode treeNode)
{
if ((ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Root) ||
(ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Container))
{
return treeNode;
}
if (ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection)
{
return treeNode.Parent;
}
return null;
}
private static FileType DetermineFileType(string fileName)
{
// TODO: Use the file contents to determine the file type instead of trusting the extension
@@ -245,7 +135,5 @@ namespace mRemoteNG.App
return FileType.Unknown;
}
}
#endregion
}
}

View File

@@ -24,6 +24,8 @@ namespace mRemoteNG.App
private static void StartApplication()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Startup.Instance.InitializeProgram();
Application.Run(frmMain.Default);
}

View File

@@ -2,9 +2,6 @@ using mRemoteNG.App.Info;
using mRemoteNG.Config.Connections;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Credential;
using mRemoteNG.Messages;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
@@ -14,16 +11,17 @@ using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Security;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Forms.Input;
using mRemoteNG.UI.TaskDialog;
using WeifenLuo.WinFormsUI.Docking;
using static System.IO.Path;
using TabPage = Crownwood.Magic.Controls.TabPage;
namespace mRemoteNG.App
@@ -31,50 +29,19 @@ namespace mRemoteNG.App
public static class Runtime
{
#region Public Properties
public static ConnectionList ConnectionList { get; set; }
private static ConnectionList PreviousConnectionList { get; set; }
public static ContainerList ContainerList { get; set; }
private static ContainerList PreviousContainerList { get; set; }
public static CredentialList CredentialList { get; set; }
public static CredentialList PreviousCredentialList { get; set; }
public static WindowList WindowList { get; set; }
public static MessageCollector MessageCollector { get; set; }
public static Tools.Controls.NotificationAreaIcon NotificationAreaIcon { get; set; }
public static Controls.NotificationAreaIcon NotificationAreaIcon { get; set; }
public static bool IsConnectionsFileLoaded { get; set; }
public static SqlConnectionsProvider SQLConnProvider { get; set; }
/*
public static System.Timers.Timer TimerSqlWatcher
{
get { return _timerSqlWatcher; }
set
{
_timerSqlWatcher = value;
_timerSqlWatcher.Elapsed += tmrSqlWatcher_Elapsed;
}
}
*/
public static RemoteConnectionsSyncronizer RemoteConnectionsSyncronizer { get; set; }
public static DateTime LastSqlUpdate { get; set; }
public static string LastSelected { get; set; }
public static ConnectionInfo DefaultConnection { get; set; } = DefaultConnectionInfo.Instance;
public static ConnectionInfoInheritance DefaultInheritance { get; set; }
public static ArrayList ExternalTools { get; set; } = new ArrayList();
public static SecureString EncryptionKey { get; set; } = "mR3m".ConvertToSecureString();
public static ConnectionTreeModel ConnectionTreeModel
{
get { return Windows.TreeForm.ConnectionTreeModel; }
set { Windows.TreeForm.ConnectionTreeModel = value; }
}
#endregion
#region Panels
@@ -229,8 +196,6 @@ namespace mRemoteNG.App
{
try
{
ConnectionList = new ConnectionList();
ContainerList = new ContainerList();
ConnectionsLoader connectionsLoader = new ConnectionsLoader();
if (filename == GetDefaultStartupConnectionFileName())
@@ -267,15 +232,10 @@ namespace mRemoteNG.App
}
connectionsLoader.ConnectionList = ConnectionList;
connectionsLoader.ContainerList = ContainerList;
ConnectionTree.ResetTree();
connectionsLoader.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0];
// Load config
connectionsLoader.ConnectionFileName = filename;
connectionsLoader.LoadConnections(false);
Windows.treeForm.tvConnections.SelectedNode = connectionsLoader.RootTreeNode;
ConnectionTreeModel = connectionsLoader.LoadConnections(false);
Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel;
}
catch (Exception ex)
{
@@ -283,7 +243,7 @@ namespace mRemoteNG.App
}
}
public static void LoadConnectionsBG()
public static void LoadConnectionsAsync()
{
_withDialog = false;
_loadUpdate = true;
@@ -306,22 +266,13 @@ namespace mRemoteNG.App
try
{
// disable sql update checking while we are loading updates
SQLConnProvider?.Disable();
if (ConnectionList != null && ContainerList != null)
{
PreviousConnectionList = ConnectionList.Copy();
PreviousContainerList = ContainerList.Copy();
}
ConnectionList = new ConnectionList();
ContainerList = new ContainerList();
RemoteConnectionsSyncronizer?.Disable();
if (!Settings.Default.UseSQLServer)
{
if (withDialog)
{
var loadDialog = Tools.Controls.ConnectionsLoadDialog();
var loadDialog = Controls.ConnectionsLoadDialog();
if (loadDialog.ShowDialog() != DialogResult.OK) return;
connectionsLoader.ConnectionFileName = loadDialog.FileName;
}
@@ -333,31 +284,9 @@ namespace mRemoteNG.App
CreateBackupFile(Convert.ToString(connectionsLoader.ConnectionFileName));
}
connectionsLoader.ConnectionList = ConnectionList;
connectionsLoader.ContainerList = ContainerList;
if (PreviousConnectionList != null && PreviousContainerList != null)
{
connectionsLoader.PreviousConnectionList = PreviousConnectionList;
connectionsLoader.PreviousContainerList = PreviousContainerList;
}
if (update)
{
connectionsLoader.PreviousSelected = LastSelected;
}
ConnectionTree.ResetTree();
connectionsLoader.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0];
connectionsLoader.UseDatabase = Settings.Default.UseSQLServer;
connectionsLoader.DatabaseHost = Settings.Default.SQLHost;
connectionsLoader.DatabaseName = Settings.Default.SQLDatabaseName;
connectionsLoader.DatabaseUsername = Settings.Default.SQLUser;
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
connectionsLoader.DatabasePassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey);
connectionsLoader.DatabaseUpdate = update;
connectionsLoader.LoadConnections(false);
ConnectionTreeModel = connectionsLoader.LoadConnections(false);
Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel;
if (Settings.Default.UseSQLServer)
{
@@ -377,7 +306,7 @@ namespace mRemoteNG.App
}
// re-enable sql update checking after updates are loaded
SQLConnProvider?.Enable();
RemoteConnectionsSyncronizer?.Enable();
}
catch (Exception ex)
{
@@ -416,7 +345,7 @@ namespace mRemoteNG.App
{
MessageBox.Show(frmMain.Default,
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
@@ -432,7 +361,7 @@ namespace mRemoteNG.App
try
{
string backupFileName = string.Format(Settings.Default.BackupFileNameFormat, fileName, DateTime.UtcNow);
var backupFileName = string.Format(Settings.Default.BackupFileNameFormat, fileName, DateTime.UtcNow);
File.Copy(fileName, backupFileName);
PruneBackupFiles(fileName);
}
@@ -495,71 +424,58 @@ namespace mRemoteNG.App
}
}
public static void SaveConnectionsBG()
public static void SaveConnectionsAsync()
{
_saveUpdate = true;
Thread t = new Thread(SaveConnectionsBGd);
var t = new Thread(SaveConnectionsBGd);
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
private static bool _saveUpdate;
private static object _saveLock = new object();
private static readonly object SaveLock = new object();
private static void SaveConnectionsBGd()
{
Monitor.Enter(_saveLock);
Monitor.Enter(SaveLock);
SaveConnections(_saveUpdate);
Monitor.Exit(_saveLock);
Monitor.Exit(SaveLock);
}
public static void SaveConnections(bool Update = false)
public static void SaveConnections(bool update = false)
{
if (!IsConnectionsFileLoaded)
{
return;
}
//if (!IsConnectionsFileLoaded)
// return;
try
{
if (Update && Settings.Default.UseSQLServer == false)
{
if (update && Settings.Default.UseSQLServer == false)
return;
}
if (SQLConnProvider != null)
{
SQLConnProvider.Disable();
}
RemoteConnectionsSyncronizer?.Disable();
ConnectionsSaver conS = new ConnectionsSaver();
var connectionsSaver = new ConnectionsSaver();
if (!Settings.Default.UseSQLServer)
{
conS.ConnectionFileName = GetStartupConnectionFileName();
}
connectionsSaver.ConnectionFileName = GetStartupConnectionFileName();
conS.ConnectionList = ConnectionList;
conS.ContainerList = ContainerList;
conS.Export = false;
conS.SaveSecurity = new Security.Save();
conS.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0];
connectionsSaver.Export = false;
connectionsSaver.SaveSecurity = new Security.Save();
connectionsSaver.ConnectionTreeModel = ConnectionTreeModel;
if (Settings.Default.UseSQLServer)
{
conS.SaveFormat = ConnectionsSaver.Format.SQL;
conS.SQLHost = Convert.ToString(Settings.Default.SQLHost);
conS.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName);
conS.SQLUsername = Convert.ToString(Settings.Default.SQLUser);
connectionsSaver.SaveFormat = ConnectionsSaver.Format.SQL;
connectionsSaver.SQLHost = Convert.ToString(Settings.Default.SQLHost);
connectionsSaver.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName);
connectionsSaver.SQLUsername = Convert.ToString(Settings.Default.SQLUser);
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
conS.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey);
connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey);
}
conS.SaveConnections();
connectionsSaver.SaveConnections();
if (Settings.Default.UseSQLServer)
{
LastSqlUpdate = DateTime.Now;
}
}
catch (Exception ex)
{
@@ -567,46 +483,39 @@ namespace mRemoteNG.App
}
finally
{
SQLConnProvider?.Enable();
RemoteConnectionsSyncronizer?.Enable();
}
}
public static void SaveConnectionsAs()
{
ConnectionsSaver connectionsSave = new ConnectionsSaver();
var connectionsSave = new ConnectionsSaver();
try
{
if (SQLConnProvider != null)
{
SQLConnProvider.Disable();
}
RemoteConnectionsSyncronizer?.Disable();
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
using (var saveFileDialog = new SaveFileDialog())
{
saveFileDialog.CheckPathExists = true;
saveFileDialog.InitialDirectory = ConnectionsFileInfo.DefaultConnectionsPath;
saveFileDialog.FileName = ConnectionsFileInfo.DefaultConnectionsFile;
saveFileDialog.OverwritePrompt = true;
List<string> fileTypes = new List<string>();
var fileTypes = new List<string>();
fileTypes.AddRange(new[] { Language.strFiltermRemoteXML, "*.xml" });
fileTypes.AddRange(new[] { Language.strFilterAll, "*.*" });
saveFileDialog.Filter = string.Join("|", fileTypes.ToArray());
if (saveFileDialog.ShowDialog(frmMain.Default) != DialogResult.OK)
{
return;
}
connectionsSave.SaveFormat = ConnectionsSaver.Format.mRXML;
connectionsSave.ConnectionFileName = saveFileDialog.FileName;
connectionsSave.Export = false;
connectionsSave.SaveSecurity = new Security.Save();
connectionsSave.ConnectionList = ConnectionList;
connectionsSave.ContainerList = ContainerList;
connectionsSave.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0];
connectionsSave.ConnectionTreeModel = ConnectionTreeModel;
connectionsSave.SaveConnections();
@@ -628,7 +537,7 @@ namespace mRemoteNG.App
}
finally
{
SQLConnProvider?.Enable();
RemoteConnectionsSyncronizer?.Enable();
}
}
#endregion
@@ -669,350 +578,14 @@ namespace mRemoteNG.App
return null;
}
}
public static void OpenConnection()
{
try
{
OpenConnection(ConnectionInfo.Force.None);
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo.Force Force)
{
try
{
if (Windows.treeForm.tvConnections.SelectedNode.Tag == null)
{
return;
}
if (ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.PuttySession)
{
OpenConnection((ConnectionInfo)Windows.treeForm.tvConnections.SelectedNode.Tag, Force);
}
else if (ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.Container)
{
foreach (TreeNode tNode in ConnectionTree.SelectedNode.Nodes)
{
if (ConnectionTreeNode.GetNodeType(tNode) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.PuttySession)
{
if (tNode.Tag != null)
{
OpenConnection((ConnectionInfo)tNode.Tag, Force);
}
}
}
}
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo ConnectionInfo)
{
try
{
OpenConnection(ConnectionInfo, ConnectionInfo.Force.None);
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo ConnectionInfo, Form ConnectionForm)
{
try
{
OpenConnectionFinal(ConnectionInfo, ConnectionInfo.Force.None, ConnectionForm);
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo ConnectionInfo, Form ConnectionForm, ConnectionInfo.Force Force)
{
try
{
OpenConnectionFinal(ConnectionInfo, Force, ConnectionForm);
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force)
{
try
{
OpenConnectionFinal(ConnectionInfo, Force, null);
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
private static void OpenConnectionFinal(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force, Form ConForm)
{
try
{
if (ConnectionInfo.Hostname == "" && ConnectionInfo.Protocol != ProtocolType.IntApp)
{
MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strConnectionOpenFailedNoHostname);
return;
}
StartPreConnectionExternalApp(ConnectionInfo);
if ((Force & ConnectionInfo.Force.DoNotJump) != ConnectionInfo.Force.DoNotJump)
{
if (SwitchToOpenConnection(ConnectionInfo))
{
return;
}
}
ProtocolFactory protocolFactory = new ProtocolFactory();
ProtocolBase newProtocol = protocolFactory.CreateProtocol(ConnectionInfo);
string connectionPanel = SetConnectionPanel(ConnectionInfo, Force);
Form connectionForm = SetConnectionForm(ConForm, connectionPanel);
Control connectionContainer = SetConnectionContainer(ConnectionInfo, connectionForm);
SetConnectionFormEventHandlers(newProtocol, connectionForm);
SetConnectionEventHandlers(newProtocol);
BuildConnectionInterfaceController(ConnectionInfo, newProtocol, connectionContainer);
newProtocol.Force = Force;
if (newProtocol.Initialize() == false)
{
newProtocol.Close();
return;
}
if (newProtocol.Connect() == false)
{
newProtocol.Close();
return;
}
ConnectionInfo.OpenConnections.Add(newProtocol);
SetTreeNodeImages(ConnectionInfo);
frmMain.Default.SelectedConnection = ConnectionInfo;
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
private static void BuildConnectionInterfaceController(ConnectionInfo ConnectionInfo, ProtocolBase newProtocol, Control connectionContainer)
{
newProtocol.InterfaceControl = new InterfaceControl(connectionContainer, newProtocol, ConnectionInfo);
}
private static void SetConnectionFormEventHandlers(ProtocolBase newProtocol, Form connectionForm)
{
newProtocol.Closed += ((ConnectionWindow)connectionForm).Prot_Event_Closed;
}
private static Control SetConnectionContainer(ConnectionInfo ConnectionInfo, Form connectionForm)
{
Control connectionContainer = ((ConnectionWindow)connectionForm).AddConnectionTab(ConnectionInfo);
if (ConnectionInfo.Protocol == ProtocolType.IntApp)
{
if (GetExtAppByName(ConnectionInfo.ExtApp).Icon != null)
((TabPage) connectionContainer).Icon = GetExtAppByName(ConnectionInfo.ExtApp).Icon;
}
return connectionContainer;
}
private static void SetTreeNodeImages(ConnectionInfo ConnectionInfo)
{
if (ConnectionInfo.IsQuickConnect == false)
{
if (ConnectionInfo.Protocol != ProtocolType.IntApp)
{
ConnectionTreeNode.SetNodeImage(ConnectionInfo.TreeNode, TreeImageType.ConnectionOpen);
}
else
{
ExternalTool extApp = GetExtAppByName(ConnectionInfo.ExtApp);
if (extApp != null)
{
if (extApp.TryIntegrate && ConnectionInfo.TreeNode != null)
{
ConnectionTreeNode.SetNodeImage(ConnectionInfo.TreeNode, TreeImageType.ConnectionOpen);
}
}
}
}
}
private static void SetConnectionEventHandlers(ProtocolBase newProtocol)
{
newProtocol.Disconnected += Prot_Event_Disconnected;
newProtocol.Connected += Prot_Event_Connected;
newProtocol.Closed += Prot_Event_Closed;
newProtocol.ErrorOccured += Prot_Event_ErrorOccured;
}
private static Form SetConnectionForm(Form ConForm, string connectionPanel)
{
var connectionForm = ConForm ?? WindowList.FromString(connectionPanel);
if (connectionForm == null)
connectionForm = AddPanel(connectionPanel);
else
((ConnectionWindow)connectionForm).Show(frmMain.Default.pnlDock);
connectionForm.Focus();
return connectionForm;
}
private static string SetConnectionPanel(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force)
{
string connectionPanel = "";
if (ConnectionInfo.Panel == "" || (Force & ConnectionInfo.Force.OverridePanel) == ConnectionInfo.Force.OverridePanel | Settings.Default.AlwaysShowPanelSelectionDlg)
{
frmChoosePanel frmPnl = new frmChoosePanel();
if (frmPnl.ShowDialog() == DialogResult.OK)
{
connectionPanel = frmPnl.Panel;
}
}
else
{
connectionPanel = ConnectionInfo.Panel;
}
return connectionPanel;
}
private static void StartPreConnectionExternalApp(ConnectionInfo ConnectionInfo)
{
if (ConnectionInfo.PreExtApp != "")
{
ExternalTool extA = GetExtAppByName(ConnectionInfo.PreExtApp);
extA?.Start(ConnectionInfo);
}
}
public static bool SwitchToOpenConnection(ConnectionInfo nCi)
{
InterfaceControl IC = FindConnectionContainer(nCi);
if (IC != null)
{
var connectionWindow = (ConnectionWindow)IC.FindForm();
connectionWindow?.Focus();
var findForm = (ConnectionWindow)IC.FindForm();
findForm?.Show(frmMain.Default.pnlDock);
TabPage tabPage = (TabPage)IC.Parent;
tabPage.Selected = true;
return true;
}
return false;
}
#endregion
#region Event Handlers
private static void Prot_Event_Disconnected(object sender, string DisconnectedMessage)
{
try
{
MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, DisconnectedMessage), true);
ProtocolBase Prot = (ProtocolBase)sender;
if (Prot.InterfaceControl.Info.Protocol == ProtocolType.RDP)
{
string ReasonCode = DisconnectedMessage.Split("\r\n".ToCharArray())[0];
string desc = DisconnectedMessage.Replace("\r\n", " ");
if (Convert.ToInt32(ReasonCode) > 3)
{
MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strRdpDisconnected + Environment.NewLine + desc);
}
}
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strProtocolEventDisconnectFailed, ex.Message), true);
}
}
private static void Prot_Event_Closed(object sender)
{
try
{
ProtocolBase Prot = (ProtocolBase)sender;
MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnenctionCloseEvent, true);
MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnenctionClosedByUser, Prot.InterfaceControl.Info.Hostname, Prot.InterfaceControl.Info.Protocol.ToString(), Environment.UserName));
Prot.InterfaceControl.Info.OpenConnections.Remove(Prot);
if (Prot.InterfaceControl.Info.OpenConnections.Count < 1 && Prot.InterfaceControl.Info.IsQuickConnect == false)
{
ConnectionTreeNode.SetNodeImage(Prot.InterfaceControl.Info.TreeNode, TreeImageType.ConnectionClosed);
}
if (Prot.InterfaceControl.Info.PostExtApp != "")
{
ExternalTool extA = GetExtAppByName(Prot.InterfaceControl.Info.PostExtApp);
extA?.Start(Prot.InterfaceControl.Info);
}
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnenctionCloseEventFailed + Environment.NewLine + ex.Message, true);
}
}
private static void Prot_Event_Connected(object sender)
{
ProtocolBase prot = (ProtocolBase)sender;
MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventConnected, true);
MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol.ToString(), Environment.UserName, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField));
}
private static void Prot_Event_ErrorOccured(object sender, string ErrorMessage)
{
try
{
MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventErrorOccured, true);
ProtocolBase Prot = (ProtocolBase)sender;
if (Prot.InterfaceControl.Info.Protocol == ProtocolType.RDP)
{
if (Convert.ToInt32(ErrorMessage) > -1)
{
MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, ErrorMessage, ProtocolRDP.FatalErrors.GetError(ErrorMessage)));
}
}
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionEventConnectionFailed + Environment.NewLine + ex.Message, true);
}
}
#endregion
#region External Apps
public static ExternalTool GetExtAppByName(string Name)
public static ExternalTool GetExtAppByName(string name)
{
foreach (ExternalTool extA in ExternalTools)
{
if (extA.DisplayName == Name)
if (extA.DisplayName == name)
return extA;
}
return null;
@@ -1020,129 +593,45 @@ namespace mRemoteNG.App
#endregion
#region Misc
private static void GoToURL(string URL)
private static void GoToUrl(string url)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
var connectionInfo = new ConnectionInfo();
connectionInfo.CopyFrom(DefaultConnectionInfo.Instance);
connectionInfo.Name = "";
connectionInfo.Hostname = URL;
if (URL.StartsWith("https:"))
{
connectionInfo.Protocol = ProtocolType.HTTPS;
}
else
{
connectionInfo.Protocol = ProtocolType.HTTP;
}
connectionInfo.Hostname = url;
connectionInfo.Protocol = url.StartsWith("https:") ? ProtocolType.HTTPS : ProtocolType.HTTP;
connectionInfo.SetDefaultPort();
connectionInfo.IsQuickConnect = true;
OpenConnection(connectionInfo, ConnectionInfo.Force.DoNotJump);
ConnectionInitiator.OpenConnection(connectionInfo, ConnectionInfo.Force.DoNotJump);
}
public static void GoToWebsite()
{
GoToURL(GeneralAppInfo.UrlHome);
GoToUrl(GeneralAppInfo.UrlHome);
}
public static void GoToDonate()
{
GoToURL(GeneralAppInfo.UrlDonate);
GoToUrl(GeneralAppInfo.UrlDonate);
}
public static void GoToForum()
{
GoToURL(GeneralAppInfo.UrlForum);
GoToUrl(GeneralAppInfo.UrlForum);
}
public static void GoToBugs()
{
GoToURL(GeneralAppInfo.UrlBugs);
}
public static void Report(string Text)
{
try
{
StreamWriter sWr = new StreamWriter(SettingsFileInfo.exePath + "\\Report.log", true);
sWr.WriteLine(Text);
sWr.Close();
}
catch (Exception)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strLogWriteToFileFailed);
}
}
public static bool SaveReport()
{
StreamReader streamReader = null;
StreamWriter streamWriter = null;
try
{
streamReader = new StreamReader(SettingsFileInfo.exePath + "\\Report.log");
string text = streamReader.ReadToEnd();
streamReader.Close();
streamWriter = new StreamWriter(GeneralAppInfo.ReportingFilePath, true);
streamWriter.Write(text);
return true;
}
catch (Exception ex)
{
MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strLogWriteToFileFinalLocationFailed + Environment.NewLine + ex.Message, true);
return false;
}
finally
{
if (streamReader != null)
{
streamReader.Close();
streamReader.Dispose();
}
if (streamWriter != null)
{
streamWriter.Close();
streamWriter.Dispose();
}
}
}
private static InterfaceControl FindConnectionContainer(ConnectionInfo connectionInfo)
{
if (connectionInfo.OpenConnections.Count > 0)
{
for (int i = 0; i <= WindowList.Count - 1; i++)
{
if (WindowList[i] is ConnectionWindow)
{
ConnectionWindow connectionWindow = (ConnectionWindow)WindowList[i];
if (connectionWindow.TabController != null)
{
foreach (TabPage t in connectionWindow.TabController.TabPages)
{
if (t.Controls[0] != null && t.Controls[0] is InterfaceControl)
{
InterfaceControl IC = (InterfaceControl)t.Controls[0];
if (IC.Info == connectionInfo)
{
return IC;
}
}
}
}
}
}
}
return null;
GoToUrl(GeneralAppInfo.UrlBugs);
}
// Override the font of all controls in a container with the default font based on the OS version
public static void FontOverride(Control ctlParent)
{
foreach (Control tempLoopVar_ctlChild in ctlParent.Controls)
foreach (Control tempLoopVarCtlChild in ctlParent.Controls)
{
var ctlChild = tempLoopVar_ctlChild;
var ctlChild = tempLoopVarCtlChild;
ctlChild.Font = new Font(SystemFonts.MessageBoxFont.Name, ctlChild.Font.Size, ctlChild.Font.Style, ctlChild.Font.Unit, ctlChild.Font.GdiCharSet);
if (ctlChild.Controls.Count > 0)
{

View File

@@ -1,6 +1,7 @@
using mRemoteNG.Tools;
using System;
using System.Diagnostics;
using mRemoteNG.Config.Putty;
using mRemoteNG.UI.Forms;
namespace mRemoteNG.App
@@ -36,7 +37,7 @@ namespace mRemoteNG.App
private static void StopPuttySessionWatcher()
{
Config.Putty.Sessions.StopWatcher();
PuttySessionsManager.Instance.StopWatcher();
}
private static void DisposeNotificationAreaIcon()
@@ -47,7 +48,7 @@ namespace mRemoteNG.App
private static void SaveConnections()
{
if (mRemoteNG.Settings.Default.SaveConsOnExit)
if (Settings.Default.SaveConsOnExit)
Runtime.SaveConnections();
}

View File

@@ -52,7 +52,6 @@ namespace mRemoteNG.App
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, (a)=>"InhDefault"+a);
}
public void SetDefaultLayout()
{
frmMain.Default.pnlDock.Visible = false;
@@ -62,11 +61,11 @@ namespace mRemoteNG.App
frmMain.Default.pnlDock.DockTopPortion = frmMain.Default.pnlDock.Height * 0.25;
frmMain.Default.pnlDock.DockBottomPortion = frmMain.Default.pnlDock.Height * 0.25;
Windows.treePanel.Show(frmMain.Default.pnlDock, DockState.DockLeft);
Windows.configPanel.Show(frmMain.Default.pnlDock);
Windows.configPanel.DockTo(Windows.treePanel.Pane, DockStyle.Bottom, -1);
Windows.TreePanel.Show(frmMain.Default.pnlDock, DockState.DockLeft);
Windows.ConfigPanel.Show(frmMain.Default.pnlDock);
Windows.ConfigPanel.DockTo(Windows.TreePanel.Pane, DockStyle.Bottom, -1);
Windows.screenshotForm.Hide();
Windows.ScreenshotForm.Hide();
frmMain.Default.pnlDock.Visible = true;
}
@@ -87,17 +86,14 @@ namespace mRemoteNG.App
}
}
private void LogStartupData()
{
if (Settings.Default.WriteLogFile)
{
LogApplicationData();
LogCmdLineArgs();
LogSystemData();
LogCLRData();
LogCultureData();
}
if (!Settings.Default.WriteLogFile) return;
LogApplicationData();
LogCmdLineArgs();
LogSystemData();
LogCLRData();
LogCultureData();
}
private void LogSystemData()
@@ -184,13 +180,13 @@ namespace mRemoteNG.App
$"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}");
}
public void CreateConnectionsProvider()
{
if (Settings.Default.UseSQLServer)
{
SqlConnectionsProvider _sqlConnectionsProvider = new SqlConnectionsProvider();
}
frmMain.Default.AreWeUsingSqlServerForSavingConnections = Settings.Default.UseSQLServer;
if (!Settings.Default.UseSQLServer) return;
Runtime.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
Runtime.RemoteConnectionsSyncronizer.Enable();
}
private void CheckForUpdate()
@@ -246,7 +242,6 @@ namespace mRemoteNG.App
}
}
private void CheckForAnnouncement()
{
if (_appUpdate == null)
@@ -290,7 +285,6 @@ namespace mRemoteNG.App
}
}
private void ParseCommandLineArgs()
{
try

View File

@@ -7,58 +7,58 @@ namespace mRemoteNG.App
{
public static class Windows
{
public static ConnectionTreeWindow treeForm;
public static DockContent treePanel = new DockContent();
public static ConfigWindow configForm;
public static DockContent configPanel = new DockContent();
public static ErrorAndInfoWindow errorsForm;
public static DockContent errorsPanel = new DockContent();
public static ScreenshotManagerWindow screenshotForm;
public static DockContent screenshotPanel = new DockContent();
public static ExportForm exportForm;
public static DockContent exportPanel = new DockContent();
private static AboutWindow aboutForm;
private static DockContent aboutPanel = new DockContent();
public static UpdateWindow updateForm;
public static DockContent updatePanel = new DockContent();
public static SSHTransferWindow sshtransferForm;
private static DockContent sshtransferPanel = new DockContent();
private static ActiveDirectoryImportWindow adimportForm;
private static DockContent adimportPanel = new DockContent();
private static HelpWindow helpForm;
private static DockContent helpPanel = new DockContent();
private static ExternalToolsWindow externalappsForm;
private static DockContent externalappsPanel = new DockContent();
private static PortScanWindow portscanForm;
private static DockContent portscanPanel = new DockContent();
private static UltraVNCWindow ultravncscForm;
private static DockContent ultravncscPanel = new DockContent();
private static ComponentsCheckWindow componentscheckForm;
private static DockContent componentscheckPanel = new DockContent();
public static AnnouncementWindow AnnouncementForm;
public static DockContent AnnouncementPanel = new DockContent();
private static AboutWindow _aboutForm;
private static DockContent _aboutPanel = new DockContent();
private static DockContent _sshtransferPanel = new DockContent();
private static ActiveDirectoryImportWindow _adimportForm;
private static DockContent _adimportPanel = new DockContent();
private static HelpWindow _helpForm;
private static DockContent _helpPanel = new DockContent();
private static ExternalToolsWindow _externalappsForm;
private static DockContent _externalappsPanel = new DockContent();
private static PortScanWindow _portscanForm;
private static DockContent _portscanPanel = new DockContent();
private static UltraVNCWindow _ultravncscForm;
private static DockContent _ultravncscPanel = new DockContent();
private static ComponentsCheckWindow _componentscheckForm;
private static DockContent _componentscheckPanel = new DockContent();
public static ConnectionTreeWindow TreeForm { get; set; }
public static DockContent TreePanel { get; set; } = new DockContent();
public static ConfigWindow ConfigForm { get; set; }
public static DockContent ConfigPanel { get; set; } = new DockContent();
public static ErrorAndInfoWindow ErrorsForm { get; set; }
public static DockContent ErrorsPanel { get; set; } = new DockContent();
public static ScreenshotManagerWindow ScreenshotForm { get; set; }
public static DockContent ScreenshotPanel { get; set; } = new DockContent();
public static AnnouncementWindow AnnouncementForm { get; set; }
public static DockContent AnnouncementPanel { get; set; } = new DockContent();
public static UpdateWindow UpdateForm { get; set; }
public static DockContent UpdatePanel { get; set; } = new DockContent();
public static SSHTransferWindow SshtransferForm { get; set; }
public static void Show(WindowType windowType)
{
try
{
if (windowType.Equals(WindowType.About))
{
if (aboutForm == null || aboutForm.IsDisposed)
if (_aboutForm == null || _aboutForm.IsDisposed)
{
aboutForm = new AboutWindow(aboutPanel);
aboutPanel = aboutForm;
_aboutForm = new AboutWindow(_aboutPanel);
_aboutPanel = _aboutForm;
}
aboutForm.Show(frmMain.Default.pnlDock);
_aboutForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.ActiveDirectoryImport))
{
if (adimportForm == null || adimportForm.IsDisposed)
if (_adimportForm == null || _adimportForm.IsDisposed)
{
adimportForm = new ActiveDirectoryImportWindow(adimportPanel);
adimportPanel = adimportForm;
_adimportForm = new ActiveDirectoryImportWindow(_adimportPanel);
_adimportPanel = _adimportForm;
}
adimportPanel.Show(frmMain.Default.pnlDock);
_adimportPanel.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.Options))
{
@@ -69,60 +69,60 @@ namespace mRemoteNG.App
}
else if (windowType.Equals(WindowType.SSHTransfer))
{
sshtransferForm = new SSHTransferWindow(sshtransferPanel);
sshtransferPanel = sshtransferForm;
sshtransferForm.Show(frmMain.Default.pnlDock);
SshtransferForm = new SSHTransferWindow(_sshtransferPanel);
_sshtransferPanel = SshtransferForm;
SshtransferForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.Update))
{
if (updateForm == null || updateForm.IsDisposed)
if (UpdateForm == null || UpdateForm.IsDisposed)
{
updateForm = new UpdateWindow(updatePanel);
updatePanel = updateForm;
UpdateForm = new UpdateWindow(UpdatePanel);
UpdatePanel = UpdateForm;
}
updateForm.Show(frmMain.Default.pnlDock);
UpdateForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.Help))
{
if (helpForm == null || helpForm.IsDisposed)
if (_helpForm == null || _helpForm.IsDisposed)
{
helpForm = new HelpWindow(helpPanel);
helpPanel = helpForm;
_helpForm = new HelpWindow(_helpPanel);
_helpPanel = _helpForm;
}
helpForm.Show(frmMain.Default.pnlDock);
_helpForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.ExternalApps))
{
if (externalappsForm == null || externalappsForm.IsDisposed)
if (_externalappsForm == null || _externalappsForm.IsDisposed)
{
externalappsForm = new ExternalToolsWindow(externalappsPanel);
externalappsPanel = externalappsForm;
_externalappsForm = new ExternalToolsWindow(_externalappsPanel);
_externalappsPanel = _externalappsForm;
}
externalappsForm.Show(frmMain.Default.pnlDock);
_externalappsForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.PortScan))
{
portscanForm = new PortScanWindow(portscanPanel);
portscanPanel = portscanForm;
portscanForm.Show(frmMain.Default.pnlDock);
_portscanForm = new PortScanWindow(_portscanPanel);
_portscanPanel = _portscanForm;
_portscanForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.UltraVNCSC))
{
if (ultravncscForm == null || ultravncscForm.IsDisposed)
if (_ultravncscForm == null || _ultravncscForm.IsDisposed)
{
ultravncscForm = new UltraVNCWindow(ultravncscPanel);
ultravncscPanel = ultravncscForm;
_ultravncscForm = new UltraVNCWindow(_ultravncscPanel);
_ultravncscPanel = _ultravncscForm;
}
ultravncscForm.Show(frmMain.Default.pnlDock);
_ultravncscForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.ComponentsCheck))
{
if (componentscheckForm == null || componentscheckForm.IsDisposed)
if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
{
componentscheckForm = new ComponentsCheckWindow(componentscheckPanel);
componentscheckPanel = componentscheckForm;
_componentscheckForm = new ComponentsCheckWindow(_componentscheckPanel);
_componentscheckPanel = _componentscheckForm;
}
componentscheckForm.Show(frmMain.Default.pnlDock);
_componentscheckForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.Announcement))
{

View File

@@ -0,0 +1,96 @@
using System;
using System.Security;
using mRemoteNG.App;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Connections
{
public class ConnectionsDecryptor
{
private readonly ICryptographyProvider _cryptographyProvider;
public ConnectionsDecryptor()
{
_cryptographyProvider = new LegacyRijndaelCryptographyProvider();
}
public string DecryptConnections(string xml)
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
if (string.IsNullOrEmpty(xml)) return "";
if (xml.Contains("<?xml version=\"1.0\" encoding=\"utf-8\"?>")) return xml;
var strDecr = "";
bool notDecr;
try
{
strDecr = cryptographyProvider.Decrypt(xml, Runtime.EncryptionKey);
notDecr = strDecr == xml;
}
catch (Exception)
{
notDecr = true;
}
if (notDecr)
{
if (Authenticate(xml, true))
{
strDecr = cryptographyProvider.Decrypt(xml, Runtime.EncryptionKey);
notDecr = false;
}
if (notDecr == false)
return strDecr;
}
else
{
return strDecr;
}
return "";
}
public bool ConnectionsFileIsAuthentic(string protectedString, RootNodeInfo rootInfo)
{
var connectionsFileIsNotEncrypted = _cryptographyProvider.Decrypt(protectedString, Runtime.EncryptionKey) == "ThisIsNotProtected";
return connectionsFileIsNotEncrypted || Authenticate(protectedString, false, rootInfo);
}
private bool Authenticate(string value, bool compareToOriginalValue, RootNodeInfo rootInfo = null)
{
var passwordName = "";
//passwordName = Path.GetFileName(ConnectionFileName);
if (compareToOriginalValue)
{
while (_cryptographyProvider.Decrypt(value, Runtime.EncryptionKey) == value)
{
Runtime.EncryptionKey = Tools.MiscTools.PasswordDialog(passwordName, false);
if (Runtime.EncryptionKey.Length == 0)
return false;
}
}
else
{
while (_cryptographyProvider.Decrypt(value, Runtime.EncryptionKey) != "ThisIsProtected")
{
Runtime.EncryptionKey = Tools.MiscTools.PasswordDialog(passwordName, false);
if (Runtime.EncryptionKey.Length == 0)
return false;
}
if (rootInfo == null) return true;
rootInfo.Password = true;
rootInfo.PasswordString = Runtime.EncryptionKey.ConvertToUnsecureString();
}
return true;
}
}
}

View File

@@ -1,6 +1,8 @@
using System.Windows.Forms;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Config.DatabaseConnectors;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Putty;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Tree;
using mRemoteNG.UI.Forms;
@@ -9,57 +11,38 @@ namespace mRemoteNG.Config.Connections
public class ConnectionsLoader
{
public bool UseDatabase { get; set; }
public string DatabaseHost { get; set; }
public string DatabaseName { get; set; }
public string DatabaseUsername { get; set; }
public string DatabasePassword { get; set; }
public bool DatabaseUpdate { get; set; }
public string PreviousSelected { get; set; }
public string ConnectionFileName { get; set; }
public TreeNode RootTreeNode { get; set; }
public ConnectionList ConnectionList { get; set; }
public ContainerList ContainerList { get; set; }
public ConnectionList PreviousConnectionList { get; set; }
public ContainerList PreviousContainerList { get; set; }
public void LoadConnections(bool import)
public ConnectionTreeModel LoadConnections(bool import)
{
IDeserializer deserializer;
if (UseDatabase)
{
var sqlConnectionsLoader = new SqlConnectionsLoader()
{
ConnectionList = ConnectionList,
ContainerList = ContainerList,
PreviousConnectionList = PreviousConnectionList,
PreviousContainerList = PreviousContainerList,
PreviousSelected = PreviousSelected,
RootTreeNode = RootTreeNode,
DatabaseName = DatabaseName,
DatabaseHost = DatabaseHost,
DatabasePassword = DatabasePassword,
DatabaseUpdate = DatabaseUpdate,
DatabaseUsername = DatabaseUsername
};
sqlConnectionsLoader.LoadFromSql();
var connector = new SqlDatabaseConnector();
var dataProvider = new SqlDataProvider(connector);
var dataTable = dataProvider.Load();
deserializer = new DataTableDeserializer(dataTable);
}
else
{
var xmlConnectionsLoader = new XmlConnectionsLoader()
{
ConnectionFileName = ConnectionFileName,
ConnectionList = ConnectionList,
ContainerList = ContainerList,
RootTreeNode = RootTreeNode,
};
xmlConnectionsLoader.LoadFromXml(import);
var dataProvider = new FileDataProvider(ConnectionFileName);
var xmlString = dataProvider.Load();
deserializer = new XmlConnectionsDeserializer(xmlString);
}
frmMain.Default.AreWeUsingSqlServerForSavingConnections = UseDatabase;
frmMain.Default.ConnectionsFileName = ConnectionFileName;
if (!import)
Putty.Sessions.AddSessionsToTree();
var connectionTreeModel = deserializer.Deserialize();
if (connectionTreeModel != null)
frmMain.Default.ConnectionsFileName = ConnectionFileName;
else
connectionTreeModel = new ConnectionTreeModel();
if (import) return connectionTreeModel;
PuttySessionsManager.Instance.AddSessions();
connectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes);
return connectionTreeModel;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
using System;
using mRemoteNG.Config.DatabaseConnectors;
namespace mRemoteNG.Config.Connections
{
public delegate void ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
public class ConnectionsUpdateAvailableEventArgs : EventArgs
{
public IDatabaseConnector DatabaseConnector { get; private set; }
public DateTime UpdateTime { get; private set; }
public bool Handled { get; set; }
public ConnectionsUpdateAvailableEventArgs(IDatabaseConnector databaseConnector, DateTime updateTime)
{
DatabaseConnector = databaseConnector;
UpdateTime = updateTime;
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace mRemoteNG.Config.Connections
{
public delegate void UpdateCheckFinishedEventHandler(object sender, ConnectionsUpdateCheckFinishedEventArgs args);
public class ConnectionsUpdateCheckFinishedEventArgs : EventArgs
{
public bool UpdateAvailable { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace mRemoteNG.Config.Connections
{
public interface IConnectionsUpdateChecker : IDisposable
{
bool IsUpdateAvailable();
void IsUpdateAvailableAsync();
event EventHandler UpdateCheckStarted;
event UpdateCheckFinishedEventHandler UpdateCheckFinished;
event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
}
}

View File

@@ -0,0 +1,89 @@
using System;
using System.Timers;
using mRemoteNG.App;
namespace mRemoteNG.Config.Connections
{
public class RemoteConnectionsSyncronizer : IConnectionsUpdateChecker
{
private readonly Timer _updateTimer;
private readonly IConnectionsUpdateChecker _updateChecker;
private readonly ConnectionsLoader _connectionsLoader;
private readonly ConnectionsSaver _connectionsSaver;
public double TimerIntervalInMilliseconds => _updateTimer.Interval;
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker)
{
_updateChecker = updateChecker;
_updateTimer = new Timer(3000);
_connectionsLoader = new ConnectionsLoader { UseDatabase = mRemoteNG.Settings.Default.UseSQLServer };
_connectionsSaver = new ConnectionsSaver { SaveFormat = ConnectionsSaver.Format.SQL };
SetEventListeners();
}
private void SetEventListeners()
{
_updateChecker.UpdateCheckStarted += OnUpdateCheckStarted;
_updateChecker.UpdateCheckFinished += OnUpdateCheckFinished;
_updateChecker.ConnectionsUpdateAvailable += (sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
_updateTimer.Elapsed += (sender, args) => _updateChecker.IsUpdateAvailableAsync();
ConnectionsUpdateAvailable += Load;
}
public void Load()
{
Runtime.ConnectionTreeModel = _connectionsLoader.LoadConnections(false);
}
private void Load(object sender, ConnectionsUpdateAvailableEventArgs args)
{
Load();
args.Handled = true;
}
public void Save()
{
_connectionsSaver.SaveConnections();
}
public void Enable() => _updateTimer.Start();
public void Disable() => _updateTimer.Stop();
public bool IsUpdateAvailable() => _updateChecker.IsUpdateAvailable();
public void IsUpdateAvailableAsync() => _updateChecker.IsUpdateAvailableAsync();
private void OnUpdateCheckStarted(object sender, EventArgs eventArgs)
{
_updateTimer.Stop();
UpdateCheckStarted?.Invoke(sender, eventArgs);
}
private void OnUpdateCheckFinished(object sender, ConnectionsUpdateCheckFinishedEventArgs eventArgs)
{
_updateTimer.Start();
UpdateCheckFinished?.Invoke(sender, eventArgs);
}
public event EventHandler UpdateCheckStarted;
public event UpdateCheckFinishedEventHandler UpdateCheckFinished;
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
~RemoteConnectionsSyncronizer()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
{
if (!itIsSafeToAlsoFreeManagedObjects) return;
_updateTimer.Dispose();
_updateChecker.Dispose();
}
}
}

View File

@@ -0,0 +1,122 @@
using mRemoteNG.App;
using mRemoteNG.Messages;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using mRemoteNG.Config.DatabaseConnectors;
namespace mRemoteNG.Config.Connections
{
public class SqlConnectionsUpdateChecker : IConnectionsUpdateChecker
{
private readonly SqlDatabaseConnector _sqlConnector;
private readonly SqlCommand _sqlQuery;
private DateTime _lastUpdateTime;
private DateTime _lastDatabaseUpdateTime;
public SqlConnectionsUpdateChecker()
{
_sqlConnector = new SqlDatabaseConnector();
_sqlQuery = new SqlCommand("SELECT * FROM tblUpdate", _sqlConnector.SqlConnection);
_lastUpdateTime = default(DateTime);
_lastDatabaseUpdateTime = default(DateTime);
}
public bool IsUpdateAvailable()
{
RaiseUpdateCheckStartedEvent();
ConnectToSqlDb();
var updateIsAvailable = DatabaseIsMoreUpToDateThanUs();
if (updateIsAvailable)
RaiseConnectionsUpdateAvailableEvent();
RaiseUpdateCheckFinishedEvent(updateIsAvailable);
return updateIsAvailable;
}
public void IsUpdateAvailableAsync()
{
var thread = new Thread(() => IsUpdateAvailable());
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private void ConnectToSqlDb()
{
try
{
_sqlConnector.Connect();
}
catch(Exception e)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Unable to connect to Sql DB to check for updates." + Environment.NewLine + e.Message, true);
}
}
private bool DatabaseIsMoreUpToDateThanUs()
{
return GetLastUpdateTimeFromDbResponse() > _lastUpdateTime;
}
private DateTime GetLastUpdateTimeFromDbResponse()
{
var lastUpdateInDb = default(DateTime);
try
{
var sqlReader = _sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
sqlReader.Read();
if (sqlReader.HasRows)
lastUpdateInDb = Convert.ToDateTime(sqlReader["LastUpdate"]);
sqlReader.Close();
}
catch (Exception ex)
{
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};
UpdateCheckFinished?.Invoke(this, args);
}
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
private void RaiseConnectionsUpdateAvailableEvent()
{
var args = new ConnectionsUpdateAvailableEventArgs(_sqlConnector, _lastDatabaseUpdateTime);
ConnectionsUpdateAvailable?.Invoke(this, args);
if(args.Handled)
_lastUpdateTime = _lastDatabaseUpdateTime;
}
~SqlConnectionsUpdateChecker()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool itIsSafeToDisposeManagedObjects)
{
if (!itIsSafeToDisposeManagedObjects) return;
_sqlConnector.Disconnect();
_sqlConnector.Dispose();
}
}
}

View File

@@ -1,72 +0,0 @@
using mRemoteNG.App;
using mRemoteNG.Messages;
using System;
namespace mRemoteNG.Config.Connections
{
public class SqlConnectionsProvider : IDisposable
{
SqlUpdateTimer _updateTimer;
SqlConnectionsUpdateChecker _sqlUpdateChecker;
public SqlConnectionsProvider()
{
_updateTimer = new SqlUpdateTimer();
_sqlUpdateChecker = new SqlConnectionsUpdateChecker();
SqlUpdateTimer.SqlUpdateTimerElapsed += SqlUpdateTimer_SqlUpdateTimerElapsed;
SqlConnectionsUpdateChecker.SQLUpdateCheckFinished += SQLUpdateCheckFinished;
}
~SqlConnectionsProvider()
{
Dispose(false);
}
public void Enable()
{
_updateTimer.Enable();
}
public void Disable()
{
_updateTimer.Disable();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
{
if (itIsSafeToAlsoFreeManagedObjects)
{
DestroySQLUpdateHandlers();
_updateTimer.Dispose();
_sqlUpdateChecker.Dispose();
}
}
private void DestroySQLUpdateHandlers()
{
SqlUpdateTimer.SqlUpdateTimerElapsed -= SqlUpdateTimer_SqlUpdateTimerElapsed;
SqlConnectionsUpdateChecker.SQLUpdateCheckFinished -= SQLUpdateCheckFinished;
}
private void SqlUpdateTimer_SqlUpdateTimerElapsed()
{
_sqlUpdateChecker.IsDatabaseUpdateAvailableAsync();
}
private void SQLUpdateCheckFinished(bool UpdateIsAvailable)
{
if (UpdateIsAvailable)
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strSqlUpdateCheckUpdateAvailable, true);
Runtime.LoadConnectionsBG();
}
}
}
}

View File

@@ -1,9 +0,0 @@
using System.Data.SqlClient;
namespace mRemoteNG.Config.Connections
{
public interface SqlCommandBuilder
{
SqlCommand BuildCommand();
}
}

View File

@@ -1,510 +0,0 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Security;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.TaskDialog;
namespace mRemoteNG.Config.Connections
{
public class SqlConnectionsLoader
{
private SqlConnection _sqlConnection;
private SqlCommand _sqlQuery;
private SqlDataReader _sqlDataReader;
private TreeNode _selectedTreeNode;
private double _confVersion;
private SecureString _pW = GeneralAppInfo.EncryptionKey;
public string DatabaseHost { get; set; }
public string DatabaseName { get; set; }
public string DatabaseUsername { get; set; }
public string DatabasePassword { get; set; }
public bool DatabaseUpdate { get; set; }
public string PreviousSelected { get; set; }
public TreeNode RootTreeNode { get; set; }
public ConnectionList ConnectionList { get; set; }
public ContainerList ContainerList { get; set; }
public ConnectionList PreviousConnectionList { get; set; }
public ContainerList PreviousContainerList { get; set; }
private delegate void LoadFromSqlDelegate();
public void LoadFromSql()
{
if (Windows.treeForm == null || Windows.treeForm.tvConnections == null)
return;
if (Windows.treeForm.tvConnections.InvokeRequired)
{
Windows.treeForm.tvConnections.Invoke(new LoadFromSqlDelegate(LoadFromSql));
return;
}
try
{
Runtime.IsConnectionsFileLoaded = false;
_sqlConnection = !string.IsNullOrEmpty(DatabaseUsername) ? new SqlConnection("Data Source=" + DatabaseHost + ";Initial Catalog=" + DatabaseName + ";User Id=" + DatabaseUsername + ";Password=" + DatabasePassword) : new SqlConnection("Data Source=" + DatabaseHost + ";Initial Catalog=" + DatabaseName + ";Integrated Security=True");
_sqlConnection.Open();
_sqlQuery = new SqlCommand("SELECT * FROM tblRoot", _sqlConnection);
_sqlDataReader = _sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
_sqlDataReader.Read();
if (_sqlDataReader.HasRows == false)
{
Runtime.SaveConnections();
_sqlQuery = new SqlCommand("SELECT * FROM tblRoot", _sqlConnection);
_sqlDataReader = _sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
_sqlDataReader.Read();
}
_confVersion = Convert.ToDouble(_sqlDataReader["confVersion"], CultureInfo.InvariantCulture);
const double maxSupportedSchemaVersion = 2.5;
if (_confVersion > maxSupportedSchemaVersion)
{
CTaskDialog.ShowTaskDialogBox(
frmMain.Default,
Application.ProductName,
"Incompatible database schema",
$"The database schema on the server is not supported. Please upgrade to a newer version of {Application.ProductName}.",
string.Format("Schema Version: {1}{0}Highest Supported Version: {2}", Environment.NewLine, _confVersion, maxSupportedSchemaVersion),
"",
"",
"",
"",
ETaskDialogButtons.Ok,
ESysIcons.Error,
ESysIcons.Error
);
throw (new Exception($"Incompatible database schema (schema version {_confVersion})."));
}
RootTreeNode.Name = Convert.ToString(_sqlDataReader["Name"]);
var rootInfo = new RootNodeInfo(RootNodeType.Connection)
{
Name = RootTreeNode.Name,
TreeNode = RootTreeNode
};
RootTreeNode.Tag = rootInfo;
RootTreeNode.ImageIndex = (int)TreeImageType.Root;
RootTreeNode.SelectedImageIndex = (int)TreeImageType.Root;
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
if (cryptographyProvider.Decrypt(Convert.ToString(_sqlDataReader["Protected"]), _pW) != "ThisIsNotProtected")
{
if (Authenticate(Convert.ToString(_sqlDataReader["Protected"]), false, rootInfo) == false)
{
mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
mRemoteNG.Settings.Default.CustomConsPath = "";
RootTreeNode.Remove();
return;
}
}
_sqlDataReader.Close();
Windows.treeForm.tvConnections.BeginUpdate();
// SECTION 3. Populate the TreeView with the DOM nodes.
AddNodesFromSql(RootTreeNode);
RootTreeNode.Expand();
//expand containers
foreach (ContainerInfo contI in ContainerList)
{
if (contI.IsExpanded)
contI.TreeNode.Expand();
}
Windows.treeForm.tvConnections.EndUpdate();
//open connections from last mremote session
if (mRemoteNG.Settings.Default.OpenConsFromLastSession && !mRemoteNG.Settings.Default.NoReconnect)
{
foreach (ConnectionInfo conI in ConnectionList)
{
if (conI.PleaseConnect)
Runtime.OpenConnection(conI);
}
}
Runtime.IsConnectionsFileLoaded = true;
Windows.treeForm.InitialRefresh();
SetSelectedNode(_selectedTreeNode);
}
finally
{
_sqlConnection?.Close();
}
}
private void AddNodesFromSql(TreeNode baseNode)
{
try
{
_sqlConnection.Open();
_sqlQuery = new SqlCommand("SELECT * FROM tblCons ORDER BY PositionID ASC", _sqlConnection);
_sqlDataReader = _sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
if (_sqlDataReader.HasRows == false)
return;
while (_sqlDataReader.Read())
{
var tNode = new TreeNode(Convert.ToString(_sqlDataReader["Name"]));
var nodeType = ConnectionTreeNode.GetNodeTypeFromString(Convert.ToString(_sqlDataReader["Type"]));
if (nodeType == TreeNodeType.Connection)
AddConnectionToList(tNode);
else if (nodeType == TreeNodeType.Container)
AddContainerToList(tNode);
var parentId = Convert.ToString(_sqlDataReader["ParentID"].ToString().Trim());
if (string.IsNullOrEmpty(parentId) || parentId == "0")
{
baseNode.Nodes.Add(tNode);
}
else
{
var pNode = ConnectionTreeNode.GetNodeFromConstantID(Convert.ToString(_sqlDataReader["ParentID"]));
if (pNode != null)
{
pNode.Nodes.Add(tNode);
switch (ConnectionTreeNode.GetNodeType(tNode))
{
case TreeNodeType.Connection:
((ConnectionInfo) tNode.Tag).Parent = (ContainerInfo)pNode.Tag;
break;
case TreeNodeType.Container:
((ContainerInfo) tNode.Tag).Parent = (ContainerInfo)pNode.Tag;
break;
}
}
else
{
baseNode.Nodes.Add(tNode);
}
}
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strAddNodesFromSqlFailed + Environment.NewLine + ex.Message, true);
}
}
private void AddConnectionToList(TreeNode tNode)
{
var conI = GetConnectionInfoFromSql();
conI.TreeNode = tNode;
ConnectionList.Add(conI);
tNode.Tag = conI;
if (DatabaseUpdate)
{
var prevCon = PreviousConnectionList.FindByConstantID(conI.ConstantID);
if (prevCon != null)
{
foreach (ProtocolBase prot in prevCon.OpenConnections)
{
prot.InterfaceControl.Info = conI;
conI.OpenConnections.Add(prot);
}
if (conI.OpenConnections.Count > 0)
{
tNode.ImageIndex = (int) TreeImageType.ConnectionOpen;
tNode.SelectedImageIndex = (int) TreeImageType.ConnectionOpen;
}
else
{
tNode.ImageIndex = (int) TreeImageType.ConnectionClosed;
tNode.SelectedImageIndex = (int) TreeImageType.ConnectionClosed;
}
}
else
{
tNode.ImageIndex = (int) TreeImageType.ConnectionClosed;
tNode.SelectedImageIndex = (int) TreeImageType.ConnectionClosed;
}
if (conI.ConstantID == PreviousSelected)
_selectedTreeNode = tNode;
}
else
{
tNode.ImageIndex = (int) TreeImageType.ConnectionClosed;
tNode.SelectedImageIndex = (int) TreeImageType.ConnectionClosed;
}
}
private void AddContainerToList(TreeNode tNode)
{
var contI = new ContainerInfo
{
TreeNode = tNode,
Name = Convert.ToString(_sqlDataReader["Name"])
};
var conI = GetConnectionInfoFromSql();
conI.Parent = contI;
conI.IsContainer = true;
contI.CopyFrom(conI);
if (DatabaseUpdate)
{
var prevCont = PreviousContainerList.FindByConstantID(conI.ConstantID);
if (prevCont != null)
contI.IsExpanded = prevCont.IsExpanded;
if (conI.ConstantID == PreviousSelected)
_selectedTreeNode = tNode;
}
else
{
contI.IsExpanded = Convert.ToBoolean(_sqlDataReader["Expanded"]);
}
ContainerList.Add(contI);
ConnectionList.Add(conI);
tNode.Tag = contI;
tNode.ImageIndex = (int)TreeImageType.Container;
tNode.SelectedImageIndex = (int)TreeImageType.Container;
}
private ConnectionInfo GetConnectionInfoFromSql()
{
try
{
var connectionInfo = new ConnectionInfo
{
PositionID = Convert.ToInt32(_sqlDataReader["PositionID"]),
ConstantID = Convert.ToString(_sqlDataReader["ConstantID"]),
Name = Convert.ToString(_sqlDataReader["Name"]),
Description = Convert.ToString(_sqlDataReader["Description"]),
Hostname = Convert.ToString(_sqlDataReader["Hostname"]),
Username = Convert.ToString(_sqlDataReader["Username"])
};
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
connectionInfo.Password = cryptographyProvider.Decrypt(Convert.ToString(_sqlDataReader["Password"]), _pW);
connectionInfo.Domain = Convert.ToString(_sqlDataReader["DomainName"]);
connectionInfo.DisplayWallpaper = Convert.ToBoolean(_sqlDataReader["DisplayWallpaper"]);
connectionInfo.DisplayThemes = Convert.ToBoolean(_sqlDataReader["DisplayThemes"]);
connectionInfo.CacheBitmaps = Convert.ToBoolean(_sqlDataReader["CacheBitmaps"]);
connectionInfo.UseConsoleSession = Convert.ToBoolean(_sqlDataReader["ConnectToConsole"]);
connectionInfo.RedirectDiskDrives = Convert.ToBoolean(_sqlDataReader["RedirectDiskDrives"]);
connectionInfo.RedirectPrinters = Convert.ToBoolean(_sqlDataReader["RedirectPrinters"]);
connectionInfo.RedirectPorts = Convert.ToBoolean(_sqlDataReader["RedirectPorts"]);
connectionInfo.RedirectSmartCards = Convert.ToBoolean(_sqlDataReader["RedirectSmartCards"]);
connectionInfo.RedirectKeys = Convert.ToBoolean(_sqlDataReader["RedirectKeys"]);
connectionInfo.RedirectSound = (ProtocolRDP.RDPSounds)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDPSounds), Convert.ToString(_sqlDataReader["RedirectSound"]));
connectionInfo.Protocol = (ProtocolType)Tools.MiscTools.StringToEnum(typeof(ProtocolType), Convert.ToString(_sqlDataReader["Protocol"]));
connectionInfo.Port = Convert.ToInt32(_sqlDataReader["Port"]);
connectionInfo.PuttySession = Convert.ToString(_sqlDataReader["PuttySession"]);
connectionInfo.Colors = (ProtocolRDP.RDPColors)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDPColors), Convert.ToString(_sqlDataReader["Colors"]));
connectionInfo.Resolution = (ProtocolRDP.RDPResolutions)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDPResolutions), Convert.ToString(_sqlDataReader["Resolution"]));
connectionInfo.Icon = Convert.ToString(_sqlDataReader["Icon"]);
connectionInfo.Panel = Convert.ToString(_sqlDataReader["Panel"]);
connectionInfo.Inheritance = new ConnectionInfoInheritance(connectionInfo)
{
CacheBitmaps = Convert.ToBoolean(_sqlDataReader["InheritCacheBitmaps"]),
Colors = Convert.ToBoolean(_sqlDataReader["InheritColors"]),
Description = Convert.ToBoolean(_sqlDataReader["InheritDescription"]),
DisplayThemes = Convert.ToBoolean(_sqlDataReader["InheritDisplayThemes"]),
DisplayWallpaper = Convert.ToBoolean(_sqlDataReader["InheritDisplayWallpaper"]),
Domain = Convert.ToBoolean(_sqlDataReader["InheritDomain"]),
Icon = Convert.ToBoolean(_sqlDataReader["InheritIcon"]),
Panel = Convert.ToBoolean(_sqlDataReader["InheritPanel"]),
Password = Convert.ToBoolean(_sqlDataReader["InheritPassword"]),
Port = Convert.ToBoolean(_sqlDataReader["InheritPort"]),
Protocol = Convert.ToBoolean(_sqlDataReader["InheritProtocol"]),
PuttySession = Convert.ToBoolean(_sqlDataReader["InheritPuttySession"]),
RedirectDiskDrives = Convert.ToBoolean(_sqlDataReader["InheritRedirectDiskDrives"]),
RedirectKeys = Convert.ToBoolean(_sqlDataReader["InheritRedirectKeys"]),
RedirectPorts = Convert.ToBoolean(_sqlDataReader["InheritRedirectPorts"]),
RedirectPrinters = Convert.ToBoolean(_sqlDataReader["InheritRedirectPrinters"]),
RedirectSmartCards = Convert.ToBoolean(_sqlDataReader["InheritRedirectSmartCards"]),
RedirectSound = Convert.ToBoolean(_sqlDataReader["InheritRedirectSound"]),
Resolution = Convert.ToBoolean(_sqlDataReader["InheritResolution"]),
UseConsoleSession = Convert.ToBoolean(_sqlDataReader["InheritUseConsoleSession"]),
Username = Convert.ToBoolean(_sqlDataReader["InheritUsername"])
};
if (_confVersion > 1.5) //1.6
{
connectionInfo.ICAEncryptionStrength = (ProtocolICA.EncryptionStrength)Tools.MiscTools.StringToEnum(typeof(ProtocolICA.EncryptionStrength), Convert.ToString(_sqlDataReader["ICAEncryptionStrength"]));
connectionInfo.Inheritance.ICAEncryptionStrength = Convert.ToBoolean(_sqlDataReader["InheritICAEncryptionStrength"]);
connectionInfo.PreExtApp = Convert.ToString(_sqlDataReader["PreExtApp"]);
connectionInfo.PostExtApp = Convert.ToString(_sqlDataReader["PostExtApp"]);
connectionInfo.Inheritance.PreExtApp = Convert.ToBoolean(_sqlDataReader["InheritPreExtApp"]);
connectionInfo.Inheritance.PostExtApp = Convert.ToBoolean(_sqlDataReader["InheritPostExtApp"]);
}
if (_confVersion > 1.6) //1.7
{
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.Compression), Convert.ToString(_sqlDataReader["VNCCompression"]));
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.Encoding), Convert.ToString(_sqlDataReader["VNCEncoding"]));
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.AuthMode), Convert.ToString(_sqlDataReader["VNCAuthMode"]));
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.ProxyType), Convert.ToString(_sqlDataReader["VNCProxyType"]));
connectionInfo.VNCProxyIP = Convert.ToString(_sqlDataReader["VNCProxyIP"]);
connectionInfo.VNCProxyPort = Convert.ToInt32(_sqlDataReader["VNCProxyPort"]);
connectionInfo.VNCProxyUsername = Convert.ToString(_sqlDataReader["VNCProxyUsername"]);
connectionInfo.VNCProxyPassword = cryptographyProvider.Decrypt(Convert.ToString(_sqlDataReader["VNCProxyPassword"]), _pW);
connectionInfo.VNCColors = (ProtocolVNC.Colors)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.Colors), Convert.ToString(_sqlDataReader["VNCColors"]));
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.SmartSizeMode), Convert.ToString(_sqlDataReader["VNCSmartSizeMode"]));
connectionInfo.VNCViewOnly = Convert.ToBoolean(_sqlDataReader["VNCViewOnly"]);
connectionInfo.Inheritance.VNCCompression = Convert.ToBoolean(_sqlDataReader["InheritVNCCompression"]);
connectionInfo.Inheritance.VNCEncoding = Convert.ToBoolean(_sqlDataReader["InheritVNCEncoding"]);
connectionInfo.Inheritance.VNCAuthMode = Convert.ToBoolean(_sqlDataReader["InheritVNCAuthMode"]);
connectionInfo.Inheritance.VNCProxyType = Convert.ToBoolean(_sqlDataReader["InheritVNCProxyType"]);
connectionInfo.Inheritance.VNCProxyIP = Convert.ToBoolean(_sqlDataReader["InheritVNCProxyIP"]);
connectionInfo.Inheritance.VNCProxyPort = Convert.ToBoolean(_sqlDataReader["InheritVNCProxyPort"]);
connectionInfo.Inheritance.VNCProxyUsername = Convert.ToBoolean(_sqlDataReader["InheritVNCProxyUsername"]);
connectionInfo.Inheritance.VNCProxyPassword = Convert.ToBoolean(_sqlDataReader["InheritVNCProxyPassword"]);
connectionInfo.Inheritance.VNCColors = Convert.ToBoolean(_sqlDataReader["InheritVNCColors"]);
connectionInfo.Inheritance.VNCSmartSizeMode = Convert.ToBoolean(_sqlDataReader["InheritVNCSmartSizeMode"]);
connectionInfo.Inheritance.VNCViewOnly = Convert.ToBoolean(_sqlDataReader["InheritVNCViewOnly"]);
}
if (_confVersion > 1.7) //1.8
{
connectionInfo.RDPAuthenticationLevel = (ProtocolRDP.AuthenticationLevel)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.AuthenticationLevel), Convert.ToString(_sqlDataReader["RDPAuthenticationLevel"]));
connectionInfo.Inheritance.RDPAuthenticationLevel = Convert.ToBoolean(_sqlDataReader["InheritRDPAuthenticationLevel"]);
}
if (_confVersion > 1.8) //1.9
{
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Tools.MiscTools.StringToEnum(typeof(HTTPBase.RenderingEngine), Convert.ToString(_sqlDataReader["RenderingEngine"]));
connectionInfo.MacAddress = Convert.ToString(_sqlDataReader["MacAddress"]);
connectionInfo.Inheritance.RenderingEngine = Convert.ToBoolean(_sqlDataReader["InheritRenderingEngine"]);
connectionInfo.Inheritance.MacAddress = Convert.ToBoolean(_sqlDataReader["InheritMacAddress"]);
}
if (_confVersion > 1.9) //2.0
{
connectionInfo.UserField = Convert.ToString(_sqlDataReader["UserField"]);
connectionInfo.Inheritance.UserField = Convert.ToBoolean(_sqlDataReader["InheritUserField"]);
}
if (_confVersion > 2.0) //2.1
{
connectionInfo.ExtApp = Convert.ToString(_sqlDataReader["ExtApp"]);
connectionInfo.Inheritance.ExtApp = Convert.ToBoolean(_sqlDataReader["InheritExtApp"]);
}
if (_confVersion >= 2.2)
{
connectionInfo.RDGatewayUsageMethod = (ProtocolRDP.RDGatewayUsageMethod)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDGatewayUsageMethod), Convert.ToString(_sqlDataReader["RDGatewayUsageMethod"]));
connectionInfo.RDGatewayHostname = Convert.ToString(_sqlDataReader["RDGatewayHostname"]);
connectionInfo.RDGatewayUseConnectionCredentials = (ProtocolRDP.RDGatewayUseConnectionCredentials)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDGatewayUseConnectionCredentials), Convert.ToString(_sqlDataReader["RDGatewayUseConnectionCredentials"]));
connectionInfo.RDGatewayUsername = Convert.ToString(_sqlDataReader["RDGatewayUsername"]);
connectionInfo.RDGatewayPassword = cryptographyProvider.Decrypt(Convert.ToString(_sqlDataReader["RDGatewayPassword"]), _pW);
connectionInfo.RDGatewayDomain = Convert.ToString(_sqlDataReader["RDGatewayDomain"]);
connectionInfo.Inheritance.RDGatewayUsageMethod = Convert.ToBoolean(_sqlDataReader["InheritRDGatewayUsageMethod"]);
connectionInfo.Inheritance.RDGatewayHostname = Convert.ToBoolean(_sqlDataReader["InheritRDGatewayHostname"]);
connectionInfo.Inheritance.RDGatewayUsername = Convert.ToBoolean(_sqlDataReader["InheritRDGatewayUsername"]);
connectionInfo.Inheritance.RDGatewayPassword = Convert.ToBoolean(_sqlDataReader["InheritRDGatewayPassword"]);
connectionInfo.Inheritance.RDGatewayDomain = Convert.ToBoolean(_sqlDataReader["InheritRDGatewayDomain"]);
}
if (_confVersion >= 2.3)
{
connectionInfo.EnableFontSmoothing = Convert.ToBoolean(_sqlDataReader["EnableFontSmoothing"]);
connectionInfo.EnableDesktopComposition = Convert.ToBoolean(_sqlDataReader["EnableDesktopComposition"]);
connectionInfo.Inheritance.EnableFontSmoothing = Convert.ToBoolean(_sqlDataReader["InheritEnableFontSmoothing"]);
connectionInfo.Inheritance.EnableDesktopComposition = Convert.ToBoolean(_sqlDataReader["InheritEnableDesktopComposition"]);
}
if (_confVersion >= 2.4)
{
connectionInfo.UseCredSsp = Convert.ToBoolean(_sqlDataReader["UseCredSsp"]);
connectionInfo.Inheritance.UseCredSsp = Convert.ToBoolean(_sqlDataReader["InheritUseCredSsp"]);
}
if (_confVersion >= 2.5)
{
connectionInfo.LoadBalanceInfo = Convert.ToString(_sqlDataReader["LoadBalanceInfo"]);
connectionInfo.AutomaticResize = Convert.ToBoolean(_sqlDataReader["AutomaticResize"]);
connectionInfo.Inheritance.LoadBalanceInfo = Convert.ToBoolean(_sqlDataReader["InheritLoadBalanceInfo"]);
connectionInfo.Inheritance.AutomaticResize = Convert.ToBoolean(_sqlDataReader["InheritAutomaticResize"]);
}
if (DatabaseUpdate)
connectionInfo.PleaseConnect = Convert.ToBoolean(_sqlDataReader["Connected"]);
return connectionInfo;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strGetConnectionInfoFromSqlFailed + Environment.NewLine + ex.Message, true);
}
return null;
}
private delegate void SetSelectedNodeDelegate(TreeNode treeNode);
private static void SetSelectedNode(TreeNode treeNode)
{
if (ConnectionTree.TreeView != null && ConnectionTree.TreeView.InvokeRequired)
{
Windows.treeForm.Invoke(new SetSelectedNodeDelegate(SetSelectedNode), treeNode);
return;
}
Windows.treeForm.tvConnections.SelectedNode = treeNode;
}
private bool Authenticate(string value, bool compareToOriginalValue, RootNodeInfo rootInfo = null)
{
var passwordName = "";
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
passwordName = Language.strSQLServer.TrimEnd(':');
if (compareToOriginalValue)
{
while (cryptographyProvider.Decrypt(value, _pW) == value)
{
_pW = Tools.MiscTools.PasswordDialog(passwordName, false);
if (_pW.Length == 0)
return false;
}
}
else
{
while (cryptographyProvider.Decrypt(value, _pW) != "ThisIsProtected")
{
_pW = Tools.MiscTools.PasswordDialog(passwordName, false);
if (_pW.Length == 0)
return false;
}
if (rootInfo == null) return true;
rootInfo.Password = true;
rootInfo.PasswordString = _pW.ConvertToUnsecureString();
}
return true;
}
}
}

View File

@@ -1,131 +0,0 @@
using mRemoteNG.App;
using mRemoteNG.Messages;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
namespace mRemoteNG.Config.Connections
{
public class SqlConnectionsUpdateChecker : IDisposable
{
private SqlConnector sqlConnector;
private SqlCommand sqlQuery;
private SqlDataReader sqlReader;
public SqlConnectionsUpdateChecker()
{
sqlConnector = default(SqlConnectorImp);
sqlQuery = default(SqlCommand);
sqlReader = default(SqlDataReader);
}
~SqlConnectionsUpdateChecker()
{
Dispose(false);
}
public void IsDatabaseUpdateAvailableAsync()
{
Thread t = new Thread(IsDatabaseUpdateAvailableDelegate);
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
private void IsDatabaseUpdateAvailableDelegate()
{
IsDatabaseUpdateAvailable();
}
public bool IsDatabaseUpdateAvailable()
{
ConnectToSqlDB();
BuildSqlQueryToGetUpdateStatus();
ExecuteQuery();
bool updateIsAvailable = DatabaseIsMoreUpToDateThanUs();
SendUpdateCheckFinishedEvent(updateIsAvailable);
return updateIsAvailable;
}
private void ConnectToSqlDB()
{
try
{
sqlConnector = new SqlConnectorImp();
sqlConnector.Connect();
}
catch(Exception e)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Unable to connect to Sql DB to check for updates." + Environment.NewLine + e.Message, true);
}
}
private void BuildSqlQueryToGetUpdateStatus()
{
try
{
SqlCommandBuilder sqlCmdBuilder = new SqlUpdateQueryBuilder();
sqlQuery = sqlCmdBuilder.BuildCommand();
sqlConnector.AssociateItemToThisConnector(sqlQuery);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Could not build query to check for updates from the Sql server." + Environment.NewLine + ex.Message, true);
}
}
private void ExecuteQuery()
{
try
{
sqlReader = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
sqlReader.Read();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Error executing Sql query to get updates from the DB." + Environment.NewLine + ex.Message, true);
}
}
private bool DatabaseIsMoreUpToDateThanUs()
{
if (GetLastUpdateTimeFromDBResponse() > Runtime.LastSqlUpdate)
return true;
return false;
}
private DateTime GetLastUpdateTimeFromDBResponse()
{
DateTime LastUpdateInDB = default(DateTime);
if (sqlReader.HasRows)
LastUpdateInDB = Convert.ToDateTime(sqlReader["LastUpdate"]);
return LastUpdateInDB;
}
private void SendUpdateCheckFinishedEvent(bool UpdateAvailable)
{
if (SQLUpdateCheckFinishedEvent != null)
SQLUpdateCheckFinishedEvent(UpdateAvailable);
}
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool itIsSafeToDisposeManagedObjects)
{
if (itIsSafeToDisposeManagedObjects)
{
sqlConnector.Disconnect();
sqlConnector.Dispose();
}
}
public delegate void SQLUpdateCheckFinishedEventHandler(bool UpdateAvailable);
private static SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinishedEvent;
public static event SQLUpdateCheckFinishedEventHandler SQLUpdateCheckFinished
{
add { SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler)System.Delegate.Combine(SQLUpdateCheckFinishedEvent, value); }
remove { SQLUpdateCheckFinishedEvent = (SQLUpdateCheckFinishedEventHandler)System.Delegate.Remove(SQLUpdateCheckFinishedEvent, value); }
}
}
}

View File

@@ -1,24 +0,0 @@
using System.Data.SqlClient;
namespace mRemoteNG.Config.Connections
{
public class SqlUpdateQueryBuilder : SqlCommandBuilder
{
private string _updateQuery;
public SqlUpdateQueryBuilder()
{
Initialize();
}
private void Initialize()
{
_updateQuery = "SELECT * FROM tblUpdate";
}
public SqlCommand BuildCommand()
{
return new SqlCommand(_updateQuery);
}
}
}

View File

@@ -1,82 +0,0 @@
using System;
using System.Timers;
using mRemoteNG.App;
namespace mRemoteNG.Config.Connections
{
public class SqlUpdateTimer : IDisposable
{
private Timer _sqlUpdateTimer;
public SqlUpdateTimer()
{
Initialize();
}
~SqlUpdateTimer()
{
Dispose(false);
}
private void Initialize()
{
_sqlUpdateTimer = new Timer();
_sqlUpdateTimer.Interval = 3000;
_sqlUpdateTimer.Elapsed += sqlUpdateTimer_Elapsed;
}
public void Enable()
{
_sqlUpdateTimer.Start();
}
public void Disable()
{
_sqlUpdateTimer.Stop();
}
public bool IsUpdateCheckingEnabled()
{
return _sqlUpdateTimer.Enabled;
}
private static void sqlUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{
SqlUpdateTimerElapsedEvent();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
{
if (itIsSafeToAlsoFreeManagedObjects)
{
StopTimer();
}
}
private void StopTimer()
{
try
{
_sqlUpdateTimer.Stop();
_sqlUpdateTimer.Close();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("SqlUpdateTimer StopTimer Exception", ex);
}
}
public delegate void SqlUpdateTimerElapsedEventHandler();
private static SqlUpdateTimerElapsedEventHandler SqlUpdateTimerElapsedEvent;
public static event SqlUpdateTimerElapsedEventHandler SqlUpdateTimerElapsed
{
add { SqlUpdateTimerElapsedEvent = (SqlUpdateTimerElapsedEventHandler)Delegate.Combine(SqlUpdateTimerElapsedEvent, value); }
remove { SqlUpdateTimerElapsedEvent = (SqlUpdateTimerElapsedEventHandler)Delegate.Remove(SqlUpdateTimerElapsedEvent, value); }
}
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.IO;
using mRemoteNG.App;
namespace mRemoteNG.Config.DataProviders
{
public class FileDataProvider : IDataProvider<string>
{
public string FilePath { get; set; }
public FileDataProvider(string filePath)
{
FilePath = filePath;
}
public virtual string Load()
{
var fileContents = "";
try
{
fileContents = File.ReadAllText(FilePath);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);
}
return fileContents;
}
public virtual void Save(string content)
{
try
{
File.WriteAllText(FilePath, content);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to save file {FilePath}", ex);
}
}
public virtual void MoveTo(string newPath)
{
try
{
File.Move(FilePath, newPath);
FilePath = newPath;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to move file {FilePath} to {newPath}", ex);
}
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.IO;
using mRemoteNG.App;
namespace mRemoteNG.Config.DataProviders
{
public class FileDataProviderWithBackup : FileDataProvider
{
protected string BackupFileSuffix = ".backup";
public FileDataProviderWithBackup(string filePath) : base(filePath)
{
}
public override void Save(string content)
{
CreateBackup();
base.Save(content);
}
protected virtual void CreateBackup()
{
var backupFileName = FilePath + BackupFileSuffix;
try
{
File.Copy(FilePath, backupFileName, true);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to create backup of file {FilePath}", ex);
throw;
}
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using mRemoteNG.App;
namespace mRemoteNG.Config.DataProviders
{
public class FileDataProviderWithRollingBackup : FileDataProviderWithBackup
{
public FileDataProviderWithRollingBackup(string filePath) : base(filePath)
{
}
protected override void CreateBackup()
{
CreateRollingBackup();
base.CreateBackup();
}
protected virtual void CreateRollingBackup()
{
var timeStamp = $"{DateTime.Now:yyyyMMdd-HHmmss-ffff}";
var normalBackup = new FileDataProviderWithBackup(FilePath + BackupFileSuffix);
var normalBackupWithoutSuffix = normalBackup.FilePath.Replace(BackupFileSuffix, "");
try
{
normalBackup.MoveTo(normalBackupWithoutSuffix + timeStamp + BackupFileSuffix);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to create rolling backup of file {FilePath}", ex);
throw;
}
}
}
}

View File

@@ -0,0 +1,10 @@

namespace mRemoteNG.Config.DataProviders
{
public interface IDataProvider<TFormat>
{
TFormat Load();
void Save(TFormat contents);
}
}

View File

@@ -0,0 +1,56 @@
using System.Data;
using System.Data.SqlClient;
using mRemoteNG.Config.DatabaseConnectors;
namespace mRemoteNG.Config.DataProviders
{
public class SqlDataProvider : IDataProvider<DataTable>
{
public SqlDatabaseConnector SqlDatabaseConnector { get; }
public SqlDataProvider(SqlDatabaseConnector sqlDatabaseConnector)
{
SqlDatabaseConnector = sqlDatabaseConnector;
}
~SqlDataProvider()
{
SqlDatabaseConnector.Dispose();
}
public DataTable Load()
{
var dataTable = new DataTable();
var sqlQuery = new SqlCommand("SELECT * FROM tblCons ORDER BY PositionID ASC");
SqlDatabaseConnector.AssociateItemToThisConnector(sqlQuery);
if (!SqlDatabaseConnector.IsConnected)
OpenConnection();
var sqlDataReader = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
if (sqlDataReader.HasRows)
dataTable.Load(sqlDataReader);
sqlDataReader.Close();
return dataTable;
}
public void Save(DataTable dataTable)
{
if (!SqlDatabaseConnector.IsConnected)
OpenConnection();
var sqlBulkCopy = new SqlBulkCopy(SqlDatabaseConnector.SqlConnection) {DestinationTableName = "dbo.tblCons"};
sqlBulkCopy.WriteToServer(dataTable);
sqlBulkCopy.Close();
}
public void OpenConnection()
{
SqlDatabaseConnector.Connect();
}
public void CloseConnection()
{
SqlDatabaseConnector.Disconnect();
}
}
}

View File

@@ -1,9 +1,11 @@
using System;
using System.Data.SqlClient;
namespace mRemoteNG.Config
namespace mRemoteNG.Config.DatabaseConnectors
{
public interface SqlConnector : IDisposable
public interface IDatabaseConnector : IDisposable
{
bool IsConnected { get; }
void Connect();
void Disconnect();
void AssociateItemToThisConnector(SqlCommand sqlCommand);

View File

@@ -1,24 +1,27 @@
using mRemoteNG.App.Info;
using System.Data;
using System.Data.SqlClient;
using mRemoteNG.App.Info;
using mRemoteNG.Security.SymmetricEncryption;
namespace mRemoteNG.Config
namespace mRemoteNG.Config.DatabaseConnectors
{
public class SqlConnectorImp : SqlConnector
public class SqlDatabaseConnector : IDatabaseConnector
{
private SqlConnection _sqlConnection = default(SqlConnection);
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
private string _sqlConnectionString = "";
private string _sqlHost;
private string _sqlCatalog;
private string _sqlUsername;
private string _sqlPassword;
public SqlConnectorImp()
public bool IsConnected => (SqlConnection.State == ConnectionState.Open);
public SqlDatabaseConnector()
{
Initialize();
}
~SqlConnectorImp()
~SqlDatabaseConnector()
{
Dispose(false);
}
@@ -26,7 +29,7 @@ namespace mRemoteNG.Config
private void Initialize()
{
BuildSqlConnectionString();
_sqlConnection = new SqlConnection(_sqlConnectionString);
SqlConnection = new SqlConnection(_sqlConnectionString);
}
private void BuildSqlConnectionString()
@@ -41,12 +44,12 @@ namespace mRemoteNG.Config
private void BuildSqlConnectionStringWithCustomCredentials()
{
_sqlConnectionString = string.Format("Data Source={0};Initial Catalog={1};User Id={2};Password={3}", _sqlHost, _sqlCatalog, _sqlUsername, _sqlPassword);
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
}
private void BuildSqlConnectionStringWithDefaultCredentials()
{
_sqlConnectionString = string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True", _sqlHost, _sqlCatalog);
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};Integrated Security=True";
}
private void GetSqlConnectionDataFromSettings()
@@ -60,19 +63,18 @@ namespace mRemoteNG.Config
public void Connect()
{
_sqlConnection.Open();
SqlConnection.Open();
}
public void Disconnect()
{
_sqlConnection.Close();
SqlConnection.Close();
}
public void AssociateItemToThisConnector(SqlCommand sqlCommand)
{
sqlCommand.Connection = _sqlConnection;
sqlCommand.Connection = SqlConnection;
}
public void Dispose()
{
@@ -80,11 +82,9 @@ namespace mRemoteNG.Config
}
private void Dispose(bool itIsSafeToFreeManagedObjects)
{
if (itIsSafeToFreeManagedObjects)
{
_sqlConnection.Close();
_sqlConnection.Dispose();
}
if (!itIsSafeToFreeManagedObjects) return;
SqlConnection.Close();
SqlConnection.Dispose();
}
}
}

View File

@@ -1,115 +0,0 @@
using System;
using System.Windows.Forms;
using System.DirectoryServices;
using mRemoteNG.App;
using System.Text.RegularExpressions;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree;
namespace mRemoteNG.Config.Import
{
public class ActiveDirectory
{
public static void Import(string ldapPath, TreeNode parentTreeNode)
{
try
{
var treeNode = ConnectionTreeNode.AddNode(TreeNodeType.Container);
var containerInfo = new ContainerInfo();
containerInfo.TreeNode = treeNode;
var name = "";
var match = Regex.Match(ldapPath, "ou=([^,]*)", RegexOptions.IgnoreCase);
if (match.Success)
{
name = match.Groups[1].Captures[0].Value;
}
else
{
name = Language.strActiveDirectory;
}
containerInfo.Name = name;
// We can only inherit from a container node, not the root node or connection nodes
if (ConnectionTreeNode.GetNodeType(parentTreeNode) == TreeNodeType.Container)
{
containerInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
}
else
{
containerInfo.Inheritance.DisableInheritance();
}
treeNode.Text = name;
treeNode.Name = name;
treeNode.Tag = containerInfo;
Runtime.ContainerList.Add(containerInfo);
ImportComputers(ldapPath, treeNode);
parentTreeNode.Nodes.Add(treeNode);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex, logOnly: true);
}
}
private static void ImportComputers(string ldapPath, TreeNode parentTreeNode)
{
try
{
const string ldapFilter = "(objectClass=computer)";
var ldapSearcher = new DirectorySearcher();
var ldapResults = default(SearchResultCollection);
var ldapResult = default(SearchResult);
ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath);
ldapSearcher.PropertiesToLoad.AddRange(new[] {"securityEquals", "cn"});
ldapSearcher.Filter = ldapFilter;
ldapSearcher.SearchScope = SearchScope.OneLevel;
ldapResults = ldapSearcher.FindAll();
foreach (SearchResult tempLoopVar_ldapResult in ldapResults)
{
ldapResult = tempLoopVar_ldapResult;
var with_2 = ldapResult.GetDirectoryEntry();
var displayName = Convert.ToString(with_2.Properties["cn"].Value);
var description = Convert.ToString(with_2.Properties["Description"].Value);
var hostName = Convert.ToString(with_2.Properties["dNSHostName"].Value);
var treeNode = ConnectionTreeNode.AddNode(TreeNodeType.Connection, displayName);
var connectionInfo = new ConnectionInfo();
var inheritanceInfo = new ConnectionInfoInheritance(connectionInfo);
inheritanceInfo.TurnOnInheritanceCompletely();
inheritanceInfo.Description = false;
if (parentTreeNode.Tag is ContainerInfo)
{
connectionInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
}
connectionInfo.Inheritance = inheritanceInfo;
connectionInfo.Name = displayName;
connectionInfo.Hostname = hostName;
connectionInfo.Description = description;
connectionInfo.TreeNode = treeNode;
treeNode.Name = displayName;
treeNode.Tag = connectionInfo; //set the nodes tag to the conI
//add connection to connections
Runtime.ConnectionList.Add(connectionInfo);
parentTreeNode.Nodes.Add(treeNode);
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex, logOnly: true);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class ActiveDirectoryImporter : IConnectionImporter
{
public void Import(object ldapPath, ContainerInfo destinationContainer)
{
var ldapPathAsString = ldapPath as string;
if (ldapPathAsString == null) return;
Import(ldapPathAsString, destinationContainer);
}
public void Import(string ldapPath, ContainerInfo destinationContainer)
{
try
{
var deserializer = new ActiveDirectoryDeserializer(ldapPath);
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, logOnly: true);
}
}
}
}

View File

@@ -0,0 +1,10 @@
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public interface IConnectionImporter
{
void Import(object source, ContainerInfo destinationContainer);
}
}

View File

@@ -1,100 +0,0 @@
using System.Collections;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tools;
namespace mRemoteNG.Config.Import
{
public static class PortScan
{
public static void Import(IEnumerable hosts, ProtocolType protocol, TreeNode parentTreeNode)
{
foreach (ScanHost host in hosts)
{
var finalProtocol = default(ProtocolType);
var protocolValid = false;
var treeNode = Tree.ConnectionTreeNode.AddNode(Tree.TreeNodeType.Connection, host.HostNameWithoutDomain);
var connectionInfo = new ConnectionInfo();
connectionInfo.Inheritance = new ConnectionInfoInheritance(connectionInfo);
connectionInfo.Name = host.HostNameWithoutDomain;
connectionInfo.Hostname = host.HostName;
switch (protocol)
{
case ProtocolType.SSH2:
if (host.SSH)
{
finalProtocol = ProtocolType.SSH2;
protocolValid = true;
}
break;
case ProtocolType.Telnet:
if (host.Telnet)
{
finalProtocol = ProtocolType.Telnet;
protocolValid = true;
}
break;
case ProtocolType.HTTP:
if (host.HTTP)
{
finalProtocol = ProtocolType.HTTP;
protocolValid = true;
}
break;
case ProtocolType.HTTPS:
if (host.HTTPS)
{
finalProtocol = ProtocolType.HTTPS;
protocolValid = true;
}
break;
case ProtocolType.Rlogin:
if (host.Rlogin)
{
finalProtocol = ProtocolType.Rlogin;
protocolValid = true;
}
break;
case ProtocolType.RDP:
if (host.RDP)
{
finalProtocol = ProtocolType.RDP;
protocolValid = true;
}
break;
case ProtocolType.VNC:
if (host.VNC)
{
finalProtocol = ProtocolType.VNC;
protocolValid = true;
}
break;
}
if (protocolValid)
{
connectionInfo.Protocol = finalProtocol;
connectionInfo.SetDefaultPort();
treeNode.Tag = connectionInfo;
parentTreeNode.Nodes.Add(treeNode);
if (parentTreeNode.Tag is ContainerInfo)
{
connectionInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
}
Runtime.ConnectionList.Add(connectionInfo);
}
}
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tools;
namespace mRemoteNG.Config.Import
{
public class PortScanImporter : IConnectionImporter
{
private readonly ProtocolType _targetProtocolType;
public PortScanImporter(ProtocolType targetProtocolType)
{
_targetProtocolType = targetProtocolType;
}
public void Import(object hosts, ContainerInfo destinationContainer)
{
var hostsAsEnumerableScanHost = hosts as IEnumerable<ScanHost>;
if (hostsAsEnumerableScanHost == null) return;
Import(hostsAsEnumerableScanHost, destinationContainer);
}
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
{
var deserializer = new PortScanDeserializer(hosts, _targetProtocolType);
var connectionTreeModel = deserializer.Deserialize();
var importedRootNode = connectionTreeModel.RootNodes.First();
if (importedRootNode == null) return;
var childrenToAdd = importedRootNode.Children.ToArray();
destinationContainer.AddChildRange(childrenToAdd);
}
}
}

View File

@@ -1,193 +0,0 @@
using System;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection;
using mRemoteNG.Tree;
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class PuttyConnectionManager
{
public static void Import(string fileName, TreeNode parentTreeNode)
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(fileName);
XmlNode configurationNode = xmlDocument.SelectSingleNode("/configuration");
//Dim version As New Version(configurationNode.Attributes("version").Value)
//If Not version = New Version(0, 7, 1, 136) Then
// Throw New FileFormatException(String.Format("Unsupported file version ({0}).", version))
//End If
foreach (XmlNode rootNode in configurationNode.SelectNodes("./root"))
{
ImportRootOrContainer(rootNode, parentTreeNode);
}
}
private static void ImportRootOrContainer(XmlNode xmlNode, TreeNode parentTreeNode)
{
string xmlNodeType = xmlNode.Attributes["type"].Value;
switch (xmlNode.Name)
{
case "root":
if (!(string.Compare(xmlNodeType, "database", ignoreCase: true) == 0))
{
throw (new FileFormatException(string.Format("Unrecognized root node type ({0}).", xmlNodeType)));
}
break;
case "container":
if (!(string.Compare(xmlNodeType, "folder", ignoreCase: true) == 0))
{
throw (new FileFormatException(string.Format("Unrecognized root node type ({0}).", xmlNodeType)));
}
break;
default:
// ReSharper disable once LocalizableElement
throw (new ArgumentException("Argument must be either a root or a container node.", "xmlNode"));
}
if (parentTreeNode == null)
{
throw (new InvalidOperationException("parentInfo.TreeNode must not be null."));
}
string name = xmlNode.Attributes["name"].Value;
TreeNode treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
ContainerInfo containerInfo = new ContainerInfo();
containerInfo.TreeNode = treeNode;
containerInfo.Name = name;
ConnectionInfo connectionInfo = CreateConnectionInfo(name);
connectionInfo.Parent = containerInfo;
connectionInfo.IsContainer = true;
containerInfo.CopyFrom(connectionInfo);
// We can only inherit from a container node, not the root node or connection nodes
if (ConnectionTreeNode.GetNodeType(parentTreeNode) == TreeNodeType.Container)
{
containerInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
}
else
{
connectionInfo.Inheritance.DisableInheritance();
}
treeNode.Name = name;
treeNode.Tag = containerInfo;
treeNode.ImageIndex = (int)TreeImageType.Container;
treeNode.SelectedImageIndex = (int)TreeImageType.Container;
foreach (XmlNode childNode in xmlNode.SelectNodes("./*"))
{
switch (childNode.Name)
{
case "container":
ImportRootOrContainer(childNode, treeNode);
break;
case "connection":
ImportConnection(childNode, treeNode);
break;
default:
throw (new FileFormatException(string.Format("Unrecognized child node ({0}).", childNode.Name)));
}
}
containerInfo.IsExpanded = bool.Parse(xmlNode.Attributes["expanded"].InnerText);
if (containerInfo.IsExpanded)
{
treeNode.Expand();
}
Runtime.ContainerList.Add(containerInfo);
}
private static void ImportConnection(XmlNode connectionNode, TreeNode parentTreeNode)
{
string connectionNodeType = connectionNode.Attributes["type"].Value;
if (!(string.Compare(connectionNodeType, "PuTTY", ignoreCase: true) == 0))
{
throw (new FileFormatException(string.Format("Unrecognized connection node type ({0}).", connectionNodeType)));
}
string name = connectionNode.Attributes["name"].Value;
TreeNode treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
ConnectionInfo connectionInfo = ConnectionInfoFromXml(connectionNode);
connectionInfo.TreeNode = treeNode;
connectionInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
treeNode.Name = name;
treeNode.Tag = connectionInfo;
treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed;
treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;
Runtime.ConnectionList.Add(connectionInfo);
}
private static ConnectionInfo CreateConnectionInfo(string name)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.Inheritance = new ConnectionInfoInheritance(connectionInfo);
connectionInfo.Name = name;
return connectionInfo;
}
private static ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
{
XmlNode connectionInfoNode = xmlNode.SelectSingleNode("./connection_info");
string name = connectionInfoNode.SelectSingleNode("./name").InnerText;
ConnectionInfo connectionInfo = CreateConnectionInfo(name);
string protocol = connectionInfoNode.SelectSingleNode("./protocol").InnerText;
switch (protocol.ToLowerInvariant())
{
case "telnet":
connectionInfo.Protocol = ProtocolType.Telnet;
break;
case "ssh":
connectionInfo.Protocol = ProtocolType.SSH2;
break;
default:
throw (new FileFormatException(string.Format("Unrecognized protocol ({0}).", protocol)));
}
connectionInfo.Hostname = connectionInfoNode.SelectSingleNode("./host").InnerText;
connectionInfo.Port = Convert.ToInt32(connectionInfoNode.SelectSingleNode("./port").InnerText);
connectionInfo.PuttySession = connectionInfoNode.SelectSingleNode("./session").InnerText;
// ./commandline
connectionInfo.Description = connectionInfoNode.SelectSingleNode("./description").InnerText;
XmlNode loginNode = xmlNode.SelectSingleNode("./login");
connectionInfo.Username = loginNode.SelectSingleNode("login").InnerText;
connectionInfo.Password = loginNode.SelectSingleNode("password").InnerText;
// ./prompt
// ./timeout/connectiontimeout
// ./timeout/logintimeout
// ./timeout/passwordtimeout
// ./timeout/commandtimeout
// ./command/command1
// ./command/command2
// ./command/command3
// ./command/command4
// ./command/command5
// ./options/loginmacro
// ./options/postcommands
// ./options/endlinechar
return connectionInfo;
}
}
}

View File

@@ -0,0 +1,35 @@
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class PuttyConnectionManagerImporter : IConnectionImporter
{
public void Import(object filePath, ContainerInfo destinationContainer)
{
var filePathAsString = filePath as string;
if (filePathAsString == null)
return;
if (File.Exists(filePathAsString))
Import(filePathAsString, destinationContainer);
}
public void Import(string filePath, ContainerInfo destinationContainer)
{
var dataProvider = new FileDataProvider(filePath);
var xmlContent = dataProvider.Load();
var deserializer = new PuttyConnectionManagerDeserializer(xmlContent);
var connectionTreeModel = deserializer.Deserialize();
var importedRootNode = connectionTreeModel.RootNodes.First();
if (importedRootNode == null) return;
var childrenToAdd = importedRootNode.Children.ToArray();
destinationContainer.AddChildRange(childrenToAdd);
}
}
}

View File

@@ -1,221 +0,0 @@
using System;
using System.Windows.Forms;
using System.IO;
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Connection;
using mRemoteNG.Tree;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnection
{
public static void Import(string fileName, TreeNode parentTreeNode)
{
string[] lines = File.ReadAllLines(fileName);
string name = Path.GetFileNameWithoutExtension(fileName);
TreeNode treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.Inheritance = new ConnectionInfoInheritance(connectionInfo);
connectionInfo.Name = name;
connectionInfo.TreeNode = treeNode;
if (treeNode.Parent.Tag is ContainerInfo)
{
connectionInfo.Parent = (ContainerInfo)treeNode.Parent.Tag;
}
treeNode.Name = name;
treeNode.Tag = connectionInfo;
treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed;
treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;
foreach (string line in lines)
{
string[] parts = line.Split(new char[] {':'}, 3);
if (parts.Length < 3)
{
continue;
}
string key = parts[0];
string value = parts[2];
SetConnectionInfoParameter(connectionInfo, key, value);
}
Runtime.ConnectionList.Add(connectionInfo);
}
private static void SetConnectionInfoParameter(ConnectionInfo connectionInfo, string key, string value)
{
switch (key.ToLower())
{
case "full address":
Uri uri = new Uri("dummyscheme" + Uri.SchemeDelimiter + value);
if (!string.IsNullOrEmpty(uri.Host))
{
connectionInfo.Hostname = uri.Host;
}
if (!(uri.Port == -1))
{
connectionInfo.Port = uri.Port;
}
break;
case "server port":
connectionInfo.Port = Convert.ToInt32(value);
break;
case "username":
connectionInfo.Username = value;
break;
case "domain":
connectionInfo.Domain = value;
break;
case "session bpp":
switch (value)
{
case "8":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors256;
break;
case "15":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors15Bit;
break;
case "16":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors16Bit;
break;
case "24":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors24Bit;
break;
case "32":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors32Bit;
break;
}
break;
case "bitmapcachepersistenable":
if (value == "1")
{
connectionInfo.CacheBitmaps = true;
}
else
{
connectionInfo.CacheBitmaps = false;
}
break;
case "screen mode id":
if (value == "2")
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.Fullscreen;
}
else
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.FitToWindow;
}
break;
case "connect to console":
if (value == "1")
{
connectionInfo.UseConsoleSession = true;
}
break;
case "disable wallpaper":
if (value == "1")
{
connectionInfo.DisplayWallpaper = true;
}
else
{
connectionInfo.DisplayWallpaper = false;
}
break;
case "disable themes":
if (value == "1")
{
connectionInfo.DisplayThemes = true;
}
else
{
connectionInfo.DisplayThemes = false;
}
break;
case "allow font smoothing":
if (value == "1")
{
connectionInfo.EnableFontSmoothing = true;
}
else
{
connectionInfo.EnableFontSmoothing = false;
}
break;
case "allow desktop composition":
if (value == "1")
{
connectionInfo.EnableDesktopComposition = true;
}
else
{
connectionInfo.EnableDesktopComposition = false;
}
break;
case "redirectsmartcards":
if (value == "1")
{
connectionInfo.RedirectSmartCards = true;
}
else
{
connectionInfo.RedirectSmartCards = false;
}
break;
case "redirectdrives":
if (value == "1")
{
connectionInfo.RedirectDiskDrives = true;
}
else
{
connectionInfo.RedirectDiskDrives = false;
}
break;
case "redirectcomports":
if (value == "1")
{
connectionInfo.RedirectPorts = true;
}
else
{
connectionInfo.RedirectPorts = false;
}
break;
case "redirectprinters":
if (value == "1")
{
connectionInfo.RedirectPrinters = true;
}
else
{
connectionInfo.RedirectPrinters = false;
}
break;
case "audiomode":
switch (value)
{
case "0":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.BringToThisComputer;
break;
case "1":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.LeaveAtRemoteComputer;
break;
case "2":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.DoNotPlay;
break;
}
break;
}
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnectionImporter : IConnectionImporter
{
public void Import(object fileName, ContainerInfo destinationContainer)
{
var fileNameAsString = fileName as string;
if(fileNameAsString == null)
return;
if (File.Exists(fileNameAsString))
Import(fileNameAsString, destinationContainer);
}
public void Import(string fileName, ContainerInfo destinationContainer)
{
var dataProvider = new FileDataProvider(fileName);
var content = dataProvider.Load();
var lines = content.Split(Environment.NewLine.ToCharArray());
var deserializer = new RemoteDesktopConnectionDeserializer(lines);
var connectionTreeModel = deserializer.Deserialize();
var importedConnection = connectionTreeModel.RootNodes.First().Children.First();
if (importedConnection == null) return;
importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
destinationContainer.AddChild(importedConnection);
}
}
}

View File

@@ -1,387 +0,0 @@
using System;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Runtime.InteropServices;
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnectionManager
{
public static void Import(string fileName, TreeNode parentTreeNode)
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(fileName);
XmlNode rdcManNode = xmlDocument.SelectSingleNode("/RDCMan");
int schemaVersion = Convert.ToInt32(rdcManNode.Attributes["schemaVersion"].Value);
if (!(schemaVersion == 1))
{
throw (new FileFormatException(string.Format("Unsupported schema version ({0}).", schemaVersion)));
}
XmlNode versionNode = rdcManNode.SelectSingleNode("./version");
Version version = new Version(versionNode.InnerText);
if (!(version == new Version(2, 2)))
{
throw (new FileFormatException(string.Format("Unsupported file version ({0}).", version)));
}
XmlNode fileNode = rdcManNode.SelectSingleNode("./file");
ImportFileOrGroup(fileNode, parentTreeNode);
}
private static void ImportFileOrGroup(XmlNode xmlNode, TreeNode parentTreeNode)
{
XmlNode propertiesNode = xmlNode.SelectSingleNode("./properties");
string name = propertiesNode.SelectSingleNode("./name").InnerText;
TreeNode treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
ContainerInfo containerInfo = new ContainerInfo();
containerInfo.TreeNode = treeNode;
containerInfo.Name = name;
ConnectionInfo connectionInfo = ConnectionInfoFromXml(propertiesNode);
connectionInfo.Parent = containerInfo;
connectionInfo.IsContainer = true;
containerInfo.CopyFrom(connectionInfo);
// We can only inherit from a container node, not the root node or connection nodes
if (ConnectionTreeNode.GetNodeType(parentTreeNode) == TreeNodeType.Container)
{
containerInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
}
else
{
connectionInfo.Inheritance.DisableInheritance();
}
treeNode.Name = name;
treeNode.Tag = containerInfo;
treeNode.ImageIndex = (int)TreeImageType.Container;
treeNode.SelectedImageIndex = (int)TreeImageType.Container;
foreach (XmlNode childNode in xmlNode.SelectNodes("./group|./server"))
{
switch (childNode.Name)
{
case "group":
ImportFileOrGroup(childNode, treeNode);
break;
case "server":
ImportServer(childNode, treeNode);
break;
}
}
containerInfo.IsExpanded = bool.Parse(propertiesNode.SelectSingleNode("./expanded").InnerText);
if (containerInfo.IsExpanded)
{
treeNode.Expand();
}
Runtime.ContainerList.Add(containerInfo);
}
private static void ImportServer(XmlNode serverNode, TreeNode parentTreeNode)
{
string name = serverNode.SelectSingleNode("./displayName").InnerText;
TreeNode treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
ConnectionInfo connectionInfo = ConnectionInfoFromXml(serverNode);
connectionInfo.TreeNode = treeNode;
connectionInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
treeNode.Name = name;
treeNode.Tag = connectionInfo;
treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed;
treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;
Runtime.ConnectionList.Add(connectionInfo);
}
private static ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.Inheritance = new ConnectionInfoInheritance(connectionInfo);
string name = xmlNode.SelectSingleNode("./name").InnerText;
string displayName = "";
XmlNode displayNameNode = xmlNode.SelectSingleNode("./displayName");
if (displayNameNode == null)
{
displayName = name;
}
else
{
displayName = displayNameNode.InnerText;
}
connectionInfo.Name = displayName;
connectionInfo.Description = xmlNode.SelectSingleNode("./comment").InnerText;
connectionInfo.Hostname = name;
XmlNode logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
if (logonCredentialsNode.Attributes["inherit"].Value == "None")
{
connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName").InnerText;
XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password");
if (passwordNode.Attributes["storeAsClearText"].Value == "True")
{
connectionInfo.Password = passwordNode.InnerText;
}
else
{
connectionInfo.Password = DecryptPassword(passwordNode.InnerText);
}
connectionInfo.Domain = logonCredentialsNode.SelectSingleNode("./domain").InnerText;
}
else
{
connectionInfo.Inheritance.Username = true;
connectionInfo.Inheritance.Password = true;
connectionInfo.Inheritance.Domain = true;
}
XmlNode connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
if (connectionSettingsNode.Attributes["inherit"].Value == "None")
{
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole").InnerText);
// ./startProgram
// ./workingDir
connectionInfo.Port = Convert.ToInt32(connectionSettingsNode.SelectSingleNode("./port").InnerText);
}
else
{
connectionInfo.Inheritance.UseConsoleSession = true;
connectionInfo.Inheritance.Port = true;
}
XmlNode gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
if (gatewaySettingsNode.Attributes["inherit"].Value == "None")
{
if (gatewaySettingsNode.SelectSingleNode("./enabled").InnerText == "True")
{
connectionInfo.RDGatewayUsageMethod = ProtocolRDP.RDGatewayUsageMethod.Always;
}
else
{
connectionInfo.RDGatewayUsageMethod = ProtocolRDP.RDGatewayUsageMethod.Never;
}
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName").InnerText;
connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName").InnerText;
XmlNode passwordNode = logonCredentialsNode.SelectSingleNode("./password");
if (passwordNode.Attributes["storeAsClearText"].Value == "True")
{
connectionInfo.RDGatewayPassword = passwordNode.InnerText;
}
else
{
connectionInfo.Password = DecryptPassword(passwordNode.InnerText);
}
connectionInfo.RDGatewayDomain = gatewaySettingsNode.SelectSingleNode("./domain").InnerText;
// ./logonMethod
// ./localBypass
// ./credSharing
}
else
{
connectionInfo.Inheritance.RDGatewayUsageMethod = true;
connectionInfo.Inheritance.RDGatewayHostname = true;
connectionInfo.Inheritance.RDGatewayUsername = true;
connectionInfo.Inheritance.RDGatewayPassword = true;
connectionInfo.Inheritance.RDGatewayDomain = true;
}
XmlNode remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop");
if (remoteDesktopNode.Attributes["inherit"].Value == "None")
{
string resolutionString = Convert.ToString(remoteDesktopNode.SelectSingleNode("./size").InnerText.Replace(" ", ""));
try
{
connectionInfo.Resolution = (ProtocolRDP.RDPResolutions)Enum.Parse(typeof(ProtocolRDP.RDPResolutions), "Res" + resolutionString);
}
catch (ArgumentException)
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./sameSizeAsClientArea").InnerText == "True")
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./fullScreen").InnerText == "True")
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.Fullscreen;
}
connectionInfo.Colors = (ProtocolRDP.RDPColors)Enum.Parse(typeof(ProtocolRDP.RDPColors), remoteDesktopNode.SelectSingleNode("./colorDepth").InnerText);
}
else
{
connectionInfo.Inheritance.Resolution = true;
connectionInfo.Inheritance.Colors = true;
}
XmlNode localResourcesNode = xmlNode.SelectSingleNode("./localResources");
if (localResourcesNode.Attributes["inherit"].Value == "None")
{
switch (localResourcesNode.SelectSingleNode("./audioRedirection").InnerText)
{
case "0": // Bring to this computer
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.BringToThisComputer;
break;
case "1": // Leave at remote computer
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.LeaveAtRemoteComputer;
break;
case "2": // Do not play
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.DoNotPlay;
break;
}
// ./audioRedirectionQuality
// ./audioCaptureRedirection
switch (localResourcesNode.SelectSingleNode("./keyboardHook").InnerText)
{
case "0": // On the local computer
connectionInfo.RedirectKeys = false;
break;
case "1": // On the remote computer
connectionInfo.RedirectKeys = true;
break;
case "2": // In full screen mode only
connectionInfo.RedirectKeys = false;
break;
}
// ./redirectClipboard
connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode.SelectSingleNode("./redirectDrives").InnerText);
connectionInfo.RedirectPorts = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPorts").InnerText);
connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode.SelectSingleNode("./redirectPrinters").InnerText);
connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode.SelectSingleNode("./redirectSmartCards").InnerText);
}
else
{
connectionInfo.Inheritance.RedirectSound = true;
connectionInfo.Inheritance.RedirectKeys = true;
connectionInfo.Inheritance.RedirectDiskDrives = true;
connectionInfo.Inheritance.RedirectPorts = true;
connectionInfo.Inheritance.RedirectPrinters = true;
connectionInfo.Inheritance.RedirectSmartCards = true;
}
XmlNode securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings");
if (securitySettingsNode.Attributes["inherit"].Value == "None")
{
switch (securitySettingsNode.SelectSingleNode("./authentication").InnerText)
{
case "0": // No authentication
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.NoAuth;
break;
case "1": // Do not connect if authentication fails
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.AuthRequired;
break;
case "2": // Warn if authentication fails
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.WarnOnFailedAuth;
break;
}
}
else
{
connectionInfo.Inheritance.RDPAuthenticationLevel = true;
}
// ./displaySettings/thumbnailScale
// ./displaySettings/liveThumbnailUpdates
// ./displaySettings/showDisconnectedThumbnails
return connectionInfo;
}
private static string DecryptPassword(string ciphertext)
{
if (string.IsNullOrEmpty(ciphertext))
{
return null;
}
GCHandle gcHandle = new GCHandle();
NativeMethods.DATA_BLOB plaintextData = new NativeMethods.DATA_BLOB();
try
{
byte[] ciphertextArray = Convert.FromBase64String(ciphertext);
gcHandle = GCHandle.Alloc(ciphertextArray, GCHandleType.Pinned);
NativeMethods.DATA_BLOB ciphertextData = new NativeMethods.DATA_BLOB();
ciphertextData.cbData = ciphertextArray.Length;
ciphertextData.pbData = gcHandle.AddrOfPinnedObject();
NativeMethods.DATA_BLOB temp_optionalEntropy = new NativeMethods.DATA_BLOB();
IntPtr temp_promptStruct = IntPtr.Zero;
if (!NativeMethods.CryptUnprotectData(ref ciphertextData, null, ref temp_optionalEntropy, IntPtr.Zero, ref temp_promptStruct, 0, ref plaintextData))
{
return null;
}
int plaintextLength = (int) ((double) plaintextData.cbData / 2); // Char = 2 bytes
char[] plaintextArray = new char[plaintextLength - 1 + 1];
Marshal.Copy(plaintextData.pbData, plaintextArray, 0, plaintextLength);
return new string(plaintextArray);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage(message: "RemoteDesktopConnectionManager.DecryptPassword() failed.", ex: ex, logOnly: true);
return null;
}
finally
{
if (gcHandle.IsAllocated)
{
gcHandle.Free();
}
if (!(plaintextData.pbData == IntPtr.Zero))
{
NativeMethods.LocalFree(plaintextData.pbData);
}
}
}
// ReSharper disable once ClassNeverInstantiated.Local
private class NativeMethods
{
// ReSharper disable InconsistentNaming
// ReSharper disable IdentifierTypo
// ReSharper disable StringLiteralTypo
[DllImport("crypt32.dll", CharSet = CharSet.Unicode)]public static extern bool CryptUnprotectData(ref DATA_BLOB dataIn, string description, ref DATA_BLOB optionalEntropy, IntPtr reserved, ref IntPtr promptStruct, int flags, ref DATA_BLOB dataOut);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]public static extern void LocalFree(IntPtr ptr);
public struct DATA_BLOB
{
public int cbData;
public IntPtr pbData;
}
// ReSharper restore StringLiteralTypo
// ReSharper restore IdentifierTypo
// ReSharper restore InconsistentNaming
}
}
}

View File

@@ -0,0 +1,35 @@
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter
{
public void Import(object filePath, ContainerInfo destinationContainer)
{
var fileNameAsString = filePath as string;
if (fileNameAsString == null)
return;
if (File.Exists(fileNameAsString))
Import(fileNameAsString, destinationContainer);
}
public void Import(string filePath, ContainerInfo destinationContainer)
{
var dataProvider = new FileDataProvider(filePath);
var fileContent = dataProvider.Load();
var deserializer = new RemoteDesktopConnectionManagerDeserializer(fileContent);
var connectionTreeModel = deserializer.Deserialize();
var importedRootNode = connectionTreeModel.RootNodes.First();
if (importedRootNode == null) return;
var childrenToAdd = importedRootNode.Children.ToArray();
destinationContainer.AddChildRange(childrenToAdd);
}
}
}

View File

@@ -1,53 +1,42 @@
using System.Windows.Forms;
using System.IO;
using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.Connections;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
using mRemoteNG.Connection;
using mRemoteNG.Tree;
using mRemoteNG.Messages;
namespace mRemoteNG.Config.Import
{
// ReSharper disable once InconsistentNaming
public class mRemoteNGImporter
public class mRemoteNGImporter : IConnectionImporter
{
public static void Import(string fileName, TreeNode parentTreeNode)
public void Import(object filePath, ContainerInfo destinationContainer)
{
var filePathAsString = filePath as string;
if (filePathAsString == null)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
return;
}
if(File.Exists(filePathAsString))
Import(filePathAsString, destinationContainer);
else
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePathAsString}");
}
public void Import(string fileName, ContainerInfo destinationContainer)
{
var name = Path.GetFileNameWithoutExtension(fileName);
var treeNode = new TreeNode(name);
parentTreeNode.Nodes.Add(treeNode);
var dataProvider = new FileDataProvider(fileName);
var xmlString = dataProvider.Load();
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer(xmlString);
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(true);
var containerInfo = new ContainerInfo
{
TreeNode = treeNode,
Name = name,
IsContainer = true
};
containerInfo.Inheritance = new ConnectionInfoInheritance(containerInfo);
// We can only inherit from a container node, not the root node or connection nodes
var parent = parentTreeNode.Tag as ContainerInfo;
if (parent != null)
containerInfo.Parent = parent;
else
containerInfo.Inheritance.DisableInheritance();
treeNode.Name = name;
treeNode.Tag = containerInfo;
treeNode.ImageIndex = (int)TreeImageType.Container;
treeNode.SelectedImageIndex = (int)TreeImageType.Container;
var connectionsLoad = new ConnectionsLoader
{
ConnectionFileName = fileName,
RootTreeNode = treeNode,
ConnectionList = Runtime.ConnectionList,
ContainerList = Runtime.ContainerList
};
connectionsLoad.LoadConnections(true);
Runtime.ContainerList.Add(containerInfo);
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
rootImportContainer.Children.AddRange(connectionTreeModel.RootNodes.First().Children);
destinationContainer.AddChild(rootImportContainer);
}
}
}

View File

@@ -0,0 +1,82 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Root.PuttySessions;
namespace mRemoteNG.Config.Putty
{
public abstract class AbstractPuttySessionsProvider
{
public virtual RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo();
protected virtual List<PuttySessionInfo> Sessions => RootInfo.Children.OfType<PuttySessionInfo>().ToList();
#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);
foreach (var sessionName in GetSessionNamesToAdd(sessionNamesFromProvider))
{
var sessionInfo = GetSession(sessionName);
AddSession(sessionInfo);
}
foreach (var session in GetSessionToRemove(sessionNamesFromProvider))
{
RemoveSession(session);
}
RootInfo.SortRecursive();
return Sessions;
}
private IEnumerable<string> GetSessionNamesToAdd(IEnumerable<string> sessionNamesFromProvider)
{
var currentlyKnownSessionNames = Sessions.Select(session => session.Name);
var sessionNamesToAdd = sessionNamesFromProvider.Except(currentlyKnownSessionNames);
return sessionNamesToAdd;
}
private IEnumerable<PuttySessionInfo> GetSessionToRemove(IEnumerable<string> sessionNamesFromProvider)
{
var currentlyKnownSessionNames = Sessions.Select(session => session.Name);
var sessionNamesToRemove = currentlyKnownSessionNames.Except(sessionNamesFromProvider);
return Sessions.Where(session => sessionNamesToRemove.Contains(session.Name));
}
protected virtual void AddSession(PuttySessionInfo sessionInfo)
{
if (string.IsNullOrEmpty(sessionInfo?.Name) || Sessions.Any(child => child.Name == sessionInfo.Name))
return;
RootInfo.AddChild(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));
}
public virtual void StartWatcher() { }
public virtual void StopWatcher() { }
#endregion
public delegate void PuttySessionChangedEventHandler(object sender, PuttySessionChangedEventArgs e);
public event PuttySessionChangedEventHandler PuttySessionChanged;
protected virtual void RaiseSessionChangedEvent(PuttySessionChangedEventArgs args)
{
PuttySessionChanged?.Invoke(this, args);
}
public event NotifyCollectionChangedEventHandler PuttySessionsCollectionChanged;
protected void RaisePuttySessionCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
{
PuttySessionsCollectionChanged?.Invoke(this, args);
}
}
}

View File

@@ -1,150 +0,0 @@
using System.Collections.Generic;
using System;
using System.Windows.Forms;
using mRemoteNG.Tree;
using mRemoteNG.Connection;
namespace mRemoteNG.Config.Putty
{
public abstract class Provider
{
#region Public Methods
private TreeNode _rootTreeNode;
public TreeNode RootTreeNode
{
get
{
if (_rootTreeNode == null)
{
_rootTreeNode = CreateRootTreeNode();
}
return _rootTreeNode;
}
}
private Root.PuttySessions.PuttySessionsNodeInfo _rootInfo;
public Root.PuttySessions.PuttySessionsNodeInfo RootInfo
{
get
{
if (_rootInfo == null)
{
_rootInfo = CreateRootInfo();
}
return _rootInfo;
}
}
public abstract string[] GetSessionNames(bool raw = false);
public abstract PuttySessionInfo GetSession(string sessionName);
public virtual PuttySessionInfo[] GetSessions()
{
List<PuttySessionInfo> sessionList = new List<PuttySessionInfo>();
PuttySessionInfo sessionInfo = (PuttySessionInfo)default(ConnectionInfo);
foreach (string sessionName in GetSessionNames(true))
{
sessionInfo = GetSession(sessionName);
if (sessionInfo == null || string.IsNullOrEmpty(sessionInfo.Hostname))
{
continue;
}
sessionList.Add(sessionInfo);
}
return sessionList.ToArray();
}
public virtual void StartWatcher()
{
}
public virtual void StopWatcher()
{
}
#endregion
#region Public Events
public delegate void SessionChangedEventHandler(object sender, SessionChangedEventArgs e);
private SessionChangedEventHandler SessionChangedEvent;
public event SessionChangedEventHandler SessionChanged
{
add
{
SessionChangedEvent = (SessionChangedEventHandler) System.Delegate.Combine(SessionChangedEvent, value);
}
remove
{
SessionChangedEvent = (SessionChangedEventHandler) System.Delegate.Remove(SessionChangedEvent, value);
}
}
#endregion
#region Public Classes
public class SessionChangedEventArgs : EventArgs
{
}
#endregion
#region Protected Methods
private delegate TreeNode CreateRootTreeNodeDelegate();
protected virtual TreeNode CreateRootTreeNode()
{
TreeView treeView = ConnectionTree.TreeView;
if (treeView == null)
{
return null;
}
if (treeView.InvokeRequired)
{
return (TreeNode)treeView.Invoke(new CreateRootTreeNodeDelegate(CreateRootTreeNode));
}
TreeNode newTreeNode = new TreeNode();
RootInfo.TreeNode = newTreeNode;
newTreeNode.Name = _rootInfo.Name;
newTreeNode.Text = _rootInfo.Name;
newTreeNode.Tag = _rootInfo;
newTreeNode.ImageIndex = (int)TreeImageType.PuttySessions;
newTreeNode.SelectedImageIndex = (int)TreeImageType.PuttySessions;
return newTreeNode;
}
protected virtual Root.PuttySessions.PuttySessionsNodeInfo CreateRootInfo()
{
Root.PuttySessions.PuttySessionsNodeInfo newRootInfo = new Root.PuttySessions.PuttySessionsNodeInfo();
if (string.IsNullOrEmpty(Convert.ToString(mRemoteNG.Settings.Default.PuttySavedSessionsName)))
{
newRootInfo.Name = Language.strPuttySavedSessionsRootName;
}
else
{
newRootInfo.Name = Convert.ToString(mRemoteNG.Settings.Default.PuttySavedSessionsName);
}
if (string.IsNullOrEmpty(Convert.ToString(mRemoteNG.Settings.Default.PuttySavedSessionsPanel)))
{
newRootInfo.Panel = Language.strGeneral;
}
else
{
newRootInfo.Panel = Convert.ToString(mRemoteNG.Settings.Default.PuttySavedSessionsPanel);
}
return newRootInfo;
}
protected virtual void OnSessionChanged(SessionChangedEventArgs e)
{
if (SessionChangedEvent != null)
SessionChangedEvent(this, new SessionChangedEventArgs());
}
#endregion
}
}

View File

@@ -1,168 +0,0 @@
using Microsoft.Win32;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Messages;
using System;
using System.Collections.Generic;
using System.Management;
using System.Security.Principal;
namespace mRemoteNG.Config.Putty
{
public class RegistryProvider : Provider
{
#region Private Fields
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
private static ManagementEventWatcher _eventWatcher;
#endregion
#region Public Methods
public override string[] GetSessionNames(bool raw = false)
{
RegistryKey sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
if (sessionsKey == null)
{
return new string[] {};
}
List<string> sessionNames = new List<string>();
foreach (string sessionName in sessionsKey.GetSubKeyNames())
{
if (raw)
{
sessionNames.Add(sessionName);
}
else
{
sessionNames.Add(System.Web.HttpUtility.UrlDecode(sessionName.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");
}
}
return sessionNames.ToArray();
}
public override PuttySessionInfo GetSession(string sessionName)
{
RegistryKey sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
if (sessionsKey == null)
{
return null;
}
RegistryKey sessionKey = sessionsKey.OpenSubKey(sessionName);
if (sessionKey == null)
{
return null;
}
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
PuttySessionInfo sessionInfo = new PuttySessionInfo();
sessionInfo.PuttySession = sessionName;
sessionInfo.Name = sessionName;
sessionInfo.Hostname = Convert.ToString(sessionKey.GetValue("HostName"));
sessionInfo.Username = Convert.ToString(sessionKey.GetValue("UserName"));
string protocol = Convert.ToString(sessionKey.GetValue("Protocol"));
if (protocol == null)
{
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 = sessionKey.GetValue("SshProt");
if (sshVersionObject != null)
{
int sshVersion = Convert.ToInt32(sshVersionObject);
if (sshVersion >= 2)
{
sessionInfo.Protocol = ProtocolType.SSH2;
}
else
{
sessionInfo.Protocol = ProtocolType.SSH1;
}
}
else
{
sessionInfo.Protocol = ProtocolType.SSH2;
}
break;
case "telnet":
sessionInfo.Protocol = ProtocolType.Telnet;
break;
default:
return null;
}
sessionInfo.Port = Convert.ToInt32(sessionKey.GetValue("PortNumber"));
return sessionInfo;
}
public override void StartWatcher()
{
if (_eventWatcher != null)
{
return ;
}
try
{
string currentUserSid = WindowsIdentity.GetCurrent().User.Value;
string key = Convert.ToString(string.Join("\\", new[] {currentUserSid, PuttySessionsKey}).Replace("\\", "\\\\"));
WqlEventQuery query = new WqlEventQuery(string.Format("SELECT * FROM RegistryTreeChangeEvent WHERE Hive = \'HKEY_USERS\' AND RootPath = \'{0}\'", key));
_eventWatcher = new ManagementEventWatcher(query);
_eventWatcher.EventArrived += OnManagementEventArrived;
_eventWatcher.Start();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("PuttySessions.Watcher.StartWatching() failed.", ex, MessageClass.WarningMsg, true);
}
}
public override void StopWatcher()
{
if (_eventWatcher == null)
{
return ;
}
_eventWatcher.Stop();
_eventWatcher.Dispose();
_eventWatcher = null;
}
#endregion
#region Private Methods
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
{
OnSessionChanged(new SessionChangedEventArgs());
}
#endregion
}
}

View File

@@ -1,231 +0,0 @@
using mRemoteNG.Connection;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace mRemoteNG.Config.Putty
{
public class Sessions
{
#region Public Methods
private delegate void AddSessionsToTreeDelegate();
public static void AddSessionsToTree()
{
TreeView treeView = ConnectionTree.TreeView;
if (treeView == null)
{
return ;
}
if (treeView.InvokeRequired)
{
treeView.Invoke(new AddSessionsToTreeDelegate(AddSessionsToTree));
return ;
}
foreach (Provider provider in Providers)
{
TreeNode rootTreeNode = provider.RootTreeNode;
bool inUpdate = false;
List<ConnectionInfo> savedSessions = new List<ConnectionInfo>(provider.GetSessions());
if (!IsProviderEnabled(provider) || savedSessions == null || savedSessions.Count == 0)
{
if (rootTreeNode != null && treeView.Nodes.Contains(rootTreeNode))
{
treeView.BeginUpdate();
treeView.Nodes.Remove(rootTreeNode);
treeView.EndUpdate();
}
continue;
}
if (!treeView.Nodes.Contains(rootTreeNode))
{
if (!inUpdate)
{
treeView.BeginUpdate();
inUpdate = true;
}
treeView.Nodes.Add(rootTreeNode);
}
List<TreeNode> newTreeNodes = new List<TreeNode>();
foreach (PuttySessionInfo sessionInfo in savedSessions)
{
TreeNode treeNode = default(TreeNode);
bool isNewNode = false;
if (rootTreeNode.Nodes.ContainsKey(sessionInfo.Name))
{
treeNode = rootTreeNode.Nodes[sessionInfo.Name];
isNewNode = false;
}
else
{
treeNode = ConnectionTreeNode.AddNode(TreeNodeType.PuttySession, sessionInfo.Name);
if (treeNode == null)
{
continue;
}
treeNode.Name = treeNode.Text;
treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed;
treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;
isNewNode = true;
}
sessionInfo.RootPuttySessionsInfo = provider.RootInfo;
sessionInfo.TreeNode = treeNode;
//sessionInfo.IInheritable.TurnOffInheritanceCompletely();
treeNode.Tag = sessionInfo;
if (isNewNode)
{
newTreeNodes.Add(treeNode);
}
}
foreach (TreeNode treeNode in rootTreeNode.Nodes)
{
if (!savedSessions.Contains((ConnectionInfo)treeNode.Tag))
{
if (!inUpdate)
{
treeView.BeginUpdate();
inUpdate = true;
}
rootTreeNode.Nodes.Remove(treeNode);
}
}
if (!(newTreeNodes.Count == 0))
{
if (!inUpdate)
{
treeView.BeginUpdate();
inUpdate = true;
}
rootTreeNode.Nodes.AddRange(newTreeNodes.ToArray());
}
if (inUpdate)
{
ConnectionTree.Sort(rootTreeNode, SortOrder.Ascending);
rootTreeNode.Expand();
treeView.EndUpdate();
}
}
}
public static void StartWatcher()
{
foreach (Provider provider in Providers)
{
provider.StartWatcher();
provider.SessionChanged += SessionChanged;
}
}
public static void StopWatcher()
{
foreach (Provider provider in Providers)
{
provider.StopWatcher();
provider.SessionChanged -= SessionChanged;
}
}
public static void SessionChanged(object sender, Provider.SessionChangedEventArgs e)
{
AddSessionsToTree();
}
#endregion
#region Private Methods
private static List<Provider> _providers;
private static List<Provider> Providers
{
get
{
if (_providers == null || _providers.Count == 0)
{
AddProviders();
}
return _providers;
}
}
private static void AddProviders()
{
_providers = new List<Provider>();
_providers.Add(new RegistryProvider());
_providers.Add(new XmingProvider());
}
private static string[] GetSessionNames(bool raw = false)
{
List<string> sessionNames = new List<string>();
foreach (Provider provider in Providers)
{
if (!IsProviderEnabled(provider))
{
continue;
}
sessionNames.AddRange(provider.GetSessionNames(raw));
}
return sessionNames.ToArray();
}
private static bool IsProviderEnabled(Provider provider)
{
bool enabled = true;
if (PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.Xming)
{
if ((provider) is RegistryProvider)
{
enabled = false;
}
}
else
{
if ((provider) is XmingProvider)
{
enabled = false;
}
}
return enabled;
}
#endregion
#region Public Classes
public class SessionList : StringConverter
{
public static string[] Names
{
get
{
return GetSessionNames();
}
}
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
{
return new StandardValuesCollection(Names);
}
public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
#endregion
}
}

View File

@@ -0,0 +1,16 @@
using System;
using mRemoteNG.Connection;
namespace mRemoteNG.Config.Putty
{
public class PuttySessionChangedEventArgs : EventArgs
{
public PuttySessionInfo Session { get; set; }
public PuttySessionChangedEventArgs(PuttySessionInfo sessionChanged = null)
{
Session = sessionChanged;
}
}
}

View File

@@ -0,0 +1,156 @@
using mRemoteNG.Tools;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using mRemoteNG.Root.PuttySessions;
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 => _providers;
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
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 provider)
{
var rootTreeNode = provider.RootInfo;
provider.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 AddProvider(AbstractPuttySessionsProvider newProvider)
{
if (_providers.Contains(newProvider)) return;
_providers.Add(newProvider);
newProvider.PuttySessionsCollectionChanged += RaisePuttySessionCollectionChangedEvent;
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newProvider));
}
public void AddProviders(IEnumerable<AbstractPuttySessionsProvider> newProviders)
{
foreach (var provider in newProviders)
AddProvider(provider);
}
public void RemoveProvider(AbstractPuttySessionsProvider providerToRemove)
{
if (!_providers.Contains(providerToRemove)) return;
_providers.Remove(providerToRemove);
providerToRemove.PuttySessionsCollectionChanged -= RaisePuttySessionCollectionChangedEvent;
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, providerToRemove));
}
public void PuttySessionChanged(object sender, PuttySessionChangedEventArgs e)
{
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)
{
var enabled = true;
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 => Instance.GetSessionNames();
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;
}
}
#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);
}
}
}

View File

@@ -0,0 +1,122 @@
using Microsoft.Win32;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Messages;
using System;
using System.Collections.Generic;
using System.Management;
using System.Security.Principal;
using System.Web;
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)
{
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
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")));
}
if (raw && !sessionNames.Contains("Default%20Settings"))
sessionNames.Insert(0, "Default%20Settings");
else if (!sessionNames.Contains("Default Settings"))
sessionNames.Insert(0, "Default Settings");
return sessionNames.ToArray();
}
public override PuttySessionInfo GetSession(string sessionName)
{
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
if (sessionKey == null) return null;
sessionName = HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
var sessionInfo = new PuttySessionInfo
{
PuttySession = sessionName,
Name = sessionName,
Hostname = Convert.ToString(sessionKey.GetValue("HostName")),
Username = Convert.ToString(sessionKey.GetValue("UserName"))
};
var protocol = Convert.ToString(sessionKey.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":
var sshVersionObject = sessionKey.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(sessionKey.GetValue("PortNumber"));
return sessionInfo;
}
public override void StartWatcher()
{
if (_eventWatcher != null) return;
try
{
var currentUserSid = WindowsIdentity.GetCurrent().User?.Value;
var key = Convert.ToString(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, true);
}
}
public override void StopWatcher()
{
if (_eventWatcher == null) return;
_eventWatcher.Stop();
_eventWatcher.Dispose();
_eventWatcher = null;
}
#endregion
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
{
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
}
}
}

View File

@@ -5,44 +5,38 @@ using mRemoteNG.Messages;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using mRemoteNG.Root.PuttySessions;
namespace mRemoteNG.Config.Putty
{
public class XmingProvider : Provider
public class PuttySessionsXmingProvider : AbstractPuttySessionsProvider
{
#region Private Fields
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 RegistryProvider RegistryProvider = new RegistryProvider();
private static readonly PuttySessionsRegistryProvider PuttySessionsRegistryProvider = new PuttySessionsRegistryProvider();
private static FileSystemWatcher _eventWatcher;
#endregion
#region Public Methods
public override string[] GetSessionNames(bool raw = false)
{
string sessionsFolderPath = GetSessionsFolderPath();
var sessionsFolderPath = GetSessionsFolderPath();
if (!Directory.Exists(sessionsFolderPath))
{
return new string[] {};
}
List<string> sessionNames = new List<string>();
foreach (string sessionName in Directory.GetFiles(sessionsFolderPath))
var sessionNames = new List<string>();
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
{
string _sessionFileName = Path.GetFileName(sessionName);
if (raw)
{
sessionNames.Add(_sessionFileName);
}
else
{
sessionNames.Add(System.Web.HttpUtility.UrlDecode(_sessionFileName.Replace("+", "%2B")));
}
var sessionFileName = Path.GetFileName(sessionName);
sessionNames.Add(raw ? sessionFileName : System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
}
if (raw)
if (raw)
{
if (!sessionNames.Contains("Default%20Settings")) // Do not localize
{
@@ -57,13 +51,9 @@ namespace mRemoteNG.Config.Putty
}
}
List<string> registrySessionNames = new List<string>();
foreach (string sessionName in RegistryProvider.GetSessionNames(raw))
{
registrySessionNames.Add(string.Format(RegistrySessionNameFormat, sessionName));
}
sessionNames.AddRange(registrySessionNames);
var registrySessionNames = PuttySessionsRegistryProvider.GetSessionNames(raw).Select(sessionName => string.Format(RegistrySessionNameFormat, sessionName)).ToList();
sessionNames.AddRange(registrySessionNames);
sessionNames.Sort();
return sessionNames.ToArray();
@@ -71,38 +61,36 @@ namespace mRemoteNG.Config.Putty
public override PuttySessionInfo GetSession(string sessionName)
{
string registrySessionName = GetRegistrySessionName(sessionName);
var registrySessionName = GetRegistrySessionName(sessionName);
if (!string.IsNullOrEmpty(registrySessionName))
{
return ModifyRegistrySessionInfo(RegistryProvider.GetSession(registrySessionName));
return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
}
string sessionsFolderPath = GetSessionsFolderPath();
var sessionsFolderPath = GetSessionsFolderPath();
if (!Directory.Exists(sessionsFolderPath))
{
return null;
}
string sessionFile = Path.Combine(sessionsFolderPath, sessionName);
var sessionFile = Path.Combine(sessionsFolderPath, sessionName);
if (!File.Exists(sessionFile))
{
return null;
}
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
SessionFileReader sessionFileReader = new SessionFileReader(sessionFile);
PuttySessionInfo sessionInfo = new PuttySessionInfo();
sessionInfo.PuttySession = sessionName;
sessionInfo.Name = sessionName;
sessionInfo.Hostname = sessionFileReader.GetValue("HostName");
sessionInfo.Username = sessionFileReader.GetValue("UserName");
string protocol = sessionFileReader.GetValue("Protocol");
if (protocol == null)
{
protocol = "ssh";
}
switch (protocol.ToLowerInvariant())
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;
@@ -116,15 +104,8 @@ namespace mRemoteNG.Config.Putty
object sshVersionObject = sessionFileReader.GetValue("SshProt");
if (sshVersionObject != null)
{
int sshVersion = Convert.ToInt32(sshVersionObject);
if (sshVersion >= 2)
{
sessionInfo.Protocol = ProtocolType.SSH2;
}
else
{
sessionInfo.Protocol = ProtocolType.SSH1;
}
var sshVersion = Convert.ToInt32(sshVersionObject);
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
}
else
{
@@ -144,8 +125,8 @@ namespace mRemoteNG.Config.Putty
public override void StartWatcher()
{
RegistryProvider.StartWatcher();
RegistryProvider.SessionChanged += OnRegistrySessionChanged;
PuttySessionsRegistryProvider.StartWatcher();
PuttySessionsRegistryProvider.PuttySessionChanged += OnRegistrySessionChanged;
if (_eventWatcher != null)
{
@@ -154,9 +135,11 @@ namespace mRemoteNG.Config.Putty
try
{
_eventWatcher = new FileSystemWatcher(GetSessionsFolderPath());
_eventWatcher.NotifyFilter = (System.IO.NotifyFilters) (NotifyFilters.FileName | NotifyFilters.LastWrite);
_eventWatcher.Changed += OnFileSystemEventArrived;
_eventWatcher = new FileSystemWatcher(GetSessionsFolderPath())
{
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
};
_eventWatcher.Changed += OnFileSystemEventArrived;
_eventWatcher.Created += OnFileSystemEventArrived;
_eventWatcher.Deleted += OnFileSystemEventArrived;
_eventWatcher.Renamed += OnFileSystemEventArrived;
@@ -170,8 +153,8 @@ namespace mRemoteNG.Config.Putty
public override void StopWatcher()
{
RegistryProvider.StopWatcher();
RegistryProvider.SessionChanged -= OnRegistrySessionChanged;
PuttySessionsRegistryProvider.StopWatcher();
PuttySessionsRegistryProvider.PuttySessionChanged -= OnRegistrySessionChanged;
if (_eventWatcher == null)
{
@@ -186,43 +169,31 @@ namespace mRemoteNG.Config.Putty
#region Private Methods
private static string GetPuttyConfPath()
{
string puttyPath = "";
if (mRemoteNG.Settings.Default.UseCustomPuttyPath)
{
puttyPath = Convert.ToString(mRemoteNG.Settings.Default.CustomPuttyPath);
}
else
{
puttyPath = App.Info.GeneralAppInfo.PuttyPath;
}
var puttyPath = "";
puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? Convert.ToString(mRemoteNG.Settings.Default.CustomPuttyPath) : App.Info.GeneralAppInfo.PuttyPath;
return Path.Combine(Path.GetDirectoryName(puttyPath), "putty.conf");
}
private static string GetSessionsFolderPath()
{
string puttyConfPath = GetPuttyConfPath();
PuttyConfFileReader sessionFileReader = new PuttyConfFileReader(puttyConfPath);
string basePath = Environment.ExpandEnvironmentVariables(sessionFileReader.GetValue("sshk&sess"));
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)
{
Regex regex = new Regex(RegistrySessionNamePattern);
MatchCollection matches = regex.Matches(sessionName);
var regex = new Regex(RegistrySessionNamePattern);
var matches = regex.Matches(sessionName);
if (matches.Count < 1)
{
return string.Empty;
}
GroupCollection groups = matches[0].Groups;
if (groups.Count < 1)
{
return string.Empty; // This should always include at least one item, but check anyway
}
return groups[1].Value;
var groups = matches[0].Groups;
return groups.Count < 1 ? string.Empty : groups[1].Value;
}
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
@@ -234,12 +205,12 @@ namespace mRemoteNG.Config.Putty
private void OnFileSystemEventArrived(object sender, FileSystemEventArgs e)
{
OnSessionChanged(new SessionChangedEventArgs());
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
}
private void OnRegistrySessionChanged(object sender, SessionChangedEventArgs e)
private void OnRegistrySessionChanged(object sender, PuttySessionChangedEventArgs e)
{
OnSessionChanged(new SessionChangedEventArgs());
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
}
#endregion
@@ -264,12 +235,11 @@ namespace mRemoteNG.Config.Putty
{
return ;
}
using (StreamReader streamReader = new StreamReader(_puttyConfFile))
using (var streamReader = new StreamReader(_puttyConfFile))
{
string line = "";
do
do
{
line = streamReader.ReadLine();
var line = streamReader.ReadLine();
if (line == null)
{
break;
@@ -283,7 +253,7 @@ namespace mRemoteNG.Config.Putty
{
continue; // Comment
}
string[] parts = line.Split(new char[] {'='}, 2);
var parts = line.Split(new[] {'='}, 2);
if (parts.Length < 2)
{
continue;
@@ -309,11 +279,7 @@ namespace mRemoteNG.Config.Putty
{
LoadConfiguration();
}
if (!_configuration.ContainsKey(setting))
{
return string.Empty;
}
return _configuration[setting];
return !_configuration.ContainsKey(setting) ? string.Empty : _configuration[setting];
}
}
@@ -339,15 +305,14 @@ namespace mRemoteNG.Config.Putty
}
using (StreamReader streamReader = new StreamReader(_sessionFile))
{
string line = "";
do
do
{
line = streamReader.ReadLine();
var line = streamReader.ReadLine();
if (line == null)
{
break;
}
string[] parts = line.Split(new char[] {'\\'});
var parts = line.Split('\\');
if (parts.Length < 2)
{
continue;
@@ -369,11 +334,7 @@ namespace mRemoteNG.Config.Putty
{
LoadSessionInfo();
}
if (!_sessionInfo.ContainsKey(setting))
{
return string.Empty;
}
return _sessionInfo[setting];
return !_sessionInfo.ContainsKey(setting) ? string.Empty : _sessionInfo[setting];
}
}
#endregion

View File

@@ -0,0 +1,88 @@
using System;
using System.DirectoryServices;
using System.Text.RegularExpressions;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class ActiveDirectoryDeserializer : IDeserializer
{
private readonly string _ldapPath;
public ActiveDirectoryDeserializer(string ldapPath)
{
_ldapPath = ldapPath;
}
public ConnectionTreeModel Deserialize()
{
var connectionTreeModel = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
connectionTreeModel.AddRootNode(root);
ImportContainers(_ldapPath, root);
return connectionTreeModel;
}
private void ImportContainers(string ldapPath, ContainerInfo parentContainer)
{
var match = Regex.Match(ldapPath, "ou=([^,]*)", RegexOptions.IgnoreCase);
var name = match.Success ? match.Groups[1].Captures[0].Value : Language.strActiveDirectory;
var newContainer = new ContainerInfo {Name = name};
parentContainer.AddChild(newContainer);
ImportComputers(ldapPath, newContainer);
}
private void ImportComputers(string ldapPath, ContainerInfo parentContainer)
{
try
{
const string ldapFilter = "(objectClass=computer)";
using (var ldapSearcher = new DirectorySearcher())
{
ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath);
ldapSearcher.Filter = ldapFilter;
ldapSearcher.SearchScope = SearchScope.OneLevel;
ldapSearcher.PropertiesToLoad.AddRange(new[] { "securityEquals", "cn" });
var ldapResults = ldapSearcher.FindAll();
foreach (SearchResult ldapResult in ldapResults)
{
using (var directoryEntry = ldapResult.GetDirectoryEntry())
DeserializeConnection(directoryEntry, parentContainer);
}
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex, logOnly: true);
}
}
private void DeserializeConnection(DirectoryEntry directoryEntry, ContainerInfo parentContainer)
{
var displayName = Convert.ToString(directoryEntry.Properties["cn"].Value);
var description = Convert.ToString(directoryEntry.Properties["Description"].Value);
var hostName = Convert.ToString(directoryEntry.Properties["dNSHostName"].Value);
var newConnectionInfo = new ConnectionInfo
{
Name = displayName,
Hostname = hostName,
Description = description
};
newConnectionInfo.Inheritance.TurnOnInheritanceCompletely();
newConnectionInfo.Inheritance.Description = false;
parentContainer.AddChild(newConnectionInfo);
}
}
}

View File

@@ -0,0 +1,141 @@
using System;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class CsvConnectionsSerializerMremotengFormat : ISerializer<string>
{
private string _csv = "";
public Save SaveSecurity { get; set; }
public string Serialize(ConnectionTreeModel connectionTreeModel)
{
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public string Serialize(ConnectionInfo serializationTarget)
{
_csv = "";
WriteCsvHeader();
SerializeNodesRecursive(serializationTarget);
return _csv;
}
private void WriteCsvHeader()
{
var csvHeader = string.Empty;
csvHeader += "Name;Folder;Description;Icon;Panel;";
if (SaveSecurity.Username)
csvHeader += "Username;";
if (SaveSecurity.Password)
csvHeader += "Password;";
if (SaveSecurity.Domain)
csvHeader += "Domain;";
csvHeader += "Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;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 (SaveSecurity.Inheritance)
csvHeader += "InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;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";
_csv += csvHeader;
}
private void SerializeNodesRecursive(ConnectionInfo node)
{
var nodeAsContainer = node as ContainerInfo;
if (nodeAsContainer != null)
{
foreach (var child in nodeAsContainer.Children)
{
if (child is ContainerInfo)
SerializeNodesRecursive((ContainerInfo) child);
else
SerializeConnectionInfo(child);
}
}
else
SerializeConnectionInfo(node);
}
private void SerializeConnectionInfo(ConnectionInfo con)
{
var nodePath = con.TreeNode.FullPath;
var firstSlash = nodePath.IndexOf("\\", StringComparison.Ordinal);
nodePath = nodePath.Remove(0, firstSlash + 1);
var lastSlash = nodePath.LastIndexOf("\\", StringComparison.Ordinal);
nodePath = lastSlash > 0 ? nodePath.Remove(lastSlash) : "";
var csvLine = Environment.NewLine;
csvLine += con.Name + ";" + nodePath + ";" + con.Description + ";" + con.Icon + ";" + con.Panel + ";";
if (SaveSecurity.Username)
csvLine += con.Username + ";";
if (SaveSecurity.Password)
csvLine += con.Password + ";";
if (SaveSecurity.Domain)
csvLine += con.Domain + ";";
csvLine += con.Hostname + ";" + con.Protocol + ";" + con.PuttySession + ";" + Convert.ToString(con.Port) + ";" + Convert.ToString(con.UseConsoleSession) + ";" + Convert.ToString(con.UseCredSsp) + ";" + con.RenderingEngine + ";" + con.ICAEncryptionStrength + ";" + con.RDPAuthenticationLevel + ";" + con.LoadBalanceInfo + ";" + con.Colors + ";" + con.Resolution + ";" + Convert.ToString(con.AutomaticResize) + ";" + Convert.ToString(con.DisplayWallpaper) + ";" + Convert.ToString(con.DisplayThemes) + ";" + Convert.ToString(con.EnableFontSmoothing) + ";" + Convert.ToString(con.EnableDesktopComposition) + ";" + Convert.ToString(con.CacheBitmaps) + ";" + Convert.ToString(con.RedirectDiskDrives) + ";" + Convert.ToString(con.RedirectPorts) + ";" + Convert.ToString(con.RedirectPrinters) + ";" + Convert.ToString(con.RedirectSmartCards) + ";" + con.RedirectSound + ";" + Convert.ToString(con.RedirectKeys) + ";" + con.PreExtApp + ";" + con.PostExtApp + ";" + con.MacAddress + ";" + con.UserField + ";" + con.ExtApp + ";" + con.VNCCompression + ";" + con.VNCEncoding + ";" + con.VNCAuthMode + ";" + con.VNCProxyType + ";" + con.VNCProxyIP + ";" + Convert.ToString(con.VNCProxyPort) + ";" + con.VNCProxyUsername + ";" + con.VNCProxyPassword + ";" + con.VNCColors + ";" + con.VNCSmartSizeMode + ";" + Convert.ToString(con.VNCViewOnly) + ";";
if (SaveSecurity.Inheritance)
{
csvLine += con.Inheritance.CacheBitmaps + ";" +
con.Inheritance.Colors + ";" +
con.Inheritance.Description + ";" +
con.Inheritance.DisplayThemes + ";" +
con.Inheritance.DisplayWallpaper + ";" +
con.Inheritance.EnableFontSmoothing + ";" +
con.Inheritance.EnableDesktopComposition + ";" +
con.Inheritance.Domain + ";" +
con.Inheritance.Icon + ";" +
con.Inheritance.Panel + ";" +
con.Inheritance.Password + ";" +
con.Inheritance.Port + ";" +
con.Inheritance.Protocol + ";" +
con.Inheritance.PuttySession + ";" +
con.Inheritance.RedirectDiskDrives + ";" +
con.Inheritance.RedirectKeys + ";" +
con.Inheritance.RedirectPorts + ";" +
con.Inheritance.RedirectPrinters + ";" +
con.Inheritance.RedirectSmartCards + ";" +
con.Inheritance.RedirectSound + ";" +
con.Inheritance.Resolution + ";" +
con.Inheritance.AutomaticResize + ";" +
con.Inheritance.UseConsoleSession + ";" +
con.Inheritance.UseCredSsp + ";" +
con.Inheritance.RenderingEngine + ";" +
con.Inheritance.Username + ";" +
con.Inheritance.ICAEncryptionStrength + ";" +
con.Inheritance.RDPAuthenticationLevel + ";" +
con.Inheritance.LoadBalanceInfo + ";" +
con.Inheritance.PreExtApp + ";" +
con.Inheritance.PostExtApp + ";" +
con.Inheritance.MacAddress + ";" +
con.Inheritance.UserField + ";" +
con.Inheritance.ExtApp + ";" +
con.Inheritance.VNCCompression + ";" +
con.Inheritance.VNCEncoding + ";" +
con.Inheritance.VNCAuthMode + ";" +
con.Inheritance.VNCProxyType + ";" +
con.Inheritance.VNCProxyIP + ";" +
con.Inheritance.VNCProxyPort + ";" +
con.Inheritance.VNCProxyUsername + ";" +
con.Inheritance.VNCProxyPassword + ";" +
con.Inheritance.VNCColors + ";" +
con.Inheritance.VNCSmartSizeMode + ";" +
con.Inheritance.VNCViewOnly;
}
_csv += csvLine;
}
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class CsvConnectionsSerializerRemoteDesktop2008Format : ISerializer<string>
{
private string _csv = "";
public Save SaveSecurity { get; set; }
public string Serialize(ConnectionTreeModel connectionTreeModel)
{
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public string Serialize(ConnectionInfo serializationTarget)
{
_csv = "";
SerializeNodesRecursive(serializationTarget);
return _csv;
}
private void SerializeNodesRecursive(ConnectionInfo node)
{
var nodeAsContainer = node as ContainerInfo;
if (nodeAsContainer != null)
{
foreach (var child in nodeAsContainer.Children)
{
if (child is ContainerInfo)
SerializeNodesRecursive((ContainerInfo)child);
else if (child.Protocol == ProtocolType.RDP)
SerializeConnectionInfo(child);
}
}
else if (node.Protocol == ProtocolType.RDP)
SerializeConnectionInfo(node);
}
private void SerializeConnectionInfo(ConnectionInfo con)
{
var nodePath = con.TreeNode.FullPath;
var firstSlash = nodePath.IndexOf("\\", StringComparison.Ordinal);
nodePath = nodePath.Remove(0, firstSlash + 1);
var lastSlash = nodePath.LastIndexOf("\\", StringComparison.Ordinal);
nodePath = lastSlash > 0 ? nodePath.Remove(lastSlash) : "";
_csv += con.Name + ";" + con.Hostname + ";" + con.MacAddress + ";;" + con.Port + ";" + con.UseConsoleSession + ";" + nodePath + Environment.NewLine;
}
}
}

View File

@@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class DataTableDeserializer : IDeserializer
{
private readonly DataTable _dataTable;
public DataTableDeserializer(DataTable dataTable)
{
_dataTable = dataTable;
}
public DataTableDeserializer(IDataReader sqlDataReader)
{
_dataTable = new DataTable();
_dataTable.Load(sqlDataReader);
}
public ConnectionTreeModel Deserialize()
{
var connectionList = CreateNodesFromTable();
var connectionTreeModel = CreateNodeHierarchy(connectionList);
return connectionTreeModel;
}
private List<ConnectionInfo> CreateNodesFromTable()
{
var nodeList = new List<ConnectionInfo>();
foreach (DataRow row in _dataTable.Rows)
{
if ((string)row["Type"] == "Connection")
nodeList.Add(DeserializeConnectionInfo(row));
else if ((string)row["Type"] == "Container")
nodeList.Add(DeserializeContainerInfo(row));
}
return nodeList;
}
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
{
var connectionInfo = new ConnectionInfo();
PopulateConnectionInfoFromDatarow(row, connectionInfo);
return connectionInfo;
}
private ContainerInfo DeserializeContainerInfo(DataRow row)
{
var containerInfo = new ContainerInfo();
PopulateConnectionInfoFromDatarow(row, containerInfo);
return containerInfo;
}
private void PopulateConnectionInfoFromDatarow(DataRow dataRow, ConnectionInfo connectionInfo)
{
connectionInfo.Name = (string)dataRow["Name"];
connectionInfo.ConstantID = (string)dataRow["ConstantID"];
//connectionInfo.Parent.ConstantID = (string)dataRow["ParentID"];
//connectionInfo is ContainerInfo ? ((ContainerInfo)connectionInfo).IsExpanded.ToString() : "" = dataRow["Expanded"];
connectionInfo.Description = (string)dataRow["Description"];
connectionInfo.Icon = (string)dataRow["Icon"];
connectionInfo.Panel = (string)dataRow["Panel"];
connectionInfo.Username = (string)dataRow["Username"];
connectionInfo.Domain = (string)dataRow["DomainName"];
connectionInfo.Password = (string)dataRow["Password"];
connectionInfo.Hostname = (string)dataRow["Hostname"];
connectionInfo.Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), (string)dataRow["Protocol"]);
connectionInfo.PuttySession = (string)dataRow["PuttySession"];
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 = (ProtocolICA.EncryptionStrength)Enum.Parse(typeof(ProtocolICA.EncryptionStrength), (string)dataRow["ICAEncryptionStrength"]);
connectionInfo.RDPAuthenticationLevel = (ProtocolRDP.AuthenticationLevel)Enum.Parse(typeof(ProtocolRDP.AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
connectionInfo.Colors = (ProtocolRDP.RDPColors)Enum.Parse(typeof(ProtocolRDP.RDPColors) ,(string)dataRow["Colors"]);
connectionInfo.Resolution = (ProtocolRDP.RDPResolutions)Enum.Parse(typeof(ProtocolRDP.RDPResolutions), (string)dataRow["Resolution"]);
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
connectionInfo.EnableFontSmoothing = (bool)dataRow["EnableFontSmoothing"];
connectionInfo.EnableDesktopComposition = (bool)dataRow["EnableDesktopComposition"];
connectionInfo.CacheBitmaps = (bool)dataRow["CacheBitmaps"];
connectionInfo.RedirectDiskDrives = (bool)dataRow["RedirectDiskDrives"];
connectionInfo.RedirectPorts = (bool)dataRow["RedirectPorts"];
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
connectionInfo.RedirectSound = (ProtocolRDP.RDPSounds)Enum.Parse(typeof(ProtocolRDP.RDPSounds), (string)dataRow["RedirectSound"]);
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
connectionInfo.PleaseConnect = (bool)dataRow["Connected"];
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.VNCProxyIP = (string)dataRow["VNCProxyIP"];
connectionInfo.VNCProxyPort = (int)dataRow["VNCProxyPort"];
connectionInfo.VNCProxyUsername = (string)dataRow["VNCProxyUsername"];
connectionInfo.VNCProxyPassword = (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.VNCViewOnly = (bool)dataRow["VNCViewOnly"];
connectionInfo.RDGatewayUsageMethod = (ProtocolRDP.RDGatewayUsageMethod)Enum.Parse(typeof(ProtocolRDP.RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
connectionInfo.RDGatewayUseConnectionCredentials = (ProtocolRDP.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(ProtocolRDP.RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
connectionInfo.RDGatewayPassword = (string)dataRow["RDGatewayPassword"];
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
connectionInfo.Inheritance.CacheBitmaps = (bool)dataRow["InheritCacheBitmaps"];
connectionInfo.Inheritance.Colors = (bool)dataRow["InheritColors"];
connectionInfo.Inheritance.Description = (bool)dataRow["InheritDescription"];
connectionInfo.Inheritance.DisplayThemes = (bool)dataRow["InheritDisplayThemes"];
connectionInfo.Inheritance.DisplayWallpaper = (bool)dataRow["InheritDisplayWallpaper"];
connectionInfo.Inheritance.EnableFontSmoothing = (bool)dataRow["InheritEnableFontSmoothing"];
connectionInfo.Inheritance.EnableDesktopComposition = (bool)dataRow["InheritEnableDesktopComposition"];
connectionInfo.Inheritance.Domain = (bool)dataRow["InheritDomain"];
connectionInfo.Inheritance.Icon = (bool)dataRow["InheritIcon"];
connectionInfo.Inheritance.Panel = (bool)dataRow["InheritPanel"];
connectionInfo.Inheritance.Password = (bool)dataRow["InheritPassword"];
connectionInfo.Inheritance.Port = (bool)dataRow["InheritPort"];
connectionInfo.Inheritance.Protocol = (bool)dataRow["InheritProtocol"];
connectionInfo.Inheritance.PuttySession = (bool)dataRow["InheritPuttySession"];
connectionInfo.Inheritance.RedirectDiskDrives = (bool)dataRow["InheritRedirectDiskDrives"];
connectionInfo.Inheritance.RedirectKeys = (bool)dataRow["InheritRedirectKeys"];
connectionInfo.Inheritance.RedirectPorts = (bool)dataRow["InheritRedirectPorts"];
connectionInfo.Inheritance.RedirectPrinters = (bool)dataRow["InheritRedirectPrinters"];
connectionInfo.Inheritance.RedirectSmartCards = (bool)dataRow["InheritRedirectSmartCards"];
connectionInfo.Inheritance.RedirectSound = (bool)dataRow["InheritRedirectSound"];
connectionInfo.Inheritance.Resolution = (bool)dataRow["InheritResolution"];
connectionInfo.Inheritance.AutomaticResize = (bool)dataRow["InheritAutomaticResize"];
connectionInfo.Inheritance.UseConsoleSession = (bool)dataRow["InheritUseConsoleSession"];
connectionInfo.Inheritance.UseCredSsp = (bool)dataRow["InheritUseCredSsp"];
connectionInfo.Inheritance.RenderingEngine = (bool)dataRow["InheritRenderingEngine"];
connectionInfo.Inheritance.Username = (bool)dataRow["InheritUsername"];
connectionInfo.Inheritance.ICAEncryptionStrength = (bool)dataRow["InheritICAEncryptionStrength"];
connectionInfo.Inheritance.RDPAuthenticationLevel = (bool)dataRow["InheritRDPAuthenticationLevel"];
connectionInfo.Inheritance.LoadBalanceInfo = (bool)dataRow["InheritLoadBalanceInfo"];
connectionInfo.Inheritance.PreExtApp = (bool)dataRow["InheritPreExtApp"];
connectionInfo.Inheritance.PostExtApp = (bool)dataRow["InheritPostExtApp"];
connectionInfo.Inheritance.MacAddress = (bool)dataRow["InheritMacAddress"];
connectionInfo.Inheritance.UserField = (bool)dataRow["InheritUserField"];
connectionInfo.Inheritance.ExtApp = (bool)dataRow["InheritExtApp"];
connectionInfo.Inheritance.VNCCompression = (bool)dataRow["InheritVNCCompression"];
connectionInfo.Inheritance.VNCEncoding = (bool)dataRow["InheritVNCEncoding"];
connectionInfo.Inheritance.VNCAuthMode = (bool)dataRow["InheritVNCAuthMode"];
connectionInfo.Inheritance.VNCProxyType = (bool)dataRow["InheritVNCProxyType"];
connectionInfo.Inheritance.VNCProxyIP = (bool)dataRow["InheritVNCProxyIP"];
connectionInfo.Inheritance.VNCProxyPort = (bool)dataRow["InheritVNCProxyPort"];
connectionInfo.Inheritance.VNCProxyUsername = (bool)dataRow["InheritVNCProxyUsername"];
connectionInfo.Inheritance.VNCProxyPassword = (bool)dataRow["InheritVNCProxyPassword"];
connectionInfo.Inheritance.VNCColors = (bool)dataRow["InheritVNCColors"];
connectionInfo.Inheritance.VNCSmartSizeMode = (bool)dataRow["InheritVNCSmartSizeMode"];
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.RDGatewayUsername = (bool)dataRow["InheritRDGatewayUsername"];
connectionInfo.Inheritance.RDGatewayPassword = (bool)dataRow["InheritRDGatewayPassword"];
connectionInfo.Inheritance.RDGatewayDomain = (bool)dataRow["InheritRDGatewayDomain"];
}
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList)
{
var connectionTreeModel = new ConnectionTreeModel();
var rootNode = new RootNodeInfo(RootNodeType.Connection) {ConstantID = "0"};
connectionTreeModel.AddRootNode(rootNode);
foreach (DataRow row in _dataTable.Rows)
{
var id = (string) row["ConstantID"];
var connectionInfo = connectionList.First(node => node.ConstantID == id);
var parentId = (string) row["ParentID"];
if (parentId == "0")
rootNode.AddChild(connectionInfo);
else
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
}
return connectionTreeModel;
}
}
}

View File

@@ -0,0 +1,350 @@
using System;
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class DataTableSerializer : ISerializer<DataTable>
{
private DataTable _dataTable;
private const string TableName = "tblCons";
private readonly Save _saveSecurity;
private int _currentNodeIndex;
public DataTableSerializer(Save saveSecurity)
{
_saveSecurity = saveSecurity;
}
public DataTable Serialize(ConnectionTreeModel connectionTreeModel)
{
var rootNode = (RootNodeInfo)connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public DataTable Serialize(ConnectionInfo serializationTarget)
{
_dataTable = new DataTable(TableName);
CreateSchema();
SetPrimaryKey();
_currentNodeIndex = 0;
SerializeNodesRecursive(serializationTarget);
return _dataTable;
}
private void CreateSchema()
{
_dataTable.Columns.Add("ID", typeof(int));
_dataTable.Columns[0].AutoIncrement = true;
_dataTable.Columns.Add("ConstantID", typeof(string));
_dataTable.Columns.Add("PositionID", typeof(int));
_dataTable.Columns.Add("ParentID", typeof(string));
_dataTable.Columns.Add("LastChange", typeof(SqlDateTime));
_dataTable.Columns.Add("Name", typeof(string));
_dataTable.Columns.Add("Type", typeof(string));
_dataTable.Columns.Add("Expanded", typeof(bool));
_dataTable.Columns.Add("Description", typeof(string));
_dataTable.Columns.Add("Icon", typeof(string));
_dataTable.Columns.Add("Panel", typeof(string));
_dataTable.Columns.Add("Username", typeof(string));
_dataTable.Columns.Add("DomainName", typeof(string));
_dataTable.Columns.Add("Password", typeof(string));
_dataTable.Columns.Add("Hostname", typeof(string));
_dataTable.Columns.Add("Protocol", typeof(string));
_dataTable.Columns.Add("PuttySession", typeof(string));
_dataTable.Columns.Add("Port", typeof(int));
_dataTable.Columns.Add("ConnectToConsole", typeof(bool));
_dataTable.Columns.Add("UseCredSsp", typeof(bool));
_dataTable.Columns.Add("RenderingEngine", typeof(string));
_dataTable.Columns.Add("ICAEncryptionStrength", typeof(string));
_dataTable.Columns.Add("RDPAuthenticationLevel", typeof(string));
_dataTable.Columns.Add("Colors", typeof(string));
_dataTable.Columns.Add("Resolution", typeof(string));
_dataTable.Columns.Add("DisplayWallpaper", typeof(bool));
_dataTable.Columns.Add("DisplayThemes", typeof(bool));
_dataTable.Columns.Add("EnableFontSmoothing", typeof(bool));
_dataTable.Columns.Add("EnableDesktopComposition", typeof(bool));
_dataTable.Columns.Add("CacheBitmaps", typeof(bool));
_dataTable.Columns.Add("RedirectDiskDrives", typeof(bool));
_dataTable.Columns.Add("RedirectPorts", typeof(bool));
_dataTable.Columns.Add("RedirectPrinters", typeof(bool));
_dataTable.Columns.Add("RedirectSmartCards", typeof(bool));
_dataTable.Columns.Add("RedirectSound", typeof(string));
_dataTable.Columns.Add("RedirectKeys", typeof(bool));
_dataTable.Columns.Add("Connected", typeof(bool));
_dataTable.Columns.Add("PreExtApp", typeof(string));
_dataTable.Columns.Add("PostExtApp", typeof(string));
_dataTable.Columns.Add("MacAddress", typeof(string));
_dataTable.Columns.Add("UserField", typeof(string));
_dataTable.Columns.Add("ExtApp", typeof(string));
_dataTable.Columns.Add("VNCCompression", typeof(string));
_dataTable.Columns.Add("VNCEncoding", typeof(string));
_dataTable.Columns.Add("VNCAuthMode", typeof(string));
_dataTable.Columns.Add("VNCProxyType", typeof(string));
_dataTable.Columns.Add("VNCProxyIP", typeof(string));
_dataTable.Columns.Add("VNCProxyPort", typeof(int));
_dataTable.Columns.Add("VNCProxyUsername", typeof(string));
_dataTable.Columns.Add("VNCProxyPassword", typeof(string));
_dataTable.Columns.Add("VNCColors", typeof(string));
_dataTable.Columns.Add("VNCSmartSizeMode", typeof(string));
_dataTable.Columns.Add("VNCViewOnly", typeof(bool));
_dataTable.Columns.Add("RDGatewayUsageMethod", typeof(string));
_dataTable.Columns.Add("RDGatewayHostname", typeof(string));
_dataTable.Columns.Add("RDGatewayUseConnectionCredentials", typeof(string));
_dataTable.Columns.Add("RDGatewayUsername", typeof(string));
_dataTable.Columns.Add("RDGatewayPassword", typeof(string));
_dataTable.Columns.Add("RDGatewayDomain", typeof(string));
_dataTable.Columns.Add("InheritCacheBitmaps", typeof(bool));
_dataTable.Columns.Add("InheritColors", typeof(bool));
_dataTable.Columns.Add("InheritDescription", typeof(bool));
_dataTable.Columns.Add("InheritDisplayThemes", typeof(bool));
_dataTable.Columns.Add("InheritDisplayWallpaper", typeof(bool));
_dataTable.Columns.Add("InheritEnableFontSmoothing", typeof(bool));
_dataTable.Columns.Add("InheritEnableDesktopComposition", typeof(bool));
_dataTable.Columns.Add("InheritDomain", typeof(bool));
_dataTable.Columns.Add("InheritIcon", typeof(bool));
_dataTable.Columns.Add("InheritPanel", typeof(bool));
_dataTable.Columns.Add("InheritPassword", typeof(bool));
_dataTable.Columns.Add("InheritPort", typeof(bool));
_dataTable.Columns.Add("InheritProtocol", typeof(bool));
_dataTable.Columns.Add("InheritPuttySession", typeof(bool));
_dataTable.Columns.Add("InheritRedirectDiskDrives", typeof(bool));
_dataTable.Columns.Add("InheritRedirectKeys", typeof(bool));
_dataTable.Columns.Add("InheritRedirectPorts", typeof(bool));
_dataTable.Columns.Add("InheritRedirectPrinters", typeof(bool));
_dataTable.Columns.Add("InheritRedirectSmartCards", typeof(bool));
_dataTable.Columns.Add("InheritRedirectSound", typeof(bool));
_dataTable.Columns.Add("InheritResolution", typeof(bool));
_dataTable.Columns.Add("InheritUseConsoleSession", typeof(bool));
_dataTable.Columns.Add("InheritUseCredSsp", typeof(bool));
_dataTable.Columns.Add("InheritRenderingEngine", typeof(bool));
_dataTable.Columns.Add("InheritICAEncryptionStrength", typeof(bool));
_dataTable.Columns.Add("InheritRDPAuthenticationLevel", typeof(bool));
_dataTable.Columns.Add("InheritUsername", typeof(bool));
_dataTable.Columns.Add("InheritPreExtApp", typeof(bool));
_dataTable.Columns.Add("InheritPostExtApp", typeof(bool));
_dataTable.Columns.Add("InheritMacAddress", typeof(bool));
_dataTable.Columns.Add("InheritUserField", typeof(bool));
_dataTable.Columns.Add("InheritExtApp", typeof(bool));
_dataTable.Columns.Add("InheritVNCCompression", typeof(bool));
_dataTable.Columns.Add("InheritVNCEncoding", typeof(bool));
_dataTable.Columns.Add("InheritVNCAuthMode", typeof(bool));
_dataTable.Columns.Add("InheritVNCProxyType", typeof(bool));
_dataTable.Columns.Add("InheritVNCProxyIP", typeof(bool));
_dataTable.Columns.Add("InheritVNCProxyPort", typeof(bool));
_dataTable.Columns.Add("InheritVNCProxyUsername", typeof(bool));
_dataTable.Columns.Add("InheritVNCProxyPassword", typeof(bool));
_dataTable.Columns.Add("InheritVNCColors", typeof(bool));
_dataTable.Columns.Add("InheritVNCSmartSizeMode", typeof(bool));
_dataTable.Columns.Add("InheritVNCViewOnly", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayUsageMethod", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayHostname", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayUseConnectionCredentials", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayUsername", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayPassword", typeof(bool));
_dataTable.Columns.Add("InheritRDGatewayDomain", typeof(bool));
_dataTable.Columns.Add("LoadBalanceInfo", typeof(string));
_dataTable.Columns.Add("AutomaticResize", typeof(bool));
_dataTable.Columns.Add("InheritLoadBalanceInfo", typeof(bool));
_dataTable.Columns.Add("InheritAutomaticResize", typeof(bool));
}
private void SetPrimaryKey()
{
_dataTable.PrimaryKey = new[] { _dataTable.Columns["ConstantID"] };
}
private void SerializeNodesRecursive(ConnectionInfo connectionInfo)
{
if (!(connectionInfo is RootNodeInfo))
SerializeConnectionInfo(connectionInfo);
var containerInfo = connectionInfo as ContainerInfo;
if (containerInfo == null) return;
foreach (var child in containerInfo.Children)
SerializeNodesRecursive(child);
}
private void SerializeConnectionInfo(ConnectionInfo connectionInfo)
{
_currentNodeIndex++;
var dataRow = _dataTable.NewRow();
dataRow["ID"] = DBNull.Value;
dataRow["Name"] = connectionInfo.Name;
dataRow["Type"] = connectionInfo.GetTreeNodeType().ToString();
dataRow["ConstantID"] = connectionInfo.ConstantID;
dataRow["ParentID"] = connectionInfo.Parent.ConstantID;
dataRow["PositionID"] = _currentNodeIndex;
dataRow["LastChange"] = (SqlDateTime)DateTime.Now;
dataRow["Expanded"] = connectionInfo is ContainerInfo ? ((ContainerInfo)connectionInfo).IsExpanded : false;
dataRow["Description"] = connectionInfo.Description;
dataRow["Icon"] = connectionInfo.Icon;
dataRow["Panel"] = connectionInfo.Panel;
dataRow["Username"] = _saveSecurity.Username ? connectionInfo.Username : "";
dataRow["DomainName"] = _saveSecurity.Domain ? connectionInfo.Domain : "";
dataRow["Password"] = _saveSecurity.Password ? connectionInfo.Password : "";
dataRow["Hostname"] = connectionInfo.Hostname;
dataRow["Protocol"] = connectionInfo.Protocol;
dataRow["PuttySession"] = connectionInfo.PuttySession;
dataRow["Port"] = connectionInfo.Port;
dataRow["ConnectToConsole"] = connectionInfo.UseConsoleSession;
dataRow["UseCredSsp"] = connectionInfo.UseCredSsp;
dataRow["RenderingEngine"] = connectionInfo.RenderingEngine;
dataRow["ICAEncryptionStrength"] = connectionInfo.ICAEncryptionStrength;
dataRow["RDPAuthenticationLevel"] = connectionInfo.RDPAuthenticationLevel;
dataRow["LoadBalanceInfo"] = connectionInfo.LoadBalanceInfo;
dataRow["Colors"] = connectionInfo.Colors;
dataRow["Resolution"] = connectionInfo.Resolution;
dataRow["AutomaticResize"] = connectionInfo.AutomaticResize;
dataRow["DisplayWallpaper"] = connectionInfo.DisplayWallpaper;
dataRow["DisplayThemes"] = connectionInfo.DisplayThemes;
dataRow["EnableFontSmoothing"] = connectionInfo.EnableFontSmoothing;
dataRow["EnableDesktopComposition"] = connectionInfo.EnableDesktopComposition;
dataRow["CacheBitmaps"] = connectionInfo.CacheBitmaps;
dataRow["RedirectDiskDrives"] = connectionInfo.RedirectDiskDrives;
dataRow["RedirectPorts"] = connectionInfo.RedirectPorts;
dataRow["RedirectPrinters"] = connectionInfo.RedirectPrinters;
dataRow["RedirectSmartCards"] = connectionInfo.RedirectSmartCards;
dataRow["RedirectSound"] = connectionInfo.RedirectSound;
dataRow["RedirectKeys"] = connectionInfo.RedirectKeys;
dataRow["Connected"] = connectionInfo.OpenConnections.Count > 0;
dataRow["PreExtApp"] = connectionInfo.PreExtApp;
dataRow["PostExtApp"] = connectionInfo.PostExtApp;
dataRow["MacAddress"] = connectionInfo.MacAddress;
dataRow["UserField"] = connectionInfo.UserField;
dataRow["ExtApp"] = connectionInfo.ExtApp;
dataRow["VNCCompression"] = connectionInfo.VNCCompression;
dataRow["VNCEncoding"] = connectionInfo.VNCEncoding;
dataRow["VNCAuthMode"] = connectionInfo.VNCAuthMode;
dataRow["VNCProxyType"] = connectionInfo.VNCProxyType;
dataRow["VNCProxyIP"] = connectionInfo.VNCProxyIP;
dataRow["VNCProxyPort"] = connectionInfo.VNCProxyPort;
dataRow["VNCProxyUsername"] = connectionInfo.VNCProxyUsername;
dataRow["VNCProxyPassword"] = connectionInfo.VNCProxyPassword;
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"] = connectionInfo.RDGatewayUsername;
dataRow["RDGatewayPassword"] = connectionInfo.RDGatewayPassword;
dataRow["RDGatewayDomain"] = connectionInfo.RDGatewayDomain;
if (_saveSecurity.Inheritance)
{
dataRow["InheritCacheBitmaps"] = connectionInfo.Inheritance.CacheBitmaps;
dataRow["InheritColors"] = connectionInfo.Inheritance.Colors;
dataRow["InheritDescription"] = connectionInfo.Inheritance.Description;
dataRow["InheritDisplayThemes"] = connectionInfo.Inheritance.DisplayThemes;
dataRow["InheritDisplayWallpaper"] = connectionInfo.Inheritance.DisplayWallpaper;
dataRow["InheritEnableFontSmoothing"] = connectionInfo.Inheritance.EnableFontSmoothing;
dataRow["InheritEnableDesktopComposition"] = connectionInfo.Inheritance.EnableDesktopComposition;
dataRow["InheritDomain"] = connectionInfo.Inheritance.Domain;
dataRow["InheritIcon"] = connectionInfo.Inheritance.Icon;
dataRow["InheritPanel"] = connectionInfo.Inheritance.Panel;
dataRow["InheritPassword"] = connectionInfo.Inheritance.Password;
dataRow["InheritPort"] = connectionInfo.Inheritance.Port;
dataRow["InheritProtocol"] = connectionInfo.Inheritance.Protocol;
dataRow["InheritPuttySession"] = connectionInfo.Inheritance.PuttySession;
dataRow["InheritRedirectDiskDrives"] = connectionInfo.Inheritance.RedirectDiskDrives;
dataRow["InheritRedirectKeys"] = connectionInfo.Inheritance.RedirectKeys;
dataRow["InheritRedirectPorts"] = connectionInfo.Inheritance.RedirectPorts;
dataRow["InheritRedirectPrinters"] = connectionInfo.Inheritance.RedirectPrinters;
dataRow["InheritRedirectSmartCards"] = connectionInfo.Inheritance.RedirectSmartCards;
dataRow["InheritRedirectSound"] = connectionInfo.Inheritance.RedirectSound;
dataRow["InheritResolution"] = connectionInfo.Inheritance.Resolution;
dataRow["InheritAutomaticResize"] = connectionInfo.Inheritance.AutomaticResize;
dataRow["InheritUseConsoleSession"] = connectionInfo.Inheritance.UseConsoleSession;
dataRow["InheritUseCredSsp"] = connectionInfo.Inheritance.UseCredSsp;
dataRow["InheritRenderingEngine"] = connectionInfo.Inheritance.RenderingEngine;
dataRow["InheritUsername"] = connectionInfo.Inheritance.Username;
dataRow["InheritICAEncryptionStrength"] = connectionInfo.Inheritance.ICAEncryptionStrength;
dataRow["InheritRDPAuthenticationLevel"] = connectionInfo.Inheritance.RDPAuthenticationLevel;
dataRow["InheritLoadBalanceInfo"] = connectionInfo.Inheritance.LoadBalanceInfo;
dataRow["InheritPreExtApp"] = connectionInfo.Inheritance.PreExtApp;
dataRow["InheritPostExtApp"] = connectionInfo.Inheritance.PostExtApp;
dataRow["InheritMacAddress"] = connectionInfo.Inheritance.MacAddress;
dataRow["InheritUserField"] = connectionInfo.Inheritance.UserField;
dataRow["InheritExtApp"] = connectionInfo.Inheritance.ExtApp;
dataRow["InheritVNCCompression"] = connectionInfo.Inheritance.VNCCompression;
dataRow["InheritVNCEncoding"] = connectionInfo.Inheritance.VNCEncoding;
dataRow["InheritVNCAuthMode"] = connectionInfo.Inheritance.VNCAuthMode;
dataRow["InheritVNCProxyType"] = connectionInfo.Inheritance.VNCProxyType;
dataRow["InheritVNCProxyIP"] = connectionInfo.Inheritance.VNCProxyIP;
dataRow["InheritVNCProxyPort"] = connectionInfo.Inheritance.VNCProxyPort;
dataRow["InheritVNCProxyUsername"] = connectionInfo.Inheritance.VNCProxyUsername;
dataRow["InheritVNCProxyPassword"] = connectionInfo.Inheritance.VNCProxyPassword;
dataRow["InheritVNCColors"] = connectionInfo.Inheritance.VNCColors;
dataRow["InheritVNCSmartSizeMode"] = connectionInfo.Inheritance.VNCSmartSizeMode;
dataRow["InheritVNCViewOnly"] = connectionInfo.Inheritance.VNCViewOnly;
dataRow["InheritRDGatewayUsageMethod"] = connectionInfo.Inheritance.RDGatewayUsageMethod;
dataRow["InheritRDGatewayHostname"] = connectionInfo.Inheritance.RDGatewayHostname;
dataRow["InheritRDGatewayUseConnectionCredentials"] = connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
dataRow["InheritRDGatewayUsername"] = connectionInfo.Inheritance.RDGatewayUsername;
dataRow["InheritRDGatewayPassword"] = connectionInfo.Inheritance.RDGatewayPassword;
dataRow["InheritRDGatewayDomain"] = connectionInfo.Inheritance.RDGatewayDomain;
}
else
{
dataRow["InheritCacheBitmaps"] = false;
dataRow["InheritColors"] = false;
dataRow["InheritDescription"] = false;
dataRow["InheritDisplayThemes"] = false;
dataRow["InheritDisplayWallpaper"] = false;
dataRow["InheritEnableFontSmoothing"] = false;
dataRow["InheritEnableDesktopComposition"] = false;
dataRow["InheritDomain"] = false;
dataRow["InheritIcon"] = false;
dataRow["InheritPanel"] = false;
dataRow["InheritPassword"] = false;
dataRow["InheritPort"] = false;
dataRow["InheritProtocol"] = false;
dataRow["InheritPuttySession"] = false;
dataRow["InheritRedirectDiskDrives"] = false;
dataRow["InheritRedirectKeys"] = false;
dataRow["InheritRedirectPorts"] = false;
dataRow["InheritRedirectPrinters"] = false;
dataRow["InheritRedirectSmartCards"] = false;
dataRow["InheritRedirectSound"] = false;
dataRow["InheritResolution"] = false;
dataRow["InheritAutomaticResize"] = false;
dataRow["InheritUseConsoleSession"] = false;
dataRow["InheritUseCredSsp"] = false;
dataRow["InheritRenderingEngine"] = false;
dataRow["InheritUsername"] = false;
dataRow["InheritICAEncryptionStrength"] = false;
dataRow["InheritRDPAuthenticationLevel"] = false;
dataRow["InheritLoadBalanceInfo"] = false;
dataRow["InheritPreExtApp"] = false;
dataRow["InheritPostExtApp"] = false;
dataRow["InheritMacAddress"] = false;
dataRow["InheritUserField"] = false;
dataRow["InheritExtApp"] = false;
dataRow["InheritVNCCompression"] = false;
dataRow["InheritVNCEncoding"] = false;
dataRow["InheritVNCAuthMode"] = false;
dataRow["InheritVNCProxyType"] = false;
dataRow["InheritVNCProxyIP"] = false;
dataRow["InheritVNCProxyPort"] = false;
dataRow["InheritVNCProxyUsername"] = false;
dataRow["InheritVNCProxyPassword"] = false;
dataRow["InheritVNCColors"] = false;
dataRow["InheritVNCSmartSizeMode"] = false;
dataRow["InheritVNCViewOnly"] = false;
dataRow["InheritRDGatewayUsageMethod"] = false;
dataRow["InheritRDGatewayHostname"] = false;
dataRow["InheritRDGatewayUseConnectionCredentials"] = false;
dataRow["InheritRDGatewayUsername"] = false;
dataRow["InheritRDGatewayPassword"] = false;
dataRow["InheritRDGatewayDomain"] = false;
}
_dataTable.Rows.Add(dataRow);
}
}
}

View File

@@ -0,0 +1,9 @@
using mRemoteNG.Tree;
namespace mRemoteNG.Config.Serializers
{
public interface IDeserializer
{
ConnectionTreeModel Deserialize();
}
}

View File

@@ -0,0 +1,12 @@
using mRemoteNG.Connection;
using mRemoteNG.Tree;
namespace mRemoteNG.Config.Serializers
{
public interface ISerializer<TFormat>
{
TFormat Serialize(ConnectionTreeModel connectionTreeModel);
TFormat Serialize(ConnectionInfo serializationTarget);
}
}

View File

@@ -0,0 +1,87 @@
using System.Collections.Generic;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class PortScanDeserializer : IDeserializer
{
private readonly IEnumerable<ScanHost> _scannedHosts;
private readonly ProtocolType _targetProtocolType;
public PortScanDeserializer(IEnumerable<ScanHost> scannedHosts, ProtocolType targetProtocolType)
{
_scannedHosts = scannedHosts;
_targetProtocolType = targetProtocolType;
}
public ConnectionTreeModel Deserialize()
{
var connectionTreeModel = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
connectionTreeModel.AddRootNode(root);
foreach (var host in _scannedHosts)
ImportScannedHost(host, root);
return connectionTreeModel;
}
private void ImportScannedHost(ScanHost host, ContainerInfo parentContainer)
{
var finalProtocol = default(ProtocolType);
var protocolValid = true;
switch (_targetProtocolType)
{
case ProtocolType.SSH2:
if (host.SSH)
finalProtocol = ProtocolType.SSH2;
break;
case ProtocolType.Telnet:
if (host.Telnet)
finalProtocol = ProtocolType.Telnet;
break;
case ProtocolType.HTTP:
if (host.HTTP)
finalProtocol = ProtocolType.HTTP;
break;
case ProtocolType.HTTPS:
if (host.HTTPS)
finalProtocol = ProtocolType.HTTPS;
break;
case ProtocolType.Rlogin:
if (host.Rlogin)
finalProtocol = ProtocolType.Rlogin;
break;
case ProtocolType.RDP:
if (host.RDP)
finalProtocol = ProtocolType.RDP;
break;
case ProtocolType.VNC:
if (host.VNC)
finalProtocol = ProtocolType.VNC;
break;
default:
protocolValid = false;
break;
}
if (!protocolValid) return;
var newConnectionInfo = new ConnectionInfo
{
Name = host.HostNameWithoutDomain,
Hostname = host.HostName,
Protocol = finalProtocol
};
newConnectionInfo.SetDefaultPort();
parentContainer.AddChild(newConnectionInfo);
}
}
}

View File

@@ -0,0 +1,159 @@
using System;
using System.IO;
using System.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class PuttyConnectionManagerDeserializer : IDeserializer
{
private readonly string _puttycmConnectionsXml;
public PuttyConnectionManagerDeserializer(string xml)
{
_puttycmConnectionsXml = xml;
}
public ConnectionTreeModel Deserialize()
{
var connectionTreeModel = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
connectionTreeModel.AddRootNode(root);
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(_puttycmConnectionsXml);
var configurationNode = xmlDocument.SelectSingleNode("/configuration");
var rootNodes = configurationNode?.SelectNodes("./root");
if (rootNodes == null) return connectionTreeModel;
foreach (XmlNode rootNode in rootNodes)
{
ImportRootOrContainer(rootNode, root);
}
return connectionTreeModel;
}
private void ImportRootOrContainer(XmlNode xmlNode, ContainerInfo parentContainer)
{
VerifyNodeType(xmlNode);
var newContainer = ImportContainer(xmlNode, parentContainer);
var childNodes = xmlNode.SelectNodes("./*");
if (childNodes == null) return;
foreach (XmlNode childNode in childNodes)
{
switch (childNode.Name)
{
case "container":
ImportRootOrContainer(childNode, newContainer);
break;
case "connection":
ImportConnection(childNode, newContainer);
break;
default:
throw (new FileFormatException($"Unrecognized child node ({childNode.Name})."));
}
}
}
private void VerifyNodeType(XmlNode xmlNode)
{
var xmlNodeType = xmlNode?.Attributes?["type"].Value;
switch (xmlNode?.Name)
{
case "root":
if (string.Compare(xmlNodeType, "database", StringComparison.OrdinalIgnoreCase) != 0)
{
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)));
}
}
private ContainerInfo ImportContainer(XmlNode containerNode, ContainerInfo parentContainer)
{
var containerInfo = new ContainerInfo
{
Name = containerNode.Attributes?["name"].Value,
IsExpanded = bool.Parse(containerNode.Attributes?["expanded"].InnerText ?? "false")
};
parentContainer.AddChild(containerInfo);
return containerInfo;
}
private void ImportConnection(XmlNode connectionNode, ContainerInfo parentContainer)
{
var connectionNodeType = connectionNode.Attributes?["type"].Value;
if (string.Compare(connectionNodeType, "PuTTY", StringComparison.OrdinalIgnoreCase) != 0)
throw (new FileFormatException($"Unrecognized connection node type ({connectionNodeType})."));
var connectionInfo = ConnectionInfoFromXml(connectionNode);
parentContainer.AddChild(connectionInfo);
}
private ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
{
var connectionInfoNode = xmlNode.SelectSingleNode("./connection_info");
var name = connectionInfoNode?.SelectSingleNode("./name")?.InnerText;
var connectionInfo = new ConnectionInfo {Name = name};
var protocol = connectionInfoNode?.SelectSingleNode("./protocol")?.InnerText;
switch (protocol?.ToLowerInvariant())
{
case "telnet":
connectionInfo.Protocol = ProtocolType.Telnet;
break;
case "ssh":
connectionInfo.Protocol = ProtocolType.SSH2;
break;
default:
throw new FileFormatException($"Unrecognized protocol ({protocol}).");
}
connectionInfo.Hostname = connectionInfoNode.SelectSingleNode("./host")?.InnerText;
connectionInfo.Port = Convert.ToInt32(connectionInfoNode.SelectSingleNode("./port")?.InnerText);
connectionInfo.PuttySession = connectionInfoNode.SelectSingleNode("./session")?.InnerText;
// ./commandline
connectionInfo.Description = connectionInfoNode.SelectSingleNode("./description")?.InnerText;
var loginNode = xmlNode.SelectSingleNode("./login");
connectionInfo.Username = loginNode?.SelectSingleNode("login")?.InnerText;
connectionInfo.Password = loginNode?.SelectSingleNode("password")?.InnerText;
// ./prompt
// ./timeout/connectiontimeout
// ./timeout/logintimeout
// ./timeout/passwordtimeout
// ./timeout/commandtimeout
// ./command/command1
// ./command/command2
// ./command/command3
// ./command/command4
// ./command/command5
// ./options/loginmacro
// ./options/postcommands
// ./options/endlinechar
return connectionInfo;
}
}
}

View File

@@ -0,0 +1,134 @@
using System;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class RemoteDesktopConnectionDeserializer : IDeserializer
{
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
private readonly string[] _fileContent;
public RemoteDesktopConnectionDeserializer(string[] fileContent)
{
_fileContent = fileContent;
}
public ConnectionTreeModel Deserialize()
{
var connectionTreeModel = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
connectionTreeModel.AddRootNode(root);
var connectionInfo = new ConnectionInfo();
foreach (var line in _fileContent)
{
var parts = line.Split(new[] { ':' }, 3);
if (parts.Length < 3)
{
continue;
}
var key = parts[0];
var value = parts[2];
SetConnectionInfoParameter(connectionInfo, key, value);
}
root.AddChild(connectionInfo);
return connectionTreeModel;
}
private void SetConnectionInfoParameter(ConnectionInfo connectionInfo, string key, string value)
{
switch (key.ToLower())
{
case "full address":
var uri = new Uri("dummyscheme" + Uri.SchemeDelimiter + value);
if (!string.IsNullOrEmpty(uri.Host))
connectionInfo.Hostname = uri.Host;
if (uri.Port != -1)
connectionInfo.Port = uri.Port;
break;
case "server port":
connectionInfo.Port = Convert.ToInt32(value);
break;
case "username":
connectionInfo.Username = value;
break;
case "domain":
connectionInfo.Domain = value;
break;
case "session bpp":
switch (value)
{
case "8":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors256;
break;
case "15":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors15Bit;
break;
case "16":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors16Bit;
break;
case "24":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors24Bit;
break;
case "32":
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors32Bit;
break;
}
break;
case "bitmapcachepersistenable":
connectionInfo.CacheBitmaps = value == "1";
break;
case "screen mode id":
connectionInfo.Resolution = value == "2" ? ProtocolRDP.RDPResolutions.Fullscreen : ProtocolRDP.RDPResolutions.FitToWindow;
break;
case "connect to console":
connectionInfo.UseConsoleSession = value == "1";
break;
case "disable wallpaper":
connectionInfo.DisplayWallpaper = value == "1";
break;
case "disable themes":
connectionInfo.DisplayThemes = value == "1";
break;
case "allow font smoothing":
connectionInfo.EnableFontSmoothing = value == "1";
break;
case "allow desktop composition":
connectionInfo.EnableDesktopComposition = value == "1";
break;
case "redirectsmartcards":
connectionInfo.RedirectSmartCards = value == "1";
break;
case "redirectdrives":
connectionInfo.RedirectDiskDrives = value == "1";
break;
case "redirectcomports":
connectionInfo.RedirectPorts = value == "1";
break;
case "redirectprinters":
connectionInfo.RedirectPrinters = value == "1";
break;
case "audiomode":
switch (value)
{
case "0":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.BringToThisComputer;
break;
case "1":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.LeaveAtRemoteComputer;
break;
case "2":
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.DoNotPlay;
break;
}
break;
}
}
}
}

View File

@@ -0,0 +1,303 @@
using System;
using System.IO;
using System.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using System.Security.Cryptography;
using System.Text;
namespace mRemoteNG.Config.Serializers
{
public class RemoteDesktopConnectionManagerDeserializer : IDeserializer
{
private readonly string _rdcmConnectionsXml;
public RemoteDesktopConnectionManagerDeserializer(string xml)
{
_rdcmConnectionsXml = xml;
}
public ConnectionTreeModel Deserialize()
{
var connectionTreeModel = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(_rdcmConnectionsXml);
var rdcManNode = xmlDocument.SelectSingleNode("/RDCMan");
VerifySchemaVersion(rdcManNode);
VerifyFileVersion(rdcManNode);
var fileNode = rdcManNode?.SelectSingleNode("./file");
ImportFileOrGroup(fileNode, root);
connectionTreeModel.AddRootNode(root);
return connectionTreeModel;
}
private void VerifySchemaVersion(XmlNode rdcManNode)
{
var schemaVersion = Convert.ToInt32(rdcManNode?.Attributes?["schemaVersion"].Value);
if (schemaVersion != 1)
{
throw (new FileFormatException($"Unsupported schema version ({schemaVersion})."));
}
}
private void VerifyFileVersion(XmlNode rdcManNode)
{
var versionNode = rdcManNode.SelectSingleNode("./version")?.InnerText;
if (versionNode != null)
{
var version = new Version(versionNode);
if (!(version == new Version(2, 2)))
{
throw new FileFormatException($"Unsupported file version ({version}).");
}
}
else
{
throw new FileFormatException("Unknown file version");
}
}
private void ImportFileOrGroup(XmlNode xmlNode, ContainerInfo parentContainer)
{
var propertiesNode = xmlNode.SelectSingleNode("./properties");
var newContainer = ImportContainer(propertiesNode, parentContainer);
var childNodes = xmlNode.SelectNodes("./group|./server");
if (childNodes == null) return;
foreach (XmlNode childNode in childNodes)
{
switch (childNode.Name)
{
case "group":
ImportFileOrGroup(childNode, newContainer);
break;
case "server":
ImportServer(childNode, newContainer);
break;
}
}
}
private ContainerInfo ImportContainer(XmlNode containerPropertiesNode, ContainerInfo parentContainer)
{
var newContainer = new ContainerInfo();
var connectionInfo = ConnectionInfoFromXml(containerPropertiesNode);
newContainer.CopyFrom(connectionInfo);
newContainer.Name = containerPropertiesNode?.SelectSingleNode("./name")?.InnerText ?? Language.strNewFolder;
newContainer.IsExpanded = bool.Parse(containerPropertiesNode?.SelectSingleNode("./expanded")?.InnerText ?? "false");
parentContainer.AddChild(newContainer);
return newContainer;
}
private void ImportServer(XmlNode serverNode, ContainerInfo parentContainer)
{
var newConnectionInfo = ConnectionInfoFromXml(serverNode);
parentContainer.AddChild(newConnectionInfo);
}
private ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
{
var connectionInfo = new ConnectionInfo {Protocol = ProtocolType.RDP};
var hostname = xmlNode.SelectSingleNode("./name")?.InnerText;
var displayName = xmlNode.SelectSingleNode("./displayName")?.InnerText ?? Language.strNewConnection;
connectionInfo.Name = displayName;
connectionInfo.Description = xmlNode.SelectSingleNode("./comment")?.InnerText;
connectionInfo.Hostname = hostname;
var logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
if (logonCredentialsNode?.Attributes?["inherit"].Value == "None")
{
connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName")?.InnerText;
var passwordNode = logonCredentialsNode.SelectSingleNode("./password");
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"].Value == "True" ? passwordNode.InnerText : DecryptRdcManPassword(passwordNode?.InnerText);
connectionInfo.Domain = logonCredentialsNode.SelectSingleNode("./domain")?.InnerText;
}
else
{
connectionInfo.Inheritance.Username = true;
connectionInfo.Inheritance.Password = true;
connectionInfo.Inheritance.Domain = true;
}
var connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
if (connectionSettingsNode?.Attributes?["inherit"].Value == "None")
{
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
// ./startProgram
// ./workingDir
connectionInfo.Port = Convert.ToInt32(connectionSettingsNode.SelectSingleNode("./port")?.InnerText);
}
else
{
connectionInfo.Inheritance.UseConsoleSession = true;
connectionInfo.Inheritance.Port = true;
}
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
if (gatewaySettingsNode?.Attributes?["inherit"].Value == "None")
{
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? ProtocolRDP.RDGatewayUsageMethod.Always : ProtocolRDP.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.RDGatewayDomain = gatewaySettingsNode.SelectSingleNode("./domain")?.InnerText;
// ./logonMethod
// ./localBypass
// ./credSharing
}
else
{
connectionInfo.Inheritance.RDGatewayUsageMethod = true;
connectionInfo.Inheritance.RDGatewayHostname = true;
connectionInfo.Inheritance.RDGatewayUsername = true;
connectionInfo.Inheritance.RDGatewayPassword = true;
connectionInfo.Inheritance.RDGatewayDomain = true;
}
var remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop");
if (remoteDesktopNode?.Attributes?["inherit"].Value == "None")
{
var resolutionString = Convert.ToString(remoteDesktopNode.SelectSingleNode("./size")?.InnerText.Replace(" ", ""));
try
{
connectionInfo.Resolution = (ProtocolRDP.RDPResolutions)Enum.Parse(typeof(ProtocolRDP.RDPResolutions), "Res" + resolutionString);
}
catch (ArgumentException)
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./sameSizeAsClientArea")?.InnerText == "True")
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./fullScreen")?.InnerText == "True")
{
connectionInfo.Resolution = ProtocolRDP.RDPResolutions.Fullscreen;
}
var colorDepth = remoteDesktopNode.SelectSingleNode("./colorDepth")?.InnerText;
if (colorDepth != null)
connectionInfo.Colors = (ProtocolRDP.RDPColors)Enum.Parse(typeof(ProtocolRDP.RDPColors), colorDepth);
}
else
{
connectionInfo.Inheritance.Resolution = true;
connectionInfo.Inheritance.Colors = true;
}
var localResourcesNode = xmlNode.SelectSingleNode("./localResources");
if (localResourcesNode?.Attributes?["inherit"].Value == "None")
{
switch (localResourcesNode.SelectSingleNode("./audioRedirection")?.InnerText)
{
case "0": // Bring to this computer
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.BringToThisComputer;
break;
case "1": // Leave at remote computer
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.LeaveAtRemoteComputer;
break;
case "2": // Do not play
connectionInfo.RedirectSound = ProtocolRDP.RDPSounds.DoNotPlay;
break;
}
// ./audioRedirectionQuality
// ./audioCaptureRedirection
switch (localResourcesNode.SelectSingleNode("./keyboardHook")?.InnerText)
{
case "0": // On the local computer
connectionInfo.RedirectKeys = false;
break;
case "1": // On the remote computer
connectionInfo.RedirectKeys = true;
break;
case "2": // In full screen mode only
connectionInfo.RedirectKeys = false;
break;
}
// ./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");
}
else
{
connectionInfo.Inheritance.RedirectSound = true;
connectionInfo.Inheritance.RedirectKeys = true;
connectionInfo.Inheritance.RedirectDiskDrives = true;
connectionInfo.Inheritance.RedirectPorts = true;
connectionInfo.Inheritance.RedirectPrinters = true;
connectionInfo.Inheritance.RedirectSmartCards = true;
}
var securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings");
if (securitySettingsNode?.Attributes?["inherit"].Value == "None")
{
switch (securitySettingsNode.SelectSingleNode("./authentication")?.InnerText)
{
case "0": // No authentication
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.NoAuth;
break;
case "1": // Do not connect if authentication fails
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.AuthRequired;
break;
case "2": // Warn if authentication fails
connectionInfo.RDPAuthenticationLevel = ProtocolRDP.AuthenticationLevel.WarnOnFailedAuth;
break;
}
}
else
{
connectionInfo.Inheritance.RDPAuthenticationLevel = true;
}
// ./displaySettings/thumbnailScale
// ./displaySettings/liveThumbnailUpdates
// ./displaySettings/showDisconnectedThumbnails
return connectionInfo;
}
private string DecryptRdcManPassword(string ciphertext)
{
if (string.IsNullOrEmpty(ciphertext))
return null;
try
{
var plaintextData = ProtectedData.Unprotect(Convert.FromBase64String(ciphertext), new byte[] { }, DataProtectionScope.LocalMachine);
var charArray = Encoding.Unicode.GetChars(plaintextData);
return new string(charArray);
}
catch (Exception ex)
{
//Runtime.MessageCollector.AddExceptionMessage("RemoteDesktopConnectionManager.DecryptPassword() failed.", ex, logOnly: true);
return null;
}
}
}
}

View File

@@ -1,11 +1,9 @@
using System;
using System.Globalization;
using System.IO;
using System.Security;
using System.Windows.Forms;
using System.Xml;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Config.Connections;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
@@ -14,7 +12,6 @@ using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
@@ -22,64 +19,100 @@ using mRemoteNG.UI.Forms;
using mRemoteNG.UI.TaskDialog;
namespace mRemoteNG.Config.Connections
namespace mRemoteNG.Config.Serializers
{
public class XmlConnectionsLoader
public class XmlConnectionsDeserializer : IDeserializer
{
private XmlDocument _xmlDocument;
private double _confVersion;
private SecureString _pW = GeneralAppInfo.EncryptionKey;
private ContainerInfo _previousContainer;
private readonly ConnectionsDecryptor _decryptor = new ConnectionsDecryptor();
//TODO find way to inject data source info
private string ConnectionFileName = "";
public XmlConnectionsDeserializer(string xml)
{
LoadXmlConnectionData(xml);
ValidateConnectionFileVersion();
}
public string ConnectionFileName { get; set; }
public TreeNode RootTreeNode { get; set; }
public ConnectionList ConnectionList { get; set; }
public ContainerList ContainerList { get; set; }
private void LoadXmlConnectionData(string connections)
{
connections = _decryptor.DecryptConnections(connections);
_xmlDocument = new XmlDocument();
if (connections != "")
_xmlDocument.LoadXml(connections);
}
private void ValidateConnectionFileVersion()
{
if (_xmlDocument.DocumentElement != null && _xmlDocument.DocumentElement.HasAttribute("ConfVersion"))
_confVersion = Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."),
CultureInfo.InvariantCulture);
else
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strOldConffile);
public void LoadFromXml(bool import)
const double maxSupportedConfVersion = 2.5;
if (!(_confVersion > maxSupportedConfVersion)) return;
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
);
throw (new Exception($"Incompatible connection file format (file format version {_confVersion})."));
}
public ConnectionTreeModel Deserialize()
{
return Deserialize(false);
}
public ConnectionTreeModel Deserialize(bool import)
{
try
{
if (!import)
Runtime.IsConnectionsFileLoaded = false;
// SECTION 1. Create a DOM Document and load the XML data into it.
LoadXmlConnectionData();
ValidateConnectionFileVersion();
// SECTION 2. Initialize the treeview control.
var rootInfo = InitializeRootNode();
var connectionTreeModel = new ConnectionTreeModel();
connectionTreeModel.AddRootNode(rootInfo);
if (!ConnectionsFileIsAuthentic(rootInfo)) return;
if (_confVersion > 1.3)
{
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, rootInfo))
{
mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
mRemoteNG.Settings.Default.CustomConsPath = "";
return null;
}
}
if (import && !IsExportFile())
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strCannotImportNormalSessionFile);
return;
return null;
}
if (!IsExportFile())
{
RootTreeNode.ImageIndex = (int)TreeImageType.Root;
RootTreeNode.SelectedImageIndex = (int)TreeImageType.Root;
}
AddNodesFromXmlRecursive(_xmlDocument.DocumentElement, rootInfo);
//Windows.treeForm.InitialRefresh();
//SetSelectedNode(RootTreeNode);
// SECTION 3. Populate the TreeView with the DOM nodes.
PopulateTreeview();
RootTreeNode.EnsureVisible();
Windows.treeForm.InitialRefresh();
SetSelectedNode(RootTreeNode);
//open connections from last mremote session
OpenConnectionsFromLastSession();
if (!import)
Runtime.IsConnectionsFileLoaded = true;
return connectionTreeModel;
}
catch (Exception ex)
{
@@ -89,66 +122,33 @@ namespace mRemoteNG.Config.Connections
}
}
private bool ConnectionsFileIsAuthentic(RootNodeInfo rootInfo)
{
if (!(_confVersion > 1.3)) return true;
var protectedString = _xmlDocument.DocumentElement.Attributes["Protected"].Value;
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
var connectionsFileIsNotEncrypted = cryptographyProvider.Decrypt(protectedString, _pW) == "ThisIsNotProtected";
if (connectionsFileIsNotEncrypted) return true;
if (Authenticate(protectedString, false, rootInfo)) return true;
mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
mRemoteNG.Settings.Default.CustomConsPath = "";
RootTreeNode.Remove();
return false;
}
private void OpenConnectionsFromLastSession()
{
if (!mRemoteNG.Settings.Default.OpenConsFromLastSession || mRemoteNG.Settings.Default.NoReconnect) return;
foreach (ConnectionInfo conI in ConnectionList)
{
if (conI.PleaseConnect)
Runtime.OpenConnection(conI);
}
}
private void PopulateTreeview()
{
Windows.treeForm.tvConnections.BeginUpdate();
AddNodeFromXml(_xmlDocument.DocumentElement, RootTreeNode);
RootTreeNode.Expand();
ExpandPreviouslyOpenedFolders();
Windows.treeForm.tvConnections.EndUpdate();
}
private void AddNodeFromXml(XmlNode parentXmlNode, TreeNode parentTreeNode)
private void AddNodesFromXmlRecursive(XmlNode parentXmlNode, ContainerInfo parentContainer)
{
try
{
// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping process.
if (parentXmlNode.HasChildNodes)
if (!parentXmlNode.HasChildNodes) return;
foreach (XmlNode xmlNode in parentXmlNode.ChildNodes)
{
foreach (XmlNode xmlNode in parentXmlNode.ChildNodes)
var treeNodeTypeString = xmlNode.Attributes?["Type"].Value ?? "connection";
var nodeType = (TreeNodeType)Enum.Parse(typeof(TreeNodeType), treeNodeTypeString, true);
if (nodeType == TreeNodeType.Connection)
{
var treeNode = new TreeNode(xmlNode.Attributes?["Name"].Value);
parentTreeNode.Nodes.Add(treeNode);
var nodeType = ConnectionTreeNode.GetNodeTypeFromString(xmlNode.Attributes?["Type"].Value);
if (nodeType == TreeNodeType.Connection)
AddConnectionToList(xmlNode, treeNode);
else if (nodeType == TreeNodeType.Container)
AddContainerToList(xmlNode, treeNode);
AddNodeFromXml(xmlNode, treeNode);
var connectionInfo = GetConnectionInfoFromXml(xmlNode);
parentContainer.AddChild(connectionInfo);
}
else if (nodeType == TreeNodeType.Container)
{
var containerInfo = new ContainerInfo();
if (_confVersion >= 0.9)
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
if (_confVersion >= 0.8)
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
parentContainer.AddChild(containerInfo);
AddNodesFromXmlRecursive(xmlNode, containerInfo);
}
}
else
{
var nameAttribute = parentXmlNode.Attributes?["Name"];
var nodeName = nameAttribute?.Value.Trim();
parentTreeNode.Text = !string.IsNullOrEmpty(nodeName) ? nodeName : parentXmlNode.Name;
}
}
catch (Exception ex)
@@ -158,39 +158,6 @@ namespace mRemoteNG.Config.Connections
}
}
private void AddConnectionToList(XmlNode xmlNode, TreeNode treeNode)
{
var connectionInfo = GetConnectionInfoFromXml(xmlNode);
connectionInfo.TreeNode = treeNode;
connectionInfo.Parent = _previousContainer;
ConnectionList.Add(connectionInfo);
treeNode.Tag = connectionInfo;
treeNode.ImageIndex = (int)TreeImageType.ConnectionClosed;
treeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;
}
private void AddContainerToList(XmlNode xmlNode, TreeNode treeNode)
{
var containerInfo = new ContainerInfo();
if (_confVersion >= 0.8)
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
if (_confVersion >= 0.9)
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
if (treeNode.Parent?.Tag is ContainerInfo)
containerInfo.Parent = (ContainerInfo) treeNode.Parent.Tag;
containerInfo.TreeNode = treeNode;
containerInfo.Name = xmlNode.Attributes?["Name"].Value;
_previousContainer = containerInfo;
ContainerList.Add(containerInfo);
treeNode.Tag = containerInfo;
treeNode.ImageIndex = (int) TreeImageType.Container;
treeNode.SelectedImageIndex = (int) TreeImageType.Container;
}
private ConnectionInfo GetConnectionInfoFromXml(XmlNode xxNode)
{
var connectionInfo = new ConnectionInfo();
@@ -204,7 +171,7 @@ namespace mRemoteNG.Config.Connections
connectionInfo.Description = xmlnode.Attributes["Descr"].Value;
connectionInfo.Hostname = xmlnode.Attributes["Hostname"].Value;
connectionInfo.Username = xmlnode.Attributes["Username"].Value;
connectionInfo.Password = cryptographyProvider.Decrypt(xmlnode.Attributes["Password"].Value, _pW);
connectionInfo.Password = cryptographyProvider.Decrypt(xmlnode.Attributes["Password"].Value, Runtime.EncryptionKey);
connectionInfo.Domain = xmlnode.Attributes["Domain"].Value;
connectionInfo.DisplayWallpaper = bool.Parse(xmlnode.Attributes["DisplayWallpaper"].Value);
connectionInfo.DisplayThemes = bool.Parse(xmlnode.Attributes["DisplayThemes"].Value);
@@ -384,7 +351,7 @@ namespace mRemoteNG.Config.Connections
connectionInfo.VNCProxyIP = xmlnode.Attributes["VNCProxyIP"].Value;
connectionInfo.VNCProxyPort = Convert.ToInt32(xmlnode.Attributes["VNCProxyPort"].Value);
connectionInfo.VNCProxyUsername = xmlnode.Attributes["VNCProxyUsername"].Value;
connectionInfo.VNCProxyPassword = cryptographyProvider.Decrypt(xmlnode.Attributes["VNCProxyPassword"].Value, _pW);
connectionInfo.VNCProxyPassword = cryptographyProvider.Decrypt(xmlnode.Attributes["VNCProxyPassword"].Value, Runtime.EncryptionKey);
connectionInfo.VNCColors = (ProtocolVNC.Colors)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.Colors), xmlnode.Attributes["VNCColors"].Value);
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Tools.MiscTools.StringToEnum(typeof(ProtocolVNC.SmartSizeMode), xmlnode.Attributes["VNCSmartSizeMode"].Value);
connectionInfo.VNCViewOnly = bool.Parse(xmlnode.Attributes["VNCViewOnly"].Value);
@@ -434,7 +401,7 @@ namespace mRemoteNG.Config.Connections
connectionInfo.RDGatewayHostname = xmlnode.Attributes["RDGatewayHostname"].Value;
connectionInfo.RDGatewayUseConnectionCredentials = (ProtocolRDP.RDGatewayUseConnectionCredentials)Tools.MiscTools.StringToEnum(typeof(ProtocolRDP.RDGatewayUseConnectionCredentials), Convert.ToString(xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value));
connectionInfo.RDGatewayUsername = xmlnode.Attributes["RDGatewayUsername"].Value;
connectionInfo.RDGatewayPassword = cryptographyProvider.Decrypt(Convert.ToString(xmlnode.Attributes["RDGatewayPassword"].Value), _pW);
connectionInfo.RDGatewayPassword = cryptographyProvider.Decrypt(Convert.ToString(xmlnode.Attributes["RDGatewayPassword"].Value), Runtime.EncryptionKey);
connectionInfo.RDGatewayDomain = xmlnode.Attributes["RDGatewayDomain"].Value;
// Get inheritance settings
@@ -478,16 +445,6 @@ namespace mRemoteNG.Config.Connections
return connectionInfo;
}
private void ExpandPreviouslyOpenedFolders()
{
foreach (ContainerInfo contI in ContainerList)
{
if (contI.IsExpanded)
contI.TreeNode.Expand();
}
}
private bool IsExportFile()
{
var isExportFile = false;
@@ -499,147 +456,13 @@ namespace mRemoteNG.Config.Connections
private RootNodeInfo InitializeRootNode()
{
var rootNodeName = "";
if (_xmlDocument.DocumentElement.HasAttribute("Name"))
rootNodeName = Convert.ToString(_xmlDocument.DocumentElement.Attributes["Name"].Value.Trim());
RootTreeNode.Name = !string.IsNullOrEmpty(rootNodeName) ? rootNodeName : _xmlDocument.DocumentElement.Name;
RootTreeNode.Text = RootTreeNode.Name;
var rootNodeName = _xmlDocument.DocumentElement?.Attributes["Name"].Value.Trim();
var rootInfo = new RootNodeInfo(RootNodeType.Connection)
{
Name = RootTreeNode.Name,
TreeNode = RootTreeNode
Name = rootNodeName
};
RootTreeNode.Tag = rootInfo;
return rootInfo;
}
private void LoadXmlConnectionData()
{
var connections = DecryptCompleteFile();
_xmlDocument = new XmlDocument();
if (connections != "")
_xmlDocument.LoadXml(connections);
else
_xmlDocument.Load(ConnectionFileName);
}
private void ValidateConnectionFileVersion()
{
if (_xmlDocument.DocumentElement.HasAttribute("ConfVersion"))
_confVersion = Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."),
CultureInfo.InvariantCulture);
else
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strOldConffile);
const double maxSupportedConfVersion = 2.5;
if (!(_confVersion > maxSupportedConfVersion)) return;
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
);
throw (new Exception($"Incompatible connection file format (file format version {_confVersion})."));
}
private delegate void SetSelectedNodeDelegate(TreeNode treeNode);
private static void SetSelectedNode(TreeNode treeNode)
{
if (ConnectionTree.TreeView != null && ConnectionTree.TreeView.InvokeRequired)
{
Windows.treeForm.Invoke(new SetSelectedNodeDelegate(SetSelectedNode), treeNode);
return;
}
Windows.treeForm.tvConnections.SelectedNode = treeNode;
}
private string DecryptCompleteFile()
{
var sRd = new StreamReader(ConnectionFileName);
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
var strCons = "";
strCons = sRd.ReadToEnd();
sRd.Close();
if (string.IsNullOrEmpty(strCons)) return "";
var strDecr = "";
bool notDecr;
if (strCons.Contains("<?xml version=\"1.0\" encoding=\"utf-8\"?>"))
{
strDecr = strCons;
return strDecr;
}
try
{
strDecr = cryptographyProvider.Decrypt(strCons, _pW);
notDecr = strDecr == strCons;
}
catch (Exception)
{
notDecr = true;
}
if (notDecr)
{
if (Authenticate(strCons, true))
{
strDecr = cryptographyProvider.Decrypt(strCons, _pW);
notDecr = false;
}
if (notDecr == false)
return strDecr;
}
else
{
return strDecr;
}
return "";
}
private bool Authenticate(string value, bool compareToOriginalValue, RootNodeInfo rootInfo = null)
{
var passwordName = "";
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
passwordName = Path.GetFileName(ConnectionFileName);
if (compareToOriginalValue)
{
while (cryptographyProvider.Decrypt(value, _pW) == value)
{
_pW = Tools.MiscTools.PasswordDialog(passwordName, false);
if (_pW.Length == 0)
return false;
}
}
else
{
while (cryptographyProvider.Decrypt(value, _pW) != "ThisIsProtected")
{
_pW = Tools.MiscTools.PasswordDialog(passwordName, false);
if (_pW.Length == 0)
return false;
}
if (rootInfo == null) return true;
rootInfo.Password = true;
rootInfo.PasswordString = _pW.ConvertToUnsecureString();
}
return true;
}
}
}

View File

@@ -0,0 +1,345 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security;
using System.Text;
using System.Xml;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class XmlConnectionsSerializer : ISerializer<string>
{
private SecureString _password = GeneralAppInfo.EncryptionKey;
private XmlTextWriter _xmlTextWriter;
public bool Export { get; set; }
public Save SaveSecurity { get; set; }
public string Serialize(ConnectionTreeModel connectionTreeModel)
{
var rootNode = (RootNodeInfo)connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public string Serialize(ConnectionInfo serializationTarget)
{
var xml = "";
try
{
var memoryStream = new MemoryStream();
using (_xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8))
{
SetXmlTextWriterSettings();
_xmlTextWriter.WriteStartDocument();
SaveNodesRecursive(serializationTarget);
_xmlTextWriter.Flush();
var streamReader = new StreamReader(memoryStream, Encoding.UTF8, true);
memoryStream.Seek(0, SeekOrigin.Begin);
xml = streamReader.ReadToEnd();
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex);
}
return xml;
}
private void SetXmlTextWriterSettings()
{
_xmlTextWriter.Formatting = Formatting.Indented;
_xmlTextWriter.Indentation = 4;
}
private void SaveNodesRecursive(ConnectionInfo node)
{
try
{
var nodeAsRoot = node as RootNodeInfo;
var nodeAsContainer = node as ContainerInfo;
if (nodeAsRoot != null)
{
SerializeRootNodeInfo(nodeAsRoot);
foreach (var child in nodeAsRoot.Children)
SaveNodesRecursive(child);
}
else if (nodeAsContainer != null)
{
SerializeContainerInfo(nodeAsContainer);
foreach (var child in nodeAsContainer.Children)
SaveNodesRecursive(child);
}
else
{
SerializeConnectionInfo(node);
}
_xmlTextWriter.WriteEndElement();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SaveNode failed" + Environment.NewLine + ex.Message, true);
}
}
private void SerializeRootNodeInfo(RootNodeInfo rootNodeInfo)
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
_xmlTextWriter.WriteStartElement("Connections"); // Do not localize
_xmlTextWriter.WriteAttributeString("Name", "", rootNodeInfo.Name);
_xmlTextWriter.WriteAttributeString("Export", "", Convert.ToString(Export));
if (Export)
{
_xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
}
else
{
if (rootNodeInfo.Password)
{
_password = rootNodeInfo.PasswordString.ConvertToSecureString();
_xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsProtected", _password));
}
else
{
_xmlTextWriter.WriteAttributeString("Protected", "", cryptographyProvider.Encrypt("ThisIsNotProtected", _password));
}
}
_xmlTextWriter.WriteAttributeString("ConfVersion", "", ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture));
}
private void SerializeContainerInfo(ContainerInfo containerInfo)
{
_xmlTextWriter.WriteStartElement("Node");
_xmlTextWriter.WriteAttributeString("Name", "", containerInfo.Name);
_xmlTextWriter.WriteAttributeString("Type", "", containerInfo.GetTreeNodeType().ToString());
_xmlTextWriter.WriteAttributeString("Expanded", "", containerInfo.IsExpanded.ToString());
SaveConnectionFields(containerInfo);
}
private void SerializeConnectionInfo(ConnectionInfo connectionInfo)
{
_xmlTextWriter.WriteStartElement("Node");
_xmlTextWriter.WriteAttributeString("Name", "", connectionInfo.Name);
_xmlTextWriter.WriteAttributeString("Type", "", connectionInfo.GetTreeNodeType().ToString());
SaveConnectionFields(connectionInfo);
}
private void SaveConnectionFields(ConnectionInfo connectionInfo)
{
try
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
_xmlTextWriter.WriteAttributeString("Descr", "", connectionInfo.Description);
_xmlTextWriter.WriteAttributeString("Icon", "", connectionInfo.Icon);
_xmlTextWriter.WriteAttributeString("Panel", "", connectionInfo.Panel);
if (SaveSecurity.Username)
_xmlTextWriter.WriteAttributeString("Username", "", connectionInfo.Username);
else
_xmlTextWriter.WriteAttributeString("Username", "", "");
if (SaveSecurity.Domain)
_xmlTextWriter.WriteAttributeString("Domain", "", connectionInfo.Domain);
else
_xmlTextWriter.WriteAttributeString("Domain", "", "");
if (SaveSecurity.Password)
_xmlTextWriter.WriteAttributeString("Password", "", cryptographyProvider.Encrypt(connectionInfo.Password, _password));
else
_xmlTextWriter.WriteAttributeString("Password", "", "");
_xmlTextWriter.WriteAttributeString("Hostname", "", connectionInfo.Hostname);
_xmlTextWriter.WriteAttributeString("Protocol", "", connectionInfo.Protocol.ToString());
_xmlTextWriter.WriteAttributeString("PuttySession", "", connectionInfo.PuttySession);
_xmlTextWriter.WriteAttributeString("Port", "", Convert.ToString(connectionInfo.Port));
_xmlTextWriter.WriteAttributeString("ConnectToConsole", "", Convert.ToString(connectionInfo.UseConsoleSession));
_xmlTextWriter.WriteAttributeString("UseCredSsp", "", Convert.ToString(connectionInfo.UseCredSsp));
_xmlTextWriter.WriteAttributeString("RenderingEngine", "", connectionInfo.RenderingEngine.ToString());
_xmlTextWriter.WriteAttributeString("ICAEncryptionStrength", "", connectionInfo.ICAEncryptionStrength.ToString());
_xmlTextWriter.WriteAttributeString("RDPAuthenticationLevel", "", connectionInfo.RDPAuthenticationLevel.ToString());
_xmlTextWriter.WriteAttributeString("LoadBalanceInfo", "", connectionInfo.LoadBalanceInfo);
_xmlTextWriter.WriteAttributeString("Colors", "", connectionInfo.Colors.ToString());
_xmlTextWriter.WriteAttributeString("Resolution", "", connectionInfo.Resolution.ToString());
_xmlTextWriter.WriteAttributeString("AutomaticResize", "", Convert.ToString(connectionInfo.AutomaticResize));
_xmlTextWriter.WriteAttributeString("DisplayWallpaper", "", Convert.ToString(connectionInfo.DisplayWallpaper));
_xmlTextWriter.WriteAttributeString("DisplayThemes", "", Convert.ToString(connectionInfo.DisplayThemes));
_xmlTextWriter.WriteAttributeString("EnableFontSmoothing", "", Convert.ToString(connectionInfo.EnableFontSmoothing));
_xmlTextWriter.WriteAttributeString("EnableDesktopComposition", "", Convert.ToString(connectionInfo.EnableDesktopComposition));
_xmlTextWriter.WriteAttributeString("CacheBitmaps", "", Convert.ToString(connectionInfo.CacheBitmaps));
_xmlTextWriter.WriteAttributeString("RedirectDiskDrives", "", Convert.ToString(connectionInfo.RedirectDiskDrives));
_xmlTextWriter.WriteAttributeString("RedirectPorts", "", Convert.ToString(connectionInfo.RedirectPorts));
_xmlTextWriter.WriteAttributeString("RedirectPrinters", "", Convert.ToString(connectionInfo.RedirectPrinters));
_xmlTextWriter.WriteAttributeString("RedirectSmartCards", "", Convert.ToString(connectionInfo.RedirectSmartCards));
_xmlTextWriter.WriteAttributeString("RedirectSound", "", connectionInfo.RedirectSound.ToString());
_xmlTextWriter.WriteAttributeString("RedirectKeys", "", Convert.ToString(connectionInfo.RedirectKeys));
if (connectionInfo.OpenConnections.Count > 0)
_xmlTextWriter.WriteAttributeString("Connected", "", Convert.ToString(true));
else
_xmlTextWriter.WriteAttributeString("Connected", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("PreExtApp", "", connectionInfo.PreExtApp);
_xmlTextWriter.WriteAttributeString("PostExtApp", "", connectionInfo.PostExtApp);
_xmlTextWriter.WriteAttributeString("MacAddress", "", connectionInfo.MacAddress);
_xmlTextWriter.WriteAttributeString("UserField", "", connectionInfo.UserField);
_xmlTextWriter.WriteAttributeString("ExtApp", "", connectionInfo.ExtApp);
_xmlTextWriter.WriteAttributeString("VNCCompression", "", connectionInfo.VNCCompression.ToString());
_xmlTextWriter.WriteAttributeString("VNCEncoding", "", connectionInfo.VNCEncoding.ToString());
_xmlTextWriter.WriteAttributeString("VNCAuthMode", "", connectionInfo.VNCAuthMode.ToString());
_xmlTextWriter.WriteAttributeString("VNCProxyType", "", connectionInfo.VNCProxyType.ToString());
_xmlTextWriter.WriteAttributeString("VNCProxyIP", "", connectionInfo.VNCProxyIP);
_xmlTextWriter.WriteAttributeString("VNCProxyPort", "", Convert.ToString(connectionInfo.VNCProxyPort));
_xmlTextWriter.WriteAttributeString("VNCProxyUsername", "", connectionInfo.VNCProxyUsername);
_xmlTextWriter.WriteAttributeString("VNCProxyPassword", "", cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _password));
_xmlTextWriter.WriteAttributeString("VNCColors", "", connectionInfo.VNCColors.ToString());
_xmlTextWriter.WriteAttributeString("VNCSmartSizeMode", "", connectionInfo.VNCSmartSizeMode.ToString());
_xmlTextWriter.WriteAttributeString("VNCViewOnly", "", Convert.ToString(connectionInfo.VNCViewOnly));
_xmlTextWriter.WriteAttributeString("RDGatewayUsageMethod", "", connectionInfo.RDGatewayUsageMethod.ToString());
_xmlTextWriter.WriteAttributeString("RDGatewayHostname", "", connectionInfo.RDGatewayHostname);
_xmlTextWriter.WriteAttributeString("RDGatewayUseConnectionCredentials", "", connectionInfo.RDGatewayUseConnectionCredentials.ToString());
if (SaveSecurity.Username)
_xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", connectionInfo.RDGatewayUsername);
else
_xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", "");
if (SaveSecurity.Password)
_xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _password));
else
_xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", "");
if (SaveSecurity.Domain)
_xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", connectionInfo.RDGatewayDomain);
else
_xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", "");
if (SaveSecurity.Inheritance)
{
_xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", Convert.ToString(connectionInfo.Inheritance.CacheBitmaps));
_xmlTextWriter.WriteAttributeString("InheritColors", "", Convert.ToString(connectionInfo.Inheritance.Colors));
_xmlTextWriter.WriteAttributeString("InheritDescription", "", Convert.ToString(connectionInfo.Inheritance.Description));
_xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", Convert.ToString(connectionInfo.Inheritance.DisplayThemes));
_xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", Convert.ToString(connectionInfo.Inheritance.DisplayWallpaper));
_xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", Convert.ToString(connectionInfo.Inheritance.EnableFontSmoothing));
_xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", Convert.ToString(connectionInfo.Inheritance.EnableDesktopComposition));
_xmlTextWriter.WriteAttributeString("InheritDomain", "", Convert.ToString(connectionInfo.Inheritance.Domain));
_xmlTextWriter.WriteAttributeString("InheritIcon", "", Convert.ToString(connectionInfo.Inheritance.Icon));
_xmlTextWriter.WriteAttributeString("InheritPanel", "", Convert.ToString(connectionInfo.Inheritance.Panel));
_xmlTextWriter.WriteAttributeString("InheritPassword", "", Convert.ToString(connectionInfo.Inheritance.Password));
_xmlTextWriter.WriteAttributeString("InheritPort", "", Convert.ToString(connectionInfo.Inheritance.Port));
_xmlTextWriter.WriteAttributeString("InheritProtocol", "", Convert.ToString(connectionInfo.Inheritance.Protocol));
_xmlTextWriter.WriteAttributeString("InheritPuttySession", "", Convert.ToString(connectionInfo.Inheritance.PuttySession));
_xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", Convert.ToString(connectionInfo.Inheritance.RedirectDiskDrives));
_xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", Convert.ToString(connectionInfo.Inheritance.RedirectKeys));
_xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", Convert.ToString(connectionInfo.Inheritance.RedirectPorts));
_xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", Convert.ToString(connectionInfo.Inheritance.RedirectPrinters));
_xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", Convert.ToString(connectionInfo.Inheritance.RedirectSmartCards));
_xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", Convert.ToString(connectionInfo.Inheritance.RedirectSound));
_xmlTextWriter.WriteAttributeString("InheritResolution", "", Convert.ToString(connectionInfo.Inheritance.Resolution));
_xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", Convert.ToString(connectionInfo.Inheritance.AutomaticResize));
_xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", Convert.ToString(connectionInfo.Inheritance.UseConsoleSession));
_xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", Convert.ToString(connectionInfo.Inheritance.UseCredSsp));
_xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", Convert.ToString(connectionInfo.Inheritance.RenderingEngine));
_xmlTextWriter.WriteAttributeString("InheritUsername", "", Convert.ToString(connectionInfo.Inheritance.Username));
_xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", Convert.ToString(connectionInfo.Inheritance.ICAEncryptionStrength));
_xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", Convert.ToString(connectionInfo.Inheritance.RDPAuthenticationLevel));
_xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", Convert.ToString(connectionInfo.Inheritance.LoadBalanceInfo));
_xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", Convert.ToString(connectionInfo.Inheritance.PreExtApp));
_xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", Convert.ToString(connectionInfo.Inheritance.PostExtApp));
_xmlTextWriter.WriteAttributeString("InheritMacAddress", "", Convert.ToString(connectionInfo.Inheritance.MacAddress));
_xmlTextWriter.WriteAttributeString("InheritUserField", "", Convert.ToString(connectionInfo.Inheritance.UserField));
_xmlTextWriter.WriteAttributeString("InheritExtApp", "", Convert.ToString(connectionInfo.Inheritance.ExtApp));
_xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", Convert.ToString(connectionInfo.Inheritance.VNCCompression));
_xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", Convert.ToString(connectionInfo.Inheritance.VNCEncoding));
_xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", Convert.ToString(connectionInfo.Inheritance.VNCAuthMode));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", Convert.ToString(connectionInfo.Inheritance.VNCProxyType));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", Convert.ToString(connectionInfo.Inheritance.VNCProxyIP));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", Convert.ToString(connectionInfo.Inheritance.VNCProxyPort));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", Convert.ToString(connectionInfo.Inheritance.VNCProxyUsername));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", Convert.ToString(connectionInfo.Inheritance.VNCProxyPassword));
_xmlTextWriter.WriteAttributeString("InheritVNCColors", "", Convert.ToString(connectionInfo.Inheritance.VNCColors));
_xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", Convert.ToString(connectionInfo.Inheritance.VNCSmartSizeMode));
_xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", Convert.ToString(connectionInfo.Inheritance.VNCViewOnly));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayUsageMethod", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayUsageMethod));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayHostname));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayUseConnectionCredentials));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayUsername));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayPassword));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", Convert.ToString(connectionInfo.Inheritance.RDGatewayDomain));
}
else
{
_xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritColors", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritDescription", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritDisplayThemes", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritDisplayWallpaper", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritEnableFontSmoothing", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritEnableDesktopComposition", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritDomain", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritIcon", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPanel", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPassword", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPort", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritProtocol", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPuttySession", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectDiskDrives", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectKeys", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectPorts", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectPrinters", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectSmartCards", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRedirectSound", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritResolution", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritAutomaticResize", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritUseConsoleSession", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritUsername", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritPostExtApp", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritMacAddress", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritUserField", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritExtApp", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCCompression", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCEncoding", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCAuthMode", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyType", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyIP", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyPort", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyUsername", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCProxyPassword", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCColors", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCSmartSizeMode", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritVNCViewOnly", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayHostname", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayUseConnectionCredentials", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayUsername", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayPassword", "", Convert.ToString(false));
_xmlTextWriter.WriteAttributeString("InheritRDGatewayDomain", "", Convert.ToString(false));
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SaveConnectionFields failed" + Environment.NewLine + ex.Message, true);
}
}
}
}

View File

@@ -22,9 +22,9 @@ namespace mRemoteNG.Config.Settings
{
try
{
Windows.treePanel = null;
Windows.configPanel = null;
Windows.errorsPanel = null;
Windows.TreePanel = null;
Windows.ConfigPanel = null;
Windows.ErrorsPanel = null;
while (_MainForm.pnlDock.Contents.Count > 0)
{
@@ -67,16 +67,16 @@ namespace mRemoteNG.Config.Settings
try
{
if (persistString == typeof(ConfigWindow).ToString())
return Windows.configPanel;
return Windows.ConfigPanel;
if (persistString == typeof(ConnectionTreeWindow).ToString())
return Windows.treePanel;
return Windows.TreePanel;
if (persistString == typeof(ErrorAndInfoWindow).ToString())
return Windows.errorsPanel;
return Windows.ErrorsPanel;
if (persistString == typeof(ScreenshotManagerWindow).ToString())
return Windows.screenshotPanel;
return Windows.ScreenshotPanel;
}
catch (Exception ex)
{
@@ -88,21 +88,20 @@ namespace mRemoteNG.Config.Settings
public void CreatePanels()
{
Windows.configForm = new ConfigWindow(Windows.configPanel);
Windows.configPanel = Windows.configForm;
Windows.ConfigForm = new ConfigWindow(Windows.ConfigPanel);
Windows.ConfigPanel = Windows.ConfigForm;
Windows.treeForm = new ConnectionTreeWindow(Windows.treePanel);
Windows.treePanel = Windows.treeForm;
ConnectionTree.TreeView = Windows.treeForm.tvConnections;
Windows.TreeForm = new ConnectionTreeWindow(Windows.TreePanel);
Windows.TreePanel = Windows.TreeForm;
Windows.errorsForm = new ErrorAndInfoWindow(Windows.errorsPanel);
Windows.errorsPanel = Windows.errorsForm;
Windows.ErrorsForm = new ErrorAndInfoWindow(Windows.ErrorsPanel);
Windows.ErrorsPanel = Windows.ErrorsForm;
Windows.screenshotForm = new ScreenshotManagerWindow(Windows.screenshotPanel);
Windows.screenshotPanel = Windows.screenshotForm;
Windows.ScreenshotForm = new ScreenshotManagerWindow(Windows.ScreenshotPanel);
Windows.ScreenshotPanel = Windows.ScreenshotForm;
Windows.updateForm = new UpdateWindow(Windows.updatePanel);
Windows.updatePanel = Windows.updateForm;
Windows.UpdateForm = new UpdateWindow(Windows.UpdatePanel);
Windows.UpdatePanel = Windows.UpdateForm;
Windows.AnnouncementForm = new AnnouncementWindow(Windows.AnnouncementPanel);
Windows.AnnouncementPanel = Windows.AnnouncementForm;

View File

@@ -0,0 +1,641 @@
using System.Collections.Generic;
using System.ComponentModel;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Tools;
namespace mRemoteNG.Connection
{
public abstract class AbstractConnectionInfoData : INotifyPropertyChanged
{
#region Fields
private string _name;
private string _description;
private string _icon;
private string _panel;
private string _hostname;
private string _username;
private string _password;
private string _domain;
private ProtocolType _protocol;
private string _extApp;
private int _port;
private string _puttySession;
private ProtocolICA.EncryptionStrength _icaEncryption;
private bool _useConsoleSession;
private ProtocolRDP.AuthenticationLevel _rdpAuthenticationLevel;
private string _loadBalanceInfo;
private HTTPBase.RenderingEngine _renderingEngine;
private bool _useCredSsp;
private ProtocolRDP.RDGatewayUsageMethod _rdGatewayUsageMethod;
private string _rdGatewayHostname;
private ProtocolRDP.RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private string _rdGatewayUsername;
private string _rdGatewayPassword;
private string _rdGatewayDomain;
private ProtocolRDP.RDPResolutions _resolution;
private bool _automaticResize;
private ProtocolRDP.RDPColors _colors;
private bool _cacheBitmaps;
private bool _displayWallpaper;
private bool _displayThemes;
private bool _enableFontSmoothing;
private bool _enableDesktopComposition;
private bool _redirectKeys;
private bool _redirectDiskDrives;
private bool _redirectPrinters;
private bool _redirectPorts;
private bool _redirectSmartCards;
private ProtocolRDP.RDPSounds _redirectSound;
private string _preExtApp;
private string _postExtApp;
private string _macAddress;
private string _userField;
private ProtocolVNC.Compression _vncCompression;
private ProtocolVNC.Encoding _vncEncoding;
private ProtocolVNC.AuthMode _vncAuthMode;
private ProtocolVNC.ProxyType _vncProxyType;
private string _vncProxyIp;
private int _vncProxyPort;
private string _vncProxyUsername;
private string _vncProxyPassword;
private ProtocolVNC.Colors _vncColors;
private ProtocolVNC.SmartSizeMode _vncSmartSizeMode;
private bool _vncViewOnly;
#endregion
#region Properties
#region Display
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameName"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionName")]
public virtual string Name
{
get { return _name; }
set { SetField(ref _name, value, "Name"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDescription"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDescription")]
public virtual string Description
{
get { return GetPropertyValue("Description", _description); }
set { SetField(ref _description, value, "Description"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
TypeConverter(typeof(ConnectionIcon)),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameIcon"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionIcon")]
public virtual string Icon
{
get { return GetPropertyValue("Icon", _icon); }
set { SetField(ref _icon, value, "Icon"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePanel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPanel")]
public virtual string Panel
{
get { return GetPropertyValue("Panel", _panel); }
set { SetField(ref _panel, value, "Panel"); }
}
#endregion
#region Connection
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAddress")]
public virtual string Hostname
{
get { return _hostname.Trim(); }
set { SetField(ref _hostname, value?.Trim(), "Hostname"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUsername")]
public virtual string Username
{
get { return GetPropertyValue("Username", _username); }
set { SetField(ref _username, value?.Trim(), "Username"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePassword"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPassword"),
PasswordPropertyText(true)]
public virtual string Password
{
get { return GetPropertyValue("Password", _password); }
set { SetField(ref _password, value, "Password"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDomain"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDomain")]
public string Domain
{
get { return GetPropertyValue("Domain", _domain).Trim(); }
set { SetField(ref _domain, value?.Trim(), "Domain"); }
}
#endregion
#region Protocol
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameProtocol"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionProtocol"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public virtual ProtocolType Protocol
{
get { return GetPropertyValue("Protocol", _protocol); }
set { SetField(ref _protocol, value, "Protocol"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalTool"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalTool"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public string ExtApp
{
get { return GetPropertyValue("ExtApp", _extApp); }
set { SetField(ref _extApp, value, "ExtApp"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePort"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPort")]
public virtual int Port
{
get { return GetPropertyValue("Port", _port); }
set { SetField(ref _port, value, "Port"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePuttySession"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPuttySession"),
TypeConverter(typeof(Config.Putty.PuttySessionsManager.SessionList))]
public virtual string PuttySession
{
get { return GetPropertyValue("PuttySession", _puttySession); }
set { SetField(ref _puttySession, value, "PuttySession"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEncryptionStrength"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEncryptionStrength"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolICA.EncryptionStrength ICAEncryptionStrength
{
get { return GetPropertyValue("ICAEncryptionStrength", _icaEncryption); }
set { SetField(ref _icaEncryption, value, "ICAEncryptionStrength"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUseConsoleSession"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUseConsoleSession"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool UseConsoleSession
{
get { return GetPropertyValue("UseConsoleSession", _useConsoleSession); }
set { SetField(ref _useConsoleSession, value, "UseConsoleSession"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationLevel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationLevel"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.AuthenticationLevel RDPAuthenticationLevel
{
get { return GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel); }
set { SetField(ref _rdpAuthenticationLevel, value, "RDPAuthenticationLevel"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameLoadBalanceInfo"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionLoadBalanceInfo")]
public string LoadBalanceInfo
{
get { return GetPropertyValue("LoadBalanceInfo", _loadBalanceInfo).Trim(); }
set { SetField(ref _loadBalanceInfo, value?.Trim(), "LoadBalanceInfo"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRenderingEngine"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRenderingEngine"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public HTTPBase.RenderingEngine RenderingEngine
{
get { return GetPropertyValue("RenderingEngine", _renderingEngine); }
set { SetField(ref _renderingEngine, value, "RenderingEngine"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUseCredSsp"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUseCredSsp"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool UseCredSsp
{
get { return GetPropertyValue("UseCredSsp", _useCredSsp); }
set { SetField(ref _useCredSsp, value, "UseCredSsp"); }
}
#endregion
#region RD Gateway
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsageMethod"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsageMethod"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDGatewayUsageMethod RDGatewayUsageMethod
{
get { return GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod); }
set { SetField(ref _rdGatewayUsageMethod, value, "RDGatewayUsageMethod"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayHostname"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayHostname")]
public string RDGatewayHostname
{
get { return GetPropertyValue("RDGatewayHostname", _rdGatewayHostname).Trim(); }
set { SetField(ref _rdGatewayHostname, value?.Trim(), "RDGatewayHostname"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUseConnectionCredentials"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUseConnectionCredentials"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
{
get { return GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials); }
set { SetField(ref _rdGatewayUseConnectionCredentials, value, "RDGatewayUseConnectionCredentials"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsername")]
public string RDGatewayUsername
{
get { return GetPropertyValue("RDGatewayUsername", _rdGatewayUsername).Trim(); }
set { SetField(ref _rdGatewayUsername, value?.Trim(), "RDGatewayUsername"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayPassword"),
LocalizedAttributes.LocalizedDescription("strPropertyNameRDGatewayPassword"),
PasswordPropertyText(true)]
public string RDGatewayPassword
{
get { return GetPropertyValue("RDGatewayPassword", _rdGatewayPassword); }
set { SetField(ref _rdGatewayPassword, value, "RDGatewayPassword"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayDomain"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayDomain")]
public string RDGatewayDomain
{
get { return GetPropertyValue("RDGatewayDomain", _rdGatewayDomain).Trim(); }
set { SetField(ref _rdGatewayDomain, value?.Trim(), "RDGatewayDomain"); }
}
#endregion
#region Appearance
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameResolution"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionResolution"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPResolutions Resolution
{
get { return GetPropertyValue("Resolution", _resolution); }
set { SetField(ref _resolution, value, "Resolution"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAutomaticResize"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAutomaticResize"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool AutomaticResize
{
get { return GetPropertyValue("AutomaticResize", _automaticResize); }
set { SetField(ref _automaticResize, value, "AutomaticResize"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPColors Colors
{
get { return GetPropertyValue("Colors", _colors); }
set { SetField(ref _colors, value, "Colors"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameCacheBitmaps"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionCacheBitmaps"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool CacheBitmaps
{
get { return GetPropertyValue("CacheBitmaps", _cacheBitmaps); }
set { SetField(ref _cacheBitmaps, value, "CacheBitmaps"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDisplayWallpaper"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDisplayWallpaper"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool DisplayWallpaper
{
get { return GetPropertyValue("DisplayWallpaper", _displayWallpaper); }
set { SetField(ref _displayWallpaper, value, "DisplayWallpaper"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDisplayThemes"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDisplayThemes"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool DisplayThemes
{
get { return GetPropertyValue("DisplayThemes", _displayThemes); }
set { SetField(ref _displayThemes, value, "DisplayThemes"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEnableFontSmoothing"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEnableFontSmoothing"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool EnableFontSmoothing
{
get { return GetPropertyValue("EnableFontSmoothing", _enableFontSmoothing); }
set { SetField(ref _enableFontSmoothing, value, "EnableFontSmoothing"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEnableDesktopComposition"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEnableDesktopComposition"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool EnableDesktopComposition
{
get { return GetPropertyValue("EnableDesktopComposition", _enableDesktopComposition); }
set { SetField(ref _enableDesktopComposition, value, "EnableDesktopComposition"); }
}
#endregion
#region Redirect
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectKeys"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectKeys"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectKeys
{
get { return GetPropertyValue("RedirectKeys", _redirectKeys); }
set { SetField(ref _redirectKeys, value, "RedirectKeys"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectDrives"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectDrives"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectDiskDrives
{
get { return GetPropertyValue("RedirectDiskDrives", _redirectDiskDrives); }
set { SetField(ref _redirectDiskDrives, value, "RedirectDiskDrives"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectPrinters"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectPrinters"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectPrinters
{
get { return GetPropertyValue("RedirectPrinters", _redirectPrinters); }
set { SetField(ref _redirectPrinters, value, "RedirectPrinters"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectPorts"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectPorts"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectPorts
{
get { return GetPropertyValue("RedirectPorts", _redirectPorts); }
set { SetField(ref _redirectPorts, value, "RedirectPorts"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSmartCards"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSmartCards"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectSmartCards
{
get { return GetPropertyValue("RedirectSmartCards", _redirectSmartCards); }
set { SetField(ref _redirectSmartCards, value, "RedirectSmartCards"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSounds"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSounds"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPSounds RedirectSound
{
get { return GetPropertyValue("RedirectSound", _redirectSound); }
set { SetField(ref _redirectSound, value, "RedirectSound"); }
}
#endregion
#region Misc
[Browsable(false)]
public string ConstantID { get; set; }
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolBefore"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalToolBefore"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public virtual string PreExtApp
{
get { return GetPropertyValue("PreExtApp", _preExtApp); }
set { SetField(ref _preExtApp, value, "PreExtApp"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolAfter"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalToolAfter"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public virtual string PostExtApp
{
get { return GetPropertyValue("PostExtApp", _postExtApp); }
set { SetField(ref _postExtApp, value, "PostExtApp"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameMACAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionMACAddress")]
public virtual string MacAddress
{
get { return GetPropertyValue("MacAddress", _macAddress); }
set { SetField(ref _macAddress, value, "MacAddress"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUser1"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUser1")]
public virtual string UserField
{
get { return GetPropertyValue("UserField", _userField); }
set { SetField(ref _userField, value, "UserField"); }
}
#endregion
#region VNC
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameCompression"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionCompression"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Compression VNCCompression
{
get { return GetPropertyValue("VNCCompression", _vncCompression); }
set { SetField(ref _vncCompression, value, "VNCCompression"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEncoding"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEncoding"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Encoding VNCEncoding
{
get { return GetPropertyValue("VNCEncoding", _vncEncoding); }
set { SetField(ref _vncEncoding, value, "VNCEncoding"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationMode"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationMode"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.AuthMode VNCAuthMode
{
get { return GetPropertyValue("VNCAuthMode", _vncAuthMode); }
set { SetField(ref _vncAuthMode, value, "VNCAuthMode"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyType"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyType"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.ProxyType VNCProxyType
{
get { return GetPropertyValue("VNCProxyType", _vncProxyType); }
set { SetField(ref _vncProxyType, value, "VNCProxyType"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyAddress")]
public string VNCProxyIP
{
get { return GetPropertyValue("VNCProxyIP", _vncProxyIp); }
set { SetField(ref _vncProxyIp, value, "VNCProxyIP"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyPort"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyPort")]
public int VNCProxyPort
{
get { return GetPropertyValue("VNCProxyPort", _vncProxyPort); }
set { SetField(ref _vncProxyPort, value, "VNCProxyPort"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyUsername")]
public string VNCProxyUsername
{
get { return GetPropertyValue("VNCProxyUsername", _vncProxyUsername); }
set { SetField(ref _vncProxyUsername, value, "VNCProxyUsername"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyPassword"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyPassword"),
PasswordPropertyText(true)]
public string VNCProxyPassword
{
get { return GetPropertyValue("VNCProxyPassword", _vncProxyPassword); }
set { SetField(ref _vncProxyPassword, value, "VNCProxyPassword"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Colors VNCColors
{
get { return GetPropertyValue("VNCColors", _vncColors); }
set { SetField(ref _vncColors, value, "VNCColors"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameSmartSizeMode"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionSmartSizeMode"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.SmartSizeMode VNCSmartSizeMode
{
get { return GetPropertyValue("VNCSmartSizeMode", _vncSmartSizeMode); }
set { SetField(ref _vncSmartSizeMode, value, "VNCSmartSizeMode"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameViewOnly"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionViewOnly"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool VNCViewOnly
{
get { return GetPropertyValue("VNCViewOnly", _vncViewOnly); }
set { SetField(ref _vncViewOnly, value, "VNCViewOnly"); }
}
#endregion
#endregion
protected virtual TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
{
return (TPropertyType)GetType().GetProperty(propertyName).GetValue(this, null);
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
{
PropertyChanged?.Invoke(sender, new PropertyChangedEventArgs(args.PropertyName));
}
protected bool SetField<T>(ref T field, T value, string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
RaisePropertyChangedEvent(this, new PropertyChangedEventArgs(propertyName));
return true;
}
}
}

View File

@@ -17,599 +17,15 @@ using mRemoteNG.Connection.Protocol.Rlogin;
using mRemoteNG.Container;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Messages;
using mRemoteNG.Tree;
namespace mRemoteNG.Connection
{
[DefaultProperty("Name")]
public class ConnectionInfo : IParent, IInheritable
{
#region Private Properties
private string _description;
private string _icon;
private string _panel;
private string _hostname;
private string _username;
private string _password;
private string _domain;
private ProtocolType _protocol;
private string _extApp;
private int _port;
private string _puttySession;
private ProtocolICA.EncryptionStrength _icaEncryption;
private bool _useConsoleSession;
private ProtocolRDP.AuthenticationLevel _rdpAuthenticationLevel;
private string _loadBalanceInfo;
private HTTPBase.RenderingEngine _renderingEngine;
private bool _useCredSsp;
private ProtocolRDP.RDGatewayUsageMethod _rdGatewayUsageMethod;
private string _rdGatewayHostname;
private ProtocolRDP.RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private string _rdGatewayUsername;
private string _rdGatewayPassword;
private string _rdGatewayDomain;
private ProtocolRDP.RDPResolutions _resolution;
private bool _automaticResize;
private ProtocolRDP.RDPColors _colors;
private bool _cacheBitmaps;
private bool _displayWallpaper;
private bool _displayThemes;
private bool _enableFontSmoothing;
private bool _enableDesktopComposition;
private bool _redirectKeys;
private bool _redirectDiskDrives;
private bool _redirectPrinters;
private bool _redirectPorts;
private bool _redirectSmartCards;
private ProtocolRDP.RDPSounds _redirectSound;
private string _preExtApp;
private string _postExtApp;
private string _macAddress;
private string _userField;
private ProtocolVNC.Compression _vncCompression;
private ProtocolVNC.Encoding _vncEncoding;
private ProtocolVNC.AuthMode _vncAuthMode;
private ProtocolVNC.ProxyType _vncProxyType;
private string _vncProxyIp;
private int _vncProxyPort;
private string _vncProxyUsername;
private string _vncProxyPassword;
private ProtocolVNC.Colors _vncColors;
private ProtocolVNC.SmartSizeMode _vncSmartSizeMode;
private bool _vncViewOnly;
#endregion
public class ConnectionInfo : AbstractConnectionInfoData, IHasParent, IInheritable, IDisposable
{
#region Public Properties
#region Display
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameName"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionName")]
public virtual string Name { get; set; }
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDescription"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDescription")]
public virtual string Description
{
get { return GetPropertyValue("Description", _description); }
set { _description = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
TypeConverter(typeof(ConnectionIcon)),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameIcon"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionIcon")]
public virtual string Icon
{
get { return GetPropertyValue("Icon", _icon); }
set { _icon = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePanel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPanel")]
public virtual string Panel
{
get { return GetPropertyValue("Panel", _panel); }
set { _panel = value; }
}
#endregion
#region Connection
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAddress")]
public virtual string Hostname
{
get { return _hostname.Trim(); }
set {
_hostname = string.IsNullOrEmpty(value) ? string.Empty : value.Trim();
}
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUsername")]
public virtual string Username
{
get { return GetPropertyValue("Username", _username); }
set { _username = value.Trim(); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePassword"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPassword"),
PasswordPropertyText(true)]
public virtual string Password
{
get { return GetPropertyValue("Password", _password); }
set { _password = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDomain"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDomain")]
public string Domain
{
get { return GetPropertyValue("Domain", _domain).Trim(); }
set { _domain = value.Trim(); }
}
#endregion
#region Protocol
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameProtocol"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionProtocol"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public virtual ProtocolType Protocol
{
get { return GetPropertyValue("Protocol", _protocol); }
set { _protocol = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalTool"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalTool"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public string ExtApp
{
get { return GetPropertyValue("ExtApp", _extApp); }
set { _extApp = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePort"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPort")]
public virtual int Port
{
get { return GetPropertyValue("Port", _port); }
set { _port = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNamePuttySession"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPuttySession"),
TypeConverter(typeof(Config.Putty.Sessions.SessionList))]
public virtual string PuttySession
{
get { return GetPropertyValue("PuttySession", _puttySession); }
set { _puttySession = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEncryptionStrength"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEncryptionStrength"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolICA.EncryptionStrength ICAEncryptionStrength
{
get { return GetPropertyValue("ICAEncryptionStrength", _icaEncryption); }
set { _icaEncryption = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUseConsoleSession"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUseConsoleSession"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool UseConsoleSession
{
get { return GetPropertyValue("UseConsoleSession", _useConsoleSession); }
set { _useConsoleSession = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationLevel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationLevel"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.AuthenticationLevel RDPAuthenticationLevel
{
get { return GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel); }
set { _rdpAuthenticationLevel = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameLoadBalanceInfo"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionLoadBalanceInfo")]
public string LoadBalanceInfo
{
get { return GetPropertyValue("LoadBalanceInfo", _loadBalanceInfo).Trim(); }
set { _loadBalanceInfo = value.Trim(); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRenderingEngine"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRenderingEngine"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public HTTPBase.RenderingEngine RenderingEngine
{
get { return GetPropertyValue("RenderingEngine", _renderingEngine); }
set { _renderingEngine = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUseCredSsp"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUseCredSsp"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool UseCredSsp
{
get { return GetPropertyValue("UseCredSsp", _useCredSsp); }
set { _useCredSsp = value; }
}
#endregion
#region RD Gateway
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsageMethod"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsageMethod"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDGatewayUsageMethod RDGatewayUsageMethod
{
get { return GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod); }
set { _rdGatewayUsageMethod = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayHostname"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayHostname")]
public string RDGatewayHostname
{
get { return GetPropertyValue("RDGatewayHostname", _rdGatewayHostname).Trim(); }
set { _rdGatewayHostname = value.Trim(); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUseConnectionCredentials"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUseConnectionCredentials"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
{
get { return GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials); }
set { _rdGatewayUseConnectionCredentials = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsername")]
public string RDGatewayUsername
{
get { return GetPropertyValue("RDGatewayUsername", _rdGatewayUsername).Trim(); }
set { _rdGatewayUsername = value.Trim(); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayPassword"),
LocalizedAttributes.LocalizedDescription("strPropertyNameRDGatewayPassword"),
PasswordPropertyText(true)]
public string RDGatewayPassword
{
get { return GetPropertyValue("RDGatewayPassword", _rdGatewayPassword); }
set { _rdGatewayPassword = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayDomain"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayDomain")]
public string RDGatewayDomain
{
get { return GetPropertyValue("RDGatewayDomain", _rdGatewayDomain).Trim(); }
set { _rdGatewayDomain = value.Trim(); }
}
#endregion
#region Appearance
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameResolution"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionResolution"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPResolutions Resolution
{
get { return GetPropertyValue("Resolution", _resolution); }
set { _resolution = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAutomaticResize"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAutomaticResize"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool AutomaticResize
{
get { return GetPropertyValue("AutomaticResize", _automaticResize); }
set { _automaticResize = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPColors Colors
{
get { return GetPropertyValue("Colors", _colors); }
set { _colors = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameCacheBitmaps"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionCacheBitmaps"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool CacheBitmaps
{
get { return GetPropertyValue("CacheBitmaps", _cacheBitmaps); }
set { _cacheBitmaps = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDisplayWallpaper"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDisplayWallpaper"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool DisplayWallpaper
{
get { return GetPropertyValue("DisplayWallpaper", _displayWallpaper); }
set { _displayWallpaper = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameDisplayThemes"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDisplayThemes"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool DisplayThemes
{
get { return GetPropertyValue("DisplayThemes", _displayThemes); }
set { _displayThemes = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEnableFontSmoothing"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEnableFontSmoothing"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool EnableFontSmoothing
{
get { return GetPropertyValue("EnableFontSmoothing", _enableFontSmoothing); }
set { _enableFontSmoothing = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEnableDesktopComposition"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEnableDesktopComposition"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool EnableDesktopComposition
{
get { return GetPropertyValue("EnableDesktopComposition", _enableDesktopComposition); }
set { _enableDesktopComposition = value; }
}
#endregion
#region Redirect
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectKeys"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectKeys"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectKeys
{
get { return GetPropertyValue("RedirectKeys", _redirectKeys); }
set { _redirectKeys = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectDrives"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectDrives"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectDiskDrives
{
get { return GetPropertyValue("RedirectDiskDrives", _redirectDiskDrives); }
set { _redirectDiskDrives = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectPrinters"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectPrinters"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectPrinters
{
get { return GetPropertyValue("RedirectPrinters", _redirectPrinters); }
set { _redirectPrinters = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectPorts"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectPorts"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectPorts
{
get { return GetPropertyValue("RedirectPorts", _redirectPorts); }
set { _redirectPorts = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSmartCards"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSmartCards"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool RedirectSmartCards
{
get { return GetPropertyValue("RedirectSmartCards", _redirectSmartCards); }
set { _redirectSmartCards = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSounds"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSounds"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolRDP.RDPSounds RedirectSound
{
get { return GetPropertyValue("RedirectSound", _redirectSound); }
set { _redirectSound = value; }
}
#endregion
#region Misc
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolBefore"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalToolBefore"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public virtual string PreExtApp
{
get { return GetPropertyValue("PreExtApp", _preExtApp); }
set { _preExtApp = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolAfter"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalToolAfter"),
TypeConverter(typeof(ExternalToolsTypeConverter))]
public virtual string PostExtApp
{
get { return GetPropertyValue("PostExtApp", _postExtApp); }
set { _postExtApp = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameMACAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionMACAddress")]
public virtual string MacAddress
{
get { return GetPropertyValue("MacAddress", _macAddress); }
set { _macAddress = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameUser1"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUser1")]
public virtual string UserField
{
get { return GetPropertyValue("UserField", _userField); }
set { _userField = value; }
}
#endregion
#region VNC
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameCompression"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionCompression"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Compression VNCCompression
{
get { return GetPropertyValue("VNCCompression", _vncCompression); }
set { _vncCompression = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameEncoding"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionEncoding"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Encoding VNCEncoding
{
get { return GetPropertyValue("VNCEncoding", _vncEncoding); }
set { _vncEncoding = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationMode"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationMode"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.AuthMode VNCAuthMode
{
get { return GetPropertyValue("VNCAuthMode", _vncAuthMode); }
set { _vncAuthMode = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyType"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyType"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.ProxyType VNCProxyType
{
get { return GetPropertyValue("VNCProxyType", _vncProxyType); }
set { _vncProxyType = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyAddress"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyAddress")]
public string VNCProxyIP
{
get { return GetPropertyValue("VNCProxyIP", _vncProxyIp); }
set { _vncProxyIp = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyPort"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyPort")]
public int VNCProxyPort
{
get { return GetPropertyValue("VNCProxyPort", _vncProxyPort); }
set { _vncProxyPort = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyUsername"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyUsername")]
public string VNCProxyUsername
{
get { return GetPropertyValue("VNCProxyUsername", _vncProxyUsername); }
set { _vncProxyUsername = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameVNCProxyPassword"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyPassword"),
PasswordPropertyText(true)]
public string VNCProxyPassword
{
get { return GetPropertyValue("VNCProxyPassword", _vncProxyPassword); }
set { _vncProxyPassword = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.Colors VNCColors
{
get { return GetPropertyValue("VNCColors", _vncColors); }
set { _vncColors = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameSmartSizeMode"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionSmartSizeMode"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public ProtocolVNC.SmartSizeMode VNCSmartSizeMode
{
get { return GetPropertyValue("VNCSmartSizeMode", _vncSmartSizeMode); }
set { _vncSmartSizeMode = value; }
}
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameViewOnly"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionViewOnly"),
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
public bool VNCViewOnly
{
get { return GetPropertyValue("VNCViewOnly", _vncViewOnly); }
set { _vncViewOnly = value; }
}
#endregion
#region Non-browsable public properties
[Browsable(false)]
public ConnectionInfoInheritance Inheritance { get; set; }
@@ -623,14 +39,11 @@ namespace mRemoteNG.Connection
public bool IsDefault { get; set; }
[Browsable(false)]
public ContainerInfo Parent { get; set; }
public ContainerInfo Parent { get; internal set; }
[Browsable(false)]
public int PositionID { get; set; }
[Browsable(false)]
public string ConstantID { get; set; }
[Browsable(false)]
public TreeNode TreeNode { get; set; }
@@ -639,9 +52,7 @@ namespace mRemoteNG.Connection
[Browsable(false)]
public bool PleaseConnect { get; set; }
#endregion
#endregion
#region Constructors
public ConnectionInfo()
@@ -661,16 +72,19 @@ namespace mRemoteNG.Connection
public ConnectionInfo(ContainerInfo parent) : this()
{
IsContainer = true;
parent.Add(this);
parent.AddChild(this);
}
#endregion
#region Public Methods
public virtual ConnectionInfo Copy()
public virtual ConnectionInfo Clone()
{
var newConnectionInfo = (ConnectionInfo)MemberwiseClone();
var newConnectionInfo = new ConnectionInfo();
newConnectionInfo.CopyFrom(this);
newConnectionInfo.ConstantID = MiscTools.CreateConstantID();
newConnectionInfo.SetParent(Parent);
newConnectionInfo.OpenConnections = new ProtocolList();
newConnectionInfo.Inheritance = Inheritance.Clone();
return newConnectionInfo;
}
@@ -683,7 +97,12 @@ namespace mRemoteNG.Connection
property.SetValue(this, remotePropertyValue, null);
}
}
public virtual TreeNodeType GetTreeNodeType()
{
return TreeNodeType.Connection;
}
public void SetDefaults()
{
if (Port == 0)
@@ -708,7 +127,23 @@ namespace mRemoteNG.Connection
var filteredProperties = properties.Where((prop) => !excludedPropertyNames.Contains(prop.Name));
return filteredProperties;
}
#endregion
public virtual void SetParent(ContainerInfo parent)
{
RemoveParent();
parent?.AddChild(this);
}
public void RemoveParent()
{
Parent?.RemoveChild(this);
}
public virtual void Dispose()
{
RemoveParent();
}
#endregion
#region Public Enumerations
[Flags()]
@@ -725,7 +160,7 @@ namespace mRemoteNG.Connection
#endregion
#region Private Methods
private TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
protected override TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
{
return ShouldThisPropertyBeInherited(propertyName) ? GetInheritedPropertyValue<TPropertyType>(propertyName) : value;
}
@@ -798,87 +233,87 @@ namespace mRemoteNG.Connection
private void SetTreeDisplayDefaults()
{
Name = Language.strNewConnection;
_description = Settings.Default.ConDefaultDescription;
_icon = Settings.Default.ConDefaultIcon;
_panel = Language.strGeneral;
Description = Settings.Default.ConDefaultDescription;
Icon = Settings.Default.ConDefaultIcon;
Panel = Language.strGeneral;
}
private void SetConnectionDefaults()
{
_hostname = string.Empty;
_username = Settings.Default.ConDefaultUsername;
_password = Settings.Default.ConDefaultPassword;
_domain = Settings.Default.ConDefaultDomain;
Hostname = string.Empty;
Username = Settings.Default.ConDefaultUsername;
Password = Settings.Default.ConDefaultPassword;
Domain = Settings.Default.ConDefaultDomain;
}
private void SetProtocolDefaults()
{
_protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), Settings.Default.ConDefaultProtocol);
_extApp = Settings.Default.ConDefaultExtApp;
_port = 0;
_puttySession = Settings.Default.ConDefaultPuttySession;
_icaEncryption = (ProtocolICA.EncryptionStrength) Enum.Parse(typeof(ProtocolICA.EncryptionStrength), Settings.Default.ConDefaultICAEncryptionStrength);
_useConsoleSession = Settings.Default.ConDefaultUseConsoleSession;
_rdpAuthenticationLevel = (ProtocolRDP.AuthenticationLevel) Enum.Parse(typeof(ProtocolRDP.AuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
_loadBalanceInfo = Settings.Default.ConDefaultLoadBalanceInfo;
_renderingEngine = (HTTPBase.RenderingEngine) Enum.Parse(typeof(HTTPBase.RenderingEngine), Settings.Default.ConDefaultRenderingEngine);
_useCredSsp = Settings.Default.ConDefaultUseCredSsp;
Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), Settings.Default.ConDefaultProtocol);
ExtApp = Settings.Default.ConDefaultExtApp;
Port = 0;
PuttySession = Settings.Default.ConDefaultPuttySession;
ICAEncryptionStrength = (ProtocolICA.EncryptionStrength) Enum.Parse(typeof(ProtocolICA.EncryptionStrength), Settings.Default.ConDefaultICAEncryptionStrength);
UseConsoleSession = Settings.Default.ConDefaultUseConsoleSession;
RDPAuthenticationLevel = (ProtocolRDP.AuthenticationLevel) Enum.Parse(typeof(ProtocolRDP.AuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
LoadBalanceInfo = Settings.Default.ConDefaultLoadBalanceInfo;
RenderingEngine = (HTTPBase.RenderingEngine) Enum.Parse(typeof(HTTPBase.RenderingEngine), Settings.Default.ConDefaultRenderingEngine);
UseCredSsp = Settings.Default.ConDefaultUseCredSsp;
}
private void SetRdGatewayDefaults()
{
_rdGatewayUsageMethod = (ProtocolRDP.RDGatewayUsageMethod) Enum.Parse(typeof(ProtocolRDP.RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
_rdGatewayHostname = Settings.Default.ConDefaultRDGatewayHostname;
_rdGatewayUseConnectionCredentials = (ProtocolRDP.RDGatewayUseConnectionCredentials) Enum.Parse(typeof(ProtocolRDP.RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials); ;
_rdGatewayUsername = Settings.Default.ConDefaultRDGatewayUsername;
_rdGatewayPassword = Settings.Default.ConDefaultRDGatewayPassword;
_rdGatewayDomain = Settings.Default.ConDefaultRDGatewayDomain;
RDGatewayUsageMethod = (ProtocolRDP.RDGatewayUsageMethod) Enum.Parse(typeof(ProtocolRDP.RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
RDGatewayHostname = Settings.Default.ConDefaultRDGatewayHostname;
RDGatewayUseConnectionCredentials = (ProtocolRDP.RDGatewayUseConnectionCredentials) Enum.Parse(typeof(ProtocolRDP.RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials); ;
RDGatewayUsername = Settings.Default.ConDefaultRDGatewayUsername;
RDGatewayPassword = Settings.Default.ConDefaultRDGatewayPassword;
RDGatewayDomain = Settings.Default.ConDefaultRDGatewayDomain;
}
private void SetAppearanceDefaults()
{
_resolution = (ProtocolRDP.RDPResolutions) Enum.Parse(typeof(ProtocolRDP.RDPResolutions), Settings.Default.ConDefaultResolution);
_automaticResize = Settings.Default.ConDefaultAutomaticResize;
_colors = (ProtocolRDP.RDPColors) Enum.Parse(typeof(ProtocolRDP.RDPColors), Settings.Default.ConDefaultColors);
_cacheBitmaps = Settings.Default.ConDefaultCacheBitmaps;
_displayWallpaper = Settings.Default.ConDefaultDisplayWallpaper;
_displayThemes = Settings.Default.ConDefaultDisplayThemes;
_enableFontSmoothing = Settings.Default.ConDefaultEnableFontSmoothing;
_enableDesktopComposition = Settings.Default.ConDefaultEnableDesktopComposition;
Resolution = (ProtocolRDP.RDPResolutions) Enum.Parse(typeof(ProtocolRDP.RDPResolutions), Settings.Default.ConDefaultResolution);
AutomaticResize = Settings.Default.ConDefaultAutomaticResize;
Colors = (ProtocolRDP.RDPColors) Enum.Parse(typeof(ProtocolRDP.RDPColors), Settings.Default.ConDefaultColors);
CacheBitmaps = Settings.Default.ConDefaultCacheBitmaps;
DisplayWallpaper = Settings.Default.ConDefaultDisplayWallpaper;
DisplayThemes = Settings.Default.ConDefaultDisplayThemes;
EnableFontSmoothing = Settings.Default.ConDefaultEnableFontSmoothing;
EnableDesktopComposition = Settings.Default.ConDefaultEnableDesktopComposition;
}
private void SetRedirectDefaults()
{
_redirectKeys = Settings.Default.ConDefaultRedirectKeys;
_redirectDiskDrives = Settings.Default.ConDefaultRedirectDiskDrives;
_redirectPrinters = Settings.Default.ConDefaultRedirectPrinters;
_redirectPorts = Settings.Default.ConDefaultRedirectPorts;
_redirectSmartCards = Settings.Default.ConDefaultRedirectSmartCards;
_redirectSound = (ProtocolRDP.RDPSounds) Enum.Parse(typeof(ProtocolRDP.RDPSounds), Settings.Default.ConDefaultRedirectSound);
RedirectKeys = Settings.Default.ConDefaultRedirectKeys;
RedirectDiskDrives = Settings.Default.ConDefaultRedirectDiskDrives;
RedirectPrinters = Settings.Default.ConDefaultRedirectPrinters;
RedirectPorts = Settings.Default.ConDefaultRedirectPorts;
RedirectSmartCards = Settings.Default.ConDefaultRedirectSmartCards;
RedirectSound = (ProtocolRDP.RDPSounds) Enum.Parse(typeof(ProtocolRDP.RDPSounds), Settings.Default.ConDefaultRedirectSound);
}
private void SetMiscDefaults()
{
ConstantID = MiscTools.CreateConstantID();
_preExtApp = Settings.Default.ConDefaultPreExtApp;
_postExtApp = Settings.Default.ConDefaultPostExtApp;
_macAddress = Settings.Default.ConDefaultMacAddress;
_userField = Settings.Default.ConDefaultUserField;
PreExtApp = Settings.Default.ConDefaultPreExtApp;
PostExtApp = Settings.Default.ConDefaultPostExtApp;
MacAddress = Settings.Default.ConDefaultMacAddress;
UserField = Settings.Default.ConDefaultUserField;
}
private void SetVncDefaults()
{
_vncCompression = (ProtocolVNC.Compression) Enum.Parse(typeof(ProtocolVNC.Compression), Settings.Default.ConDefaultVNCCompression);
_vncEncoding = (ProtocolVNC.Encoding) Enum.Parse(typeof(ProtocolVNC.Encoding), Settings.Default.ConDefaultVNCEncoding);
_vncAuthMode = (ProtocolVNC.AuthMode) Enum.Parse(typeof(ProtocolVNC.AuthMode), Settings.Default.ConDefaultVNCAuthMode);
_vncProxyType = (ProtocolVNC.ProxyType) Enum.Parse(typeof(ProtocolVNC.ProxyType), Settings.Default.ConDefaultVNCProxyType);
_vncProxyIp = Settings.Default.ConDefaultVNCProxyIP;
_vncProxyPort = Settings.Default.ConDefaultVNCProxyPort;
_vncProxyUsername = Settings.Default.ConDefaultVNCProxyUsername;
_vncProxyPassword = Settings.Default.ConDefaultVNCProxyPassword;
_vncColors = (ProtocolVNC.Colors) Enum.Parse(typeof(ProtocolVNC.Colors), Settings.Default.ConDefaultVNCColors);
_vncSmartSizeMode = (ProtocolVNC.SmartSizeMode) Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), Settings.Default.ConDefaultVNCSmartSizeMode);
_vncViewOnly = Settings.Default.ConDefaultVNCViewOnly;
VNCCompression = (ProtocolVNC.Compression) Enum.Parse(typeof(ProtocolVNC.Compression), Settings.Default.ConDefaultVNCCompression);
VNCEncoding = (ProtocolVNC.Encoding) Enum.Parse(typeof(ProtocolVNC.Encoding), Settings.Default.ConDefaultVNCEncoding);
VNCAuthMode = (ProtocolVNC.AuthMode) Enum.Parse(typeof(ProtocolVNC.AuthMode), Settings.Default.ConDefaultVNCAuthMode);
VNCProxyType = (ProtocolVNC.ProxyType) Enum.Parse(typeof(ProtocolVNC.ProxyType), Settings.Default.ConDefaultVNCProxyType);
VNCProxyIP = Settings.Default.ConDefaultVNCProxyIP;
VNCProxyPort = Settings.Default.ConDefaultVNCProxyPort;
VNCProxyUsername = Settings.Default.ConDefaultVNCProxyUsername;
VNCProxyPassword = Settings.Default.ConDefaultVNCProxyPassword;
VNCColors = (ProtocolVNC.Colors) Enum.Parse(typeof(ProtocolVNC.Colors), Settings.Default.ConDefaultVNCColors);
VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode) Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), Settings.Default.ConDefaultVNCSmartSizeMode);
VNCViewOnly = Settings.Default.ConDefaultVNCViewOnly;
}
private void SetNonBrowsablePropertiesDefaults()

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace mRemoteNG.Connection
{
public class ConnectionInfoComparer<TProperty> : IComparer<ConnectionInfo> where TProperty : IComparable<TProperty>
{
private readonly Func<ConnectionInfo, TProperty> _sortExpression;
public ListSortDirection SortDirection { get; set; } = ListSortDirection.Ascending;
public ConnectionInfoComparer(Func<ConnectionInfo, TProperty> sortExpression)
{
_sortExpression = sortExpression;
}
public int Compare(ConnectionInfo x, ConnectionInfo y)
{
return SortDirection == ListSortDirection.Ascending ? CompareAscending(x, y) : CompareDescending(x, y);
}
private int CompareAscending(ConnectionInfo x, ConnectionInfo y)
{
return _sortExpression(x).CompareTo(_sortExpression(y));
}
private int CompareDescending(ConnectionInfo x, ConnectionInfo y)
{
return _sortExpression(y).CompareTo(_sortExpression(x));
}
}
}

View File

@@ -305,9 +305,11 @@ namespace mRemoteNG.Connection
}
public ConnectionInfoInheritance Copy()
public ConnectionInfoInheritance Clone()
{
return (ConnectionInfoInheritance)MemberwiseClone();
var newInheritance = (ConnectionInfoInheritance) MemberwiseClone();
newInheritance._tempInheritanceStorage = null;
return newInheritance;
}
public void EnableInheritance()
@@ -330,7 +332,7 @@ namespace mRemoteNG.Connection
private void StashInheritanceData()
{
_tempInheritanceStorage = Copy();
_tempInheritanceStorage = Clone();
}
public void TurnOnInheritanceCompletely()

View File

@@ -0,0 +1,297 @@
using System;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Window;
using TabPage = Crownwood.Magic.Controls.TabPage;
namespace mRemoteNG.Connection
{
public static class ConnectionInitiator
{
public static void OpenConnection(ContainerInfo containerInfo)
{
OpenConnection(containerInfo, ConnectionInfo.Force.None);
}
public static void OpenConnection(ContainerInfo containerInfo, ConnectionInfo.Force force)
{
OpenConnection(containerInfo, force, null);
}
public static void OpenConnection(ContainerInfo containerInfo, ConnectionInfo.Force force, Form conForm)
{
var children = containerInfo.Children;
if (children.Count == 0) return;
foreach (var child in children)
{
var childAsContainer = child as ContainerInfo;
if (childAsContainer != null)
OpenConnection(childAsContainer, force, conForm);
else
OpenConnection(child, force, conForm);
}
}
public static void OpenConnection(ConnectionInfo connectionInfo)
{
try
{
OpenConnection(connectionInfo, ConnectionInfo.Force.None);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo connectionInfo, ConnectionInfo.Force force)
{
try
{
OpenConnection(connectionInfo, force, null);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
public static void OpenConnection(ConnectionInfo connectionInfo, ConnectionInfo.Force force, Form conForm)
{
try
{
if (connectionInfo.Hostname == "" && connectionInfo.Protocol != ProtocolType.IntApp)
{
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strConnectionOpenFailedNoHostname);
return;
}
StartPreConnectionExternalApp(connectionInfo);
if ((force & ConnectionInfo.Force.DoNotJump) != ConnectionInfo.Force.DoNotJump)
{
if (SwitchToOpenConnection(connectionInfo))
return;
}
var protocolFactory = new ProtocolFactory();
var newProtocol = protocolFactory.CreateProtocol(connectionInfo);
var connectionPanel = SetConnectionPanel(connectionInfo, force);
var connectionForm = SetConnectionForm(conForm, connectionPanel);
var connectionContainer = SetConnectionContainer(connectionInfo, connectionForm);
SetConnectionFormEventHandlers(newProtocol, connectionForm);
SetConnectionEventHandlers(newProtocol);
BuildConnectionInterfaceController(connectionInfo, newProtocol, connectionContainer);
newProtocol.Force = force;
if (newProtocol.Initialize() == false)
{
newProtocol.Close();
return;
}
if (newProtocol.Connect() == false)
{
newProtocol.Close();
return;
}
connectionInfo.OpenConnections.Add(newProtocol);
frmMain.Default.SelectedConnection = connectionInfo;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message);
}
}
private static void StartPreConnectionExternalApp(ConnectionInfo connectionInfo)
{
if (connectionInfo.PreExtApp != "")
{
var extA = Runtime.GetExtAppByName(connectionInfo.PreExtApp);
extA?.Start(connectionInfo);
}
}
public static bool SwitchToOpenConnection(ConnectionInfo nCi)
{
var IC = FindConnectionContainer(nCi);
if (IC != null)
{
var connectionWindow = (ConnectionWindow)IC.FindForm();
connectionWindow?.Focus();
var findForm = (ConnectionWindow)IC.FindForm();
findForm?.Show(frmMain.Default.pnlDock);
var tabPage = (TabPage)IC.Parent;
tabPage.Selected = true;
return true;
}
return false;
}
private static InterfaceControl FindConnectionContainer(ConnectionInfo connectionInfo)
{
if (connectionInfo.OpenConnections.Count > 0)
{
for (int i = 0; i <= Runtime.WindowList.Count - 1; i++)
{
if (Runtime.WindowList[i] is ConnectionWindow)
{
var connectionWindow = (ConnectionWindow)Runtime.WindowList[i];
if (connectionWindow.TabController != null)
{
foreach (TabPage t in connectionWindow.TabController.TabPages)
{
if (t.Controls[0] != null && t.Controls[0] is InterfaceControl)
{
var IC = (InterfaceControl)t.Controls[0];
if (IC.Info == connectionInfo)
{
return IC;
}
}
}
}
}
}
}
return null;
}
private static string SetConnectionPanel(ConnectionInfo connectionInfo, ConnectionInfo.Force Force)
{
string connectionPanel = "";
if (connectionInfo.Panel == "" || (Force & ConnectionInfo.Force.OverridePanel) == ConnectionInfo.Force.OverridePanel | Settings.Default.AlwaysShowPanelSelectionDlg)
{
frmChoosePanel frmPnl = new frmChoosePanel();
if (frmPnl.ShowDialog() == DialogResult.OK)
{
connectionPanel = frmPnl.Panel;
}
}
else
{
connectionPanel = connectionInfo.Panel;
}
return connectionPanel;
}
private static Form SetConnectionForm(Form conForm, string connectionPanel)
{
var connectionForm = conForm ?? Runtime.WindowList.FromString(connectionPanel);
if (connectionForm == null)
connectionForm = Runtime.AddPanel(connectionPanel);
else
((ConnectionWindow)connectionForm).Show(frmMain.Default.pnlDock);
connectionForm.Focus();
return connectionForm;
}
private static Control SetConnectionContainer(ConnectionInfo connectionInfo, Form connectionForm)
{
Control connectionContainer = ((ConnectionWindow)connectionForm).AddConnectionTab(connectionInfo);
if (connectionInfo.Protocol == ProtocolType.IntApp)
{
if (Runtime.GetExtAppByName(connectionInfo.ExtApp).Icon != null)
((TabPage)connectionContainer).Icon = Runtime.GetExtAppByName(connectionInfo.ExtApp).Icon;
}
return connectionContainer;
}
private static void SetConnectionFormEventHandlers(ProtocolBase newProtocol, Form connectionForm)
{
newProtocol.Closed += ((ConnectionWindow)connectionForm).Prot_Event_Closed;
}
private static void SetConnectionEventHandlers(ProtocolBase newProtocol)
{
newProtocol.Disconnected += Prot_Event_Disconnected;
newProtocol.Connected += Prot_Event_Connected;
newProtocol.Closed += Prot_Event_Closed;
newProtocol.ErrorOccured += Prot_Event_ErrorOccured;
}
private static void BuildConnectionInterfaceController(ConnectionInfo connectionInfo, ProtocolBase newProtocol, Control connectionContainer)
{
newProtocol.InterfaceControl = new InterfaceControl(connectionContainer, newProtocol, connectionInfo);
}
private static void Prot_Event_Disconnected(object sender, string disconnectedMessage)
{
try
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, disconnectedMessage), true);
var Prot = (ProtocolBase)sender;
if (Prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
var ReasonCode = disconnectedMessage.Split("\r\n".ToCharArray())[0];
var desc = disconnectedMessage.Replace("\r\n", " ");
if (Convert.ToInt32(ReasonCode) > 3)
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strRdpDisconnected + Environment.NewLine + desc);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strProtocolEventDisconnectFailed, ex.Message), true);
}
}
private static void Prot_Event_Closed(object sender)
{
try
{
var Prot = (ProtocolBase)sender;
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnenctionCloseEvent, true);
Runtime.MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnenctionClosedByUser, Prot.InterfaceControl.Info.Hostname, Prot.InterfaceControl.Info.Protocol.ToString(), Environment.UserName));
Prot.InterfaceControl.Info.OpenConnections.Remove(Prot);
if (Prot.InterfaceControl.Info.PostExtApp == "") return;
var extA = Runtime.GetExtAppByName(Prot.InterfaceControl.Info.PostExtApp);
extA?.Start(Prot.InterfaceControl.Info);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnenctionCloseEventFailed + Environment.NewLine + ex.Message, true);
}
}
private static void Prot_Event_Connected(object sender)
{
var prot = (ProtocolBase)sender;
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventConnected, true);
Runtime.MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol, Environment.UserName, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField));
}
private static void Prot_Event_ErrorOccured(object sender, string errorMessage)
{
try
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventErrorOccured, true);
var Prot = (ProtocolBase)sender;
if (Prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
if (Convert.ToInt32(errorMessage) > -1)
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, errorMessage, ProtocolRDP.FatalErrors.GetError(errorMessage)));
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionEventConnectionFailed + Environment.NewLine + ex.Message, true);
}
}
}
}

View File

@@ -1,68 +0,0 @@
using System;
using System.Collections;
namespace mRemoteNG.Connection
{
public class ConnectionList : CollectionBase
{
public ConnectionInfo this[object Index]
{
get
{
if (Index is ConnectionInfo)
return (ConnectionInfo)Index;
else
return ((ConnectionInfo) (List[Convert.ToInt32(Index)]));
}
}
public new int Count
{
get { return List.Count; }
}
public ConnectionInfo Add(ConnectionInfo connectionInfo)
{
List.Add(connectionInfo);
return connectionInfo;
}
public void AddRange(ConnectionInfo[] connectionInfoArray)
{
foreach (ConnectionInfo connectionInfo in connectionInfoArray)
{
List.Add(connectionInfo);
}
}
public ConnectionInfo FindByConstantID(string id)
{
foreach (ConnectionInfo connectionInfo in List)
{
if (connectionInfo.ConstantID == id)
return connectionInfo;
}
return null;
}
public ConnectionList Copy()
{
try
{
return (ConnectionList)MemberwiseClone();
}
catch (Exception)
{
}
return null;
}
public new void Clear()
{
List.Clear();
}
}
}

Some files were not shown because too many files have changed in this diff Show More