Compare commits

...

28 Commits

Author SHA1 Message Date
David Sparer
5bd43afcd3 refactored relationship between protocol objects and interfacecontrol 2018-02-11 20:35:14 -06:00
David Sparer
d85c46930f added class for testing rdp version suppport 2018-02-10 21:13:20 -06:00
David Sparer
4614de1dea renamed event invocation methods to be more descriptive 2018-02-10 20:42:59 -06:00
David Sparer
f33102d545 simplification of protocol base class 2018-02-10 20:38:46 -06:00
David Sparer
8003f410a7 support rdp client v6 through 10 2018-02-10 20:38:28 -06:00
David Sparer
b21dc9a062 began splitting rdp implementations by version so we can dynamically support whatever is on the user's machine 2018-02-09 16:52:19 -06:00
David Sparer
36ed189177 bit more refactoring 2018-02-09 15:25:55 -06:00
David Sparer
b3b961c647 moved rdp enums out of the rdp protocol class 2018-02-09 13:14:27 -06:00
David Sparer
a212121f4a moved all rdp enums to their own files 2018-02-09 13:14:27 -06:00
David Sparer
3d9d57b7fa adding several tool chain dependencies 2018-02-09 13:09:58 -06:00
David Sparer
2c1734aea6 change post-build scripts to use bin tools from the repo
this should prevent some build issues new devs have and gives us more control over our build process
2018-02-08 16:11:16 -06:00
David Sparer
301c39aad0 update copyright 2018-02-08 15:39:35 -06:00
David Sparer
5be346c89d changed a few localized strings used by the initial connection file not found dialog 2018-02-04 19:44:39 -06:00
David Sparer
e4eaf0037e fixed an issue that was making bug #479 reappear 2018-02-04 19:14:03 -06:00
David Sparer
8f97be82cb added some more safety around retrieving inherited values 2018-02-04 19:08:29 -06:00
David Sparer
4ab7f92b82 reapply the quick connect focus bug fix provided in #651 2018-02-04 18:13:18 -06:00
David Sparer
0ec95a7729 Merge branch '625_deserialize_csv' into develop 2018-02-04 17:59:49 -06:00
David Sparer
98c38716cd updated changelog 2018-02-04 17:59:15 -06:00
David Sparer
6a46df780c did some refactoring
made IConnectionImporter generic to cut down on code
2018-02-04 16:00:50 -06:00
David Sparer
7788198f26 fixed an issue with serializing csv data with semi colons in fields 2018-02-04 11:52:26 -06:00
David Sparer
3010963283 hooked up csv deserialization to ui 2018-02-04 11:39:04 -06:00
David Sparer
6522524c0f added serialization for a few more inheritance properties 2018-02-04 10:32:18 -06:00
David Sparer
160434c114 Merge branch 'develop' into 625_deserialize_csv 2018-02-04 09:33:33 -06:00
David Sparer
36acb9ac12 update develop branch download badge 2018-02-01 21:38:10 -06:00
Sean Kaim
ddbf6a2e7a ports from dev for appveyor build 2018-01-25 12:35:32 -05:00
Sean Kaim
8567e912a3 add citrixReceiver.exe for appveyor 2018-01-25 12:25:48 -05:00
Sean Kaim
7c98f2809c add appveyor.yml 2018-01-25 12:14:01 -05:00
David Sparer
0898ed8c00 began implementing csv deserializing 2017-12-04 22:00:18 -06:00
90 changed files with 2745 additions and 1562 deletions

View File

@@ -1,3 +1,14 @@
1.76.0 Alpha 3 (2018-xx-xx):
Features/Enhancements:
----------------------
#625: Added ability to import mRemoteNG formatted CSV files
Fixes:
------
1.76.0 Alpha 2 (2018-02-01):
Features/Enhancements:
@@ -24,6 +35,7 @@ Features/Enhancements:
#671: Revamped UI theme system
#611: Added multi-ssh toolbar for sending commands to many SSH clients at once
#558: Connection tree now shows customizable icons instead of play/pause icon
#519: You can now import normal mRemoteNG files - they do not have to be exports
#504: Added Korean translation
#485: The Domain field is now visible/editable for connection with the IntApp protocol
#468: Default connection info Panel property is now saved

View File

@@ -12,7 +12,7 @@
| ---------------|--------------|-----------|
| Stable | [![Build status](https://ci.appveyor.com/api/projects/status/k0sdbxmq90fgdmj6/branch/master?svg=true)](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [![Github Releases (by Release)](https://img.shields.io/github/downloads/mRemoteNG/mRemoteNG/v1.75.7011/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7011) |
| Beta | | [![Github Releases (by Release)](https://img.shields.io/github/downloads/mRemoteNG/mRemoteNG/v1.75.7011/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7011) |
| Development | [![Build status](https://ci.appveyor.com/api/projects/status/k0sdbxmq90fgdmj6/branch/develop?svg=true)](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | - |
| Development | [![Build status](https://ci.appveyor.com/api/projects/status/k0sdbxmq90fgdmj6/branch/develop?svg=true)](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [![Github Releases (by Release)](https://img.shields.io/github/downloads/mRemoteNG/mRemoteNG/v1.76Alpha2/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76Alpha2) |
mRemoteNG is the next generation of mRemote, a full-featured, multi-tab remote connections manager.

View File

@@ -5,7 +5,7 @@ setlocal enabledelayedexpansion
set SOLUTIONDIR=%~dp0..
rem Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
set SIGCHECK="%SOLUTIONDIR%\Tools\sigcheck.exe"
set SIGCHECK="%SOLUTIONDIR%\Tools\exes\sigcheck.exe"
set SEVENZIP="%SOLUTIONDIR%\Tools\7zip\7za.exe"
set VCVARSALL="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

BIN
Tools/exes/dumpbin.exe Normal file

Binary file not shown.

BIN
Tools/exes/editbin.exe Normal file

Binary file not shown.

BIN
Tools/exes/link.exe Normal file

Binary file not shown.

BIN
Tools/exes/mspdbcore.dll Normal file

Binary file not shown.

View File

@@ -1,3 +1,5 @@
[CmdletBinding()]
param (
[string]
# Name of the file to find
@@ -46,6 +48,7 @@ $rootSearchPaths = @(
# Returns the first full path to the $FileName that our search can find
foreach ($searchPath in $rootSearchPaths) {
foreach ($visualStudioFolder in $searchPath) {
Write-Verbose "Searching in folder '$visualStudioFolder'"
$matchingExes = [System.IO.Directory]::EnumerateFileSystemEntries($visualStudioFolder, $FileName, [System.IO.SearchOption]::AllDirectories)
foreach ($matchingExe in $matchingExes) {
if ((EditBinCertificateIsValid -Path $matchingExe) -and (ToolCanBeExecuted -Path $matchingExe)) {

View File

@@ -1,3 +1,5 @@
[CmdletBinding()]
param (
[string]
[Parameter(Mandatory=$true)]
@@ -10,13 +12,11 @@ param (
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# Find editbin.exe
$path_editBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "editbin.exe"
$path_editBin = Join-Path -Path $PSScriptRoot -ChildPath "exes\editbin.exe"
$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
# Set LargeAddressAware
Write-Output "Setting LargeAddressAware on binary file:`n`"$path_outputExe`" `nwith:`n`"$path_editBin`""
& $path_editBin "/largeaddressaware" "$path_outputExe"
& "$path_editBin" /largeaddressaware "$path_outputExe"
Write-Output ""

View File

@@ -1,3 +1,5 @@
[CmdletBinding()]
param (
[string]
[Parameter(Mandatory=$true)]
@@ -10,13 +12,11 @@ param (
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# Find editbin.exe
$path_dumpBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "dumpbin.exe"
$path_dumpBin = Join-Path -Path $PSScriptRoot -ChildPath "exes\dumpbin.exe"
$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
# Dump exe header
$output = & "$path_dumpBin" /NOLOGO /HEADERS $path_outputExe | Select-String large
$output = & "$path_dumpBin" /NOLOGO /HEADERS "$path_outputExe" | Select-String large
if ($output -eq $null)
{
@@ -27,6 +27,4 @@ else
Write-Output $output.ToString().TrimStart(" ")
}
Write-Output ""

View File

@@ -17,11 +17,11 @@ Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# validate release versions and if the certificate is available
if ($ConfigurationName -match "Release") {
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
{
if ($CertificatePath -eq "" -or !(Test-Path -Path $CertificatePath -PathType Leaf))
{
Write-Output "Certificate is not present - files likely not signed - we won't verify file signatures."
return
}
}
Write-Output "Verifying signature of binaries"
Write-Output "Getting files from path: $TargetDir"

View File

@@ -0,0 +1,170 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.MiscSerializers;
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.Credential;
using mRemoteNG.Security;
using NSubstitute;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
{
public class CsvConnectionsDeserializerMremotengFormatTests
{
private CsvConnectionsDeserializerMremotengFormat _deserializer;
private ICredentialRepositoryList _credentialRepositoryList;
[SetUp]
public void Setup()
{
_deserializer = new CsvConnectionsDeserializerMremotengFormat();
_credentialRepositoryList = Substitute.For<ICredentialRepositoryList>();
}
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.ConnectionPropertyTestCases))]
public object ConnectionPropertiesDeserializedCorrectly(string propertyToCheck)
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var csv = serializer.Serialize(GetTestConnection());
var deserializedConnections = _deserializer.Deserialize(csv);
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
var propertyValue = typeof(ConnectionInfo).GetProperty(propertyToCheck)?.GetValue(connection);
return propertyValue;
}
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.InheritanceTestCases))]
public object InheritancePropertiesDeserializedCorrectly(string propertyToCheck)
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var csv = serializer.Serialize(GetTestConnectionWithAllInherited());
var deserializedConnections = _deserializer.Deserialize(csv);
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
var propertyValue = typeof(ConnectionInfoInheritance).GetProperty(propertyToCheck)?.GetValue(connection?.Inheritance);
return propertyValue;
}
internal static ConnectionInfo GetTestConnection()
{
return new ConnectionInfo
{
Name = "SomeName",
Description = "SomeDescription",
Icon = "SomeIcon",
Panel = "SomePanel",
Username = "SomeUsername",
Password = "SomePassword",
Domain = "SomeDomain",
Hostname = "SomeHostname",
PuttySession = "SomePuttySession",
LoadBalanceInfo = "SomeLoadBalanceInfo",
PreExtApp = "SomePreExtApp",
PostExtApp = "SomePostExtApp",
MacAddress = "SomeMacAddress",
UserField = "SomeUserField",
ExtApp = "SomeExtApp",
VNCProxyUsername = "SomeVNCProxyUsername",
VNCProxyPassword = "SomeVNCProxyPassword",
RDGatewayUsername = "SomeRDGatewayUsername",
RDGatewayPassword = "SomeRDGatewayPassword",
RDGatewayDomain = "SomeRDGatewayDomain",
VNCProxyIP = "SomeVNCProxyIP",
RDGatewayHostname = "SomeRDGatewayHostname",
Protocol = ProtocolType.ICA,
Port = 999,
UseConsoleSession = true,
UseCredSsp = true,
RenderingEngine = HTTPBase.RenderingEngine.Gecko,
ICAEncryptionStrength = IcaProtocol.EncryptionStrength.Encr40Bit,
RDPAuthenticationLevel = RdpAuthenticationLevel.WarnOnFailedAuth,
Colors = RdpColors.Colors16Bit,
Resolution = RdpResolutions.Res1366x768,
AutomaticResize = true,
DisplayWallpaper = true,
DisplayThemes = true,
EnableFontSmoothing = true,
EnableDesktopComposition = true,
CacheBitmaps = true,
RedirectDiskDrives = true,
RedirectPorts = true,
RedirectPrinters = true,
RedirectSmartCards = true,
RedirectSound = RdpSounds.LeaveAtRemoteComputer,
RedirectKeys = true,
VNCCompression = ProtocolVNC.Compression.Comp4,
VNCEncoding = ProtocolVNC.Encoding.EncRRE,
VNCAuthMode = ProtocolVNC.AuthMode.AuthVNC,
VNCProxyType = ProtocolVNC.ProxyType.ProxySocks5,
VNCProxyPort = 123,
VNCColors = ProtocolVNC.Colors.Col8Bit,
VNCSmartSizeMode = ProtocolVNC.SmartSizeMode.SmartSAspect,
VNCViewOnly = true,
RDGatewayUsageMethod = RDGatewayUsageMethod.Detect,
RDGatewayUseConnectionCredentials = RDGatewayUseConnectionCredentials.SmartCard
};
}
internal static ConnectionInfo GetTestConnectionWithAllInherited()
{
var connectionInfo = new ConnectionInfo();
connectionInfo.Inheritance.TurnOnInheritanceCompletely();
return connectionInfo;
}
private class DeserializationTestSource
{
public static IEnumerable ConnectionPropertyTestCases()
{
var ignoreProperties = new[]
{
nameof(ConnectionInfo.Inheritance),
nameof(ConnectionInfo.ConstantID),
nameof(ConnectionInfo.Parent)
};
var properties = typeof(ConnectionInfo)
.GetProperties()
.Where(property => !ignoreProperties.Contains(property.Name));
var testCases = new List<TestCaseData>();
var testConnectionInfo = GetTestConnection();
foreach (var property in properties)
{
testCases.Add(
new TestCaseData(property.Name)
.Returns(property.GetValue(testConnectionInfo)));
}
return testCases;
}
public static IEnumerable InheritanceTestCases()
{
var ignoreProperties = new[]
{
nameof(ConnectionInfoInheritance.EverythingInherited),
nameof(ConnectionInfoInheritance.Parent)
};
var properties = typeof(ConnectionInfoInheritance)
.GetProperties()
.Where(property => !ignoreProperties.Contains(property.Name));
var testCases = new List<TestCaseData>();
var testInheritance = GetTestConnectionWithAllInherited().Inheritance;
foreach (var property in properties)
{
testCases.Add(
new TestCaseData(property.Name)
.Returns(property.GetValue(testInheritance)));
}
return testCases;
}
}
}
}

View File

@@ -8,7 +8,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
{
public class RemoteDesktopConnectionDeserializerTests
public class RemoteDesktopConnectionDeserializerTests
{
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
private RemoteDesktopConnectionDeserializer _deserializer;
@@ -18,9 +18,9 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
private const string ExpectedDomain = "myspecialdomain";
private const string ExpectedGatewayHostname = "gatewayhostname.domain.com";
private const int ExpectedPort = 9933;
private const RdpProtocol.RDPColors ExpectedColors = RdpProtocol.RDPColors.Colors24Bit;
private const RdpColors ExpectedColors = RdpColors.Colors24Bit;
private const bool ExpectedBitmapCaching = false;
private const RdpProtocol.RDPResolutions ExpectedResolutionMode = RdpProtocol.RDPResolutions.FitToWindow;
private const RdpResolutions ExpectedResolutionMode = RdpResolutions.FitToWindow;
private const bool ExpectedWallpaperDisplay = true;
private const bool ExpectedThemesDisplay = true;
private const bool ExpectedFontSmoothing = true;
@@ -29,7 +29,7 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
private const bool ExpectedDriveRedirection = true;
private const bool ExpectedPortRedirection = true;
private const bool ExpectedPrinterRedirection = true;
private const RdpProtocol.RDPSounds ExpectedSoundRedirection = RdpProtocol.RDPSounds.BringToThisComputer;
private const RdpSounds ExpectedSoundRedirection = RdpSounds.BringToThisComputer;
[OneTimeSetUp]

View File

@@ -10,7 +10,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
{
public class RemoteDesktopConnectionManager27DeserializerTests
public class RemoteDesktopConnectionManager27DeserializerTests
{
private string _connectionFileContents;
private RemoteDesktopConnectionManagerDeserializer _deserializer;
@@ -23,20 +23,20 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
private const string ExpectedPassword = "passwordHere!";
private const bool ExpectedUseConsoleSession = true;
private const int ExpectedPort = 9933;
private const RdpProtocol.RDGatewayUsageMethod ExpectedGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
private const RDGatewayUsageMethod ExpectedGatewayUsageMethod = 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 RdpProtocol.RDPResolutions ExpectedRdpResolution = RdpProtocol.RDPResolutions.FitToWindow;
private const RdpProtocol.RDPColors ExpectedRdpColorDepth = RdpProtocol.RDPColors.Colors24Bit;
private const RdpProtocol.RDPSounds ExpectedAudioRedirection = RdpProtocol.RDPSounds.DoNotPlay;
private const RdpResolutions ExpectedRdpResolution = RdpResolutions.FitToWindow;
private const RdpColors ExpectedRdpColorDepth = RdpColors.Colors24Bit;
private const RdpSounds ExpectedAudioRedirection = 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 RdpProtocol.AuthenticationLevel ExpectedAuthLevel = RdpProtocol.AuthenticationLevel.WarnOnFailedAuth;
private const RdpAuthenticationLevel ExpectedAuthLevel = RdpAuthenticationLevel.WarnOnFailedAuth;
[OneTimeSetUp]

View File

@@ -10,7 +10,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
{
public class RemoteDesktopConnectionManagerDeserializerTests
public class RemoteDesktopConnectionManagerDeserializerTests
{
private string _connectionFileContents;
private RemoteDesktopConnectionManagerDeserializer _deserializer;
@@ -23,20 +23,20 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
private const string ExpectedPassword = "passwordHere!";
private const bool ExpectedUseConsoleSession = true;
private const int ExpectedPort = 9933;
private const RdpProtocol.RDGatewayUsageMethod ExpectedGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
private const RDGatewayUsageMethod ExpectedGatewayUsageMethod = 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 RdpProtocol.RDPResolutions ExpectedRdpResolution = RdpProtocol.RDPResolutions.FitToWindow;
private const RdpProtocol.RDPColors ExpectedRdpColorDepth = RdpProtocol.RDPColors.Colors24Bit;
private const RdpProtocol.RDPSounds ExpectedAudioRedirection = RdpProtocol.RDPSounds.DoNotPlay;
private const RdpResolutions ExpectedRdpResolution = RdpResolutions.FitToWindow;
private const RdpColors ExpectedRdpColorDepth = RdpColors.Colors24Bit;
private const RdpSounds ExpectedAudioRedirection = 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 RdpProtocol.AuthenticationLevel ExpectedAuthLevel = RdpProtocol.AuthenticationLevel.AuthRequired;
private const RdpAuthenticationLevel ExpectedAuthLevel = RdpAuthenticationLevel.AuthRequired;
[OneTimeSetUp]

View File

@@ -9,7 +9,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.Connection
{
public class AbstractConnectionInfoDataTests
public class AbstractConnectionInfoDataTests
{
#pragma warning disable 618
private class TestAbstractConnectionInfoData : AbstractConnectionRecord {}
@@ -160,7 +160,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.AuthRequired;
_testAbstractConnectionInfoData.RDPAuthenticationLevel = RdpAuthenticationLevel.AuthRequired;
Assert.That(wasCalled, Is.True);
}
@@ -196,7 +196,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
_testAbstractConnectionInfoData.RDGatewayUsageMethod = RDGatewayUsageMethod.Always;
Assert.That(wasCalled, Is.True);
}
@@ -214,7 +214,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard;
_testAbstractConnectionInfoData.RDGatewayUseConnectionCredentials = RDGatewayUseConnectionCredentials.SmartCard;
Assert.That(wasCalled, Is.True);
}
@@ -250,7 +250,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Resolution = RdpProtocol.RDPResolutions.Res1366x768;
_testAbstractConnectionInfoData.Resolution = RdpResolutions.Res1366x768;
Assert.That(wasCalled, Is.True);
}
@@ -268,7 +268,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Colors = RdpProtocol.RDPColors.Colors16Bit;
_testAbstractConnectionInfoData.Colors = RdpColors.Colors16Bit;
Assert.That(wasCalled, Is.True);
}
@@ -367,7 +367,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
_testAbstractConnectionInfoData.RedirectSound = RdpSounds.DoNotPlay;
Assert.That(wasCalled, Is.True);
}

View File

@@ -81,7 +81,7 @@ namespace mRemoteNGTests.Connection
{
var eventWasCalled = false;
_connectionInfo.PropertyChanged += (sender, args) => eventWasCalled = true;
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionInfo));
Assert.That(eventWasCalled);
}
@@ -90,7 +90,7 @@ namespace mRemoteNGTests.Connection
{
var nameOfModifiedProperty = "";
_connectionInfo.PropertyChanged += (sender, args) => nameOfModifiedProperty = args.PropertyName;
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionInfo));
Assert.That(nameOfModifiedProperty, Is.EqualTo("OpenConnections"));
}

View File

@@ -1,5 +1,4 @@
using System.Collections.ObjectModel;
using mRemoteNG.App;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tools;
@@ -12,7 +11,7 @@ namespace mRemoteNGTests.Connection.Protocol
{
public class IntegratedProgramTests
{
private readonly ExternalTool _extTool = new ExternalTool
private readonly ExternalTool _extTool = new ExternalTool
{
DisplayName = "notepad",
FileName = @"%windir%\system32\notepad.exe",
@@ -20,13 +19,13 @@ namespace mRemoteNGTests.Connection.Protocol
TryIntegrate = true
};
[Test]
public void CanStartExternalApp()
{
SetExternalToolList(_extTool);
var sut = new IntegratedProgram();
sut.InterfaceControl = BuildInterfaceControl("notepad", sut);
var connectionInfo = new ConnectionInfo { ExtApp = _extTool.DisplayName };
var sut = new IntegratedProgram(connectionInfo);
sut.InterfaceControl = BuildInterfaceControl(sut);
sut.Initialize();
var appStarted = sut.Connect();
sut.Disconnect();
@@ -37,8 +36,9 @@ namespace mRemoteNGTests.Connection.Protocol
public void ConnectingToExternalAppThatDoesntExistDoesNothing()
{
SetExternalToolList(_extTool);
var sut = new IntegratedProgram();
sut.InterfaceControl = BuildInterfaceControl("doesntExist", sut);
var connectionInfo = new ConnectionInfo { ExtApp = "doesntExist" };
var sut = new IntegratedProgram(connectionInfo);
sut.InterfaceControl = BuildInterfaceControl(sut);
var appInitialized = sut.Initialize();
Assert.That(appInitialized, Is.False);
}
@@ -48,11 +48,10 @@ namespace mRemoteNGTests.Connection.Protocol
Runtime.ExternalToolsService.ExternalTools = new FullyObservableCollection<ExternalTool> {externalTool};
}
private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut)
private InterfaceControl BuildInterfaceControl(ProtocolBase sut)
{
var connectionWindow = new ConnectionWindow(new DockContent());
var connectionInfo = new ConnectionInfo {ExtApp = extAppName};
return new InterfaceControl(connectionWindow, sut, connectionInfo);
return new InterfaceControl(connectionWindow, sut);
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Specialized;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.SSH;
using mRemoteNG.Connection.Protocol.Telnet;
@@ -21,9 +22,9 @@ namespace mRemoteNGTests.Connection.Protocol
public void Setup()
{
_protocolList = new ProtocolList();
_protocol1 = new ProtocolTelnet();
_protocol2 = new ProtocolSSH2();
_protocol3 = new ProtocolVNC();
_protocol1 = new ProtocolTelnet(new ConnectionInfo());
_protocol2 = new ProtocolSSH2(new ConnectionInfo());
_protocol3 = new ProtocolVNC(new ConnectionInfo());
}
[TearDown]

View File

@@ -121,6 +121,7 @@
<Compile Include="Config\Serializers\CredentialProviderSerializerTests.cs" />
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialPasswordDecryptorDecoratorTests.cs" />
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialPasswordEncryptorDecoratorTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\CsvConnectionsDeserializerMremotengFormatTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\CsvConnectionsSerializerMremotengFormatTests.cs" />
<Compile Include="Config\Serializers\DataTableSerializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\PortScanDeserializerTests.cs" />

View File

@@ -7,22 +7,10 @@ using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
using mRemoteNG.Tools;
namespace mRemoteNG.App
{
public static class Import
{
private enum FileType
{
Unknown = 0,
// ReSharper disable once InconsistentNaming
mRemoteXml,
RemoteDesktopConnection,
RemoteDesktopConnectionManager,
PuttyConnectionManager
}
#region Public Methods
public static void ImportFromFile(ContainerInfo importDestinationContainer)
{
try
@@ -34,8 +22,9 @@ namespace mRemoteNG.App
openFileDialog.Multiselect = true;
var fileTypes = new List<string>();
fileTypes.AddRange(new[] {Language.strFilterAllImportable, "*.xml;*.rdp;*.rdg;*.dat"});
fileTypes.AddRange(new[] {Language.strFilterAllImportable, "*.xml;*.rdp;*.rdg;*.dat;*.csv"});
fileTypes.AddRange(new[] {Language.strFiltermRemoteXML, "*.xml"});
fileTypes.AddRange(new[] {Language.strFiltermRemoteCSV, "*.csv"});
fileTypes.AddRange(new[] {Language.strFilterRDP, "*.rdp"});
fileTypes.AddRange(new[] {Language.strFilterRdgFiles, "*.rdg"});
fileTypes.AddRange(new[] {Language.strFilterPuttyConnectionManager, "*.dat"});
@@ -50,32 +39,14 @@ namespace mRemoteNG.App
{
try
{
IConnectionImporter importer;
// ReSharper disable once SwitchStatementMissingSomeCases
switch (DetermineFileType(fileName))
{
case FileType.mRemoteXml:
importer = new mRemoteNGImporter();
break;
case FileType.RemoteDesktopConnection:
importer = new RemoteDesktopConnectionImporter();
break;
case FileType.RemoteDesktopConnectionManager:
importer = new RemoteDesktopConnectionManagerImporter();
break;
case FileType.PuttyConnectionManager:
importer = new PuttyConnectionManagerImporter();
break;
default:
throw new FileFormatException("Unrecognized file format.");
}
var importer = BuildConnectionImporterFromFileExtension(fileName);
importer.Import(fileName, importDestinationContainer);
}
catch (Exception ex)
{
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromFile() failed:1", ex);
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
}
}
@@ -84,15 +55,15 @@ namespace mRemoteNG.App
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromFile() failed:2", ex);
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
}
}
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOU)
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
{
try
{
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOU);
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOu);
Runtime.ConnectionsService.SaveConnectionsAsync();
}
catch (Exception ex)
@@ -114,25 +85,25 @@ namespace mRemoteNG.App
Runtime.MessageCollector.AddExceptionMessage("App.Import.ImportFromPortScan() failed.", ex);
}
}
#endregion
private static FileType DetermineFileType(string fileName)
private static IConnectionImporter<string> BuildConnectionImporterFromFileExtension(string fileName)
{
// TODO: Use the file contents to determine the file type instead of trusting the extension
var extension = Path.GetExtension(fileName);
if (extension == null) return FileType.Unknown;
var extension = Path.GetExtension(fileName) ?? "";
switch (extension.ToLowerInvariant())
{
case ".xml":
return FileType.mRemoteXml;
return new MRemoteNGXmlImporter();
case ".csv":
return new MRemoteNGCsvImporter();
case ".rdp":
return FileType.RemoteDesktopConnection;
return new RemoteDesktopConnectionImporter();
case ".rdg":
return FileType.RemoteDesktopConnectionManager;
return new RemoteDesktopConnectionManagerImporter();
case ".dat":
return FileType.PuttyConnectionManager;
return new PuttyConnectionManagerImporter();
default:
return FileType.Unknown;
throw new FileFormatException("Unrecognized file format.");
}
}
}

View File

@@ -147,7 +147,14 @@ namespace mRemoteNG.App
{
try
{
CTaskDialog.ShowTaskDialogBox(GeneralAppInfo.ProductName, Language.ConfigurationFileNotFound, "", "", "", "", "", string.Join(" | ", commandButtons), ETaskDialogButtons.None, ESysIcons.Question, ESysIcons.Question);
CTaskDialog.ShowTaskDialogBox(
GeneralAppInfo.ProductName,
Language.ConnectionFileNotFound,
"", "", "", "", "",
string.Join(" | ", commandButtons),
ETaskDialogButtons.None,
ESysIcons.Question,
ESysIcons.Question);
switch (CTaskDialog.CommandButtonResult)
{

View File

@@ -20,6 +20,10 @@ namespace mRemoteNG.Config.DataProviders
{
fileContents = File.ReadAllText(FilePath);
}
catch (FileNotFoundException ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Could not load file. File does not exist '{FilePath}'", ex);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);

View File

@@ -3,24 +3,23 @@ using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
using mRemoteNG.Tools;
namespace mRemoteNG.Config.Import
{
public class ActiveDirectoryImporter : IConnectionImporter
public class ActiveDirectoryImporter : IConnectionImporter<string>
{
public void Import(object ldapPath, ContainerInfo destinationContainer)
public void Import(string ldapPath, ContainerInfo destinationContainer)
{
var ldapPathAsString = ldapPath as string;
if (ldapPathAsString == null) return;
Import(ldapPathAsString, destinationContainer);
Import(ldapPath, destinationContainer, false);
}
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOU = false)
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
{
try
{
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOU);
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
var connectionTreeModel = deserializer.Deserialize();
var importedRootNode = connectionTreeModel.RootNodes.First();
if (importedRootNode == null) return;

View File

@@ -1,10 +1,10 @@
using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public interface IConnectionImporter
public interface IConnectionImporter<in TSource>
where TSource : class
{
void Import(object source, ContainerInfo destinationContainer);
void Import(TSource source, ContainerInfo destinationContainer);
}
}

View File

@@ -1,42 +1,34 @@
using System.IO;
using System.IO;
using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.MiscSerializers;
using mRemoteNG.Container;
using mRemoteNG.Messages;
namespace mRemoteNG.Config.Import
{
// ReSharper disable once InconsistentNaming
public class mRemoteNGImporter : IConnectionImporter
{
public void Import(object filePath, ContainerInfo destinationContainer)
{
var filePathAsString = filePath as string;
if (filePathAsString == null)
{
public class MRemoteNGCsvImporter : IConnectionImporter<string>
{
public void Import(string filePath, ContainerInfo destinationContainer)
{
if (string.IsNullOrEmpty(filePath))
{
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}");
}
if (!File.Exists(filePath))
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
public void Import(string fileName, ContainerInfo destinationContainer)
{
var dataProvider = new FileDataProvider(fileName);
var dataProvider = new FileDataProvider(filePath);
var xmlString = dataProvider.Load();
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
var xmlConnectionsDeserializer = new CsvConnectionsDeserializerMremotengFormat();
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString);
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
destinationContainer.AddChild(rootImportContainer);
}
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.IO;
using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Container;
using mRemoteNG.Messages;
namespace mRemoteNG.Config.Import
{
// ReSharper disable once InconsistentNaming
public class MRemoteNGXmlImporter : IConnectionImporter<string>
{
public void Import(string fileName, ContainerInfo destinationContainer)
{
if (fileName == null)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
return;
}
if(!File.Exists(fileName))
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {fileName}");
var dataProvider = new FileDataProvider(fileName);
var xmlString = dataProvider.Load();
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
destinationContainer.AddChild(rootImportContainer);
}
}
}

View File

@@ -8,7 +8,7 @@ using mRemoteNG.Tools;
namespace mRemoteNG.Config.Import
{
public class PortScanImporter : IConnectionImporter
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
{
private readonly ProtocolType _targetProtocolType;
@@ -17,13 +17,6 @@ namespace mRemoteNG.Config.Import
_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(_targetProtocolType);

View File

@@ -1,4 +1,3 @@
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
@@ -7,17 +6,8 @@ using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class PuttyConnectionManagerImporter : IConnectionImporter
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
{
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);

View File

@@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
@@ -8,17 +7,8 @@ using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnectionImporter : IConnectionImporter
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
{
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);

View File

@@ -1,4 +1,3 @@
using System.IO;
using System.Linq;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
@@ -7,18 +6,9 @@ using mRemoteNG.Container;
namespace mRemoteNG.Config.Import
{
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
{
public void Import(object filePath, ContainerInfo destinationContainer)
{
var fileNameAsString = filePath as string;
if (fileNameAsString == null)
return;
if (File.Exists(fileNameAsString))
Import(fileNameAsString, destinationContainer);
}
private static void Import(string filePath, ContainerInfo destinationContainer)
public void Import(string filePath, ContainerInfo destinationContainer)
{
var dataProvider = new FileDataProvider(filePath);
var fileContent = dataProvider.Load();

View File

@@ -219,7 +219,7 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion < 1.1) //1.0 - 0.1
{
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value) ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.RDPResolutions.FitToWindow;
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value) ? RdpResolutions.Fullscreen : RdpResolutions.FitToWindow;
}
if (_confVersion <= 2.6) // 0.2 - 2.6
@@ -249,7 +249,7 @@ namespace mRemoteNG.Config.Serializers
}
else
{
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
connectionInfo.Port = (int)RdpProtocol6.Defaults.Port;
connectionInfo.Protocol = ProtocolType.RDP;
}
@@ -269,7 +269,7 @@ namespace mRemoteNG.Config.Serializers
if (Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value))
connectionInfo.Port = (int)ProtocolVNC.Defaults.Port;
else
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
connectionInfo.Port = (int)RdpProtocol6.Defaults.Port;
}
connectionInfo.UseConsoleSession = false;
}
@@ -307,34 +307,34 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.3)
{
connectionInfo.Colors = (RdpProtocol.RDPColors)MiscTools.StringToEnum(typeof(RdpProtocol.RDPColors), xmlnode.Attributes["Colors"].Value);
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)MiscTools.StringToEnum(typeof(RdpProtocol.RDPResolutions), Convert.ToString(xmlnode.Attributes["Resolution"].Value));
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)MiscTools.StringToEnum(typeof(RdpProtocol.RDPSounds), Convert.ToString(xmlnode.Attributes["RedirectSound"].Value));
connectionInfo.Colors = (RdpColors)MiscTools.StringToEnum(typeof(RdpColors), xmlnode.Attributes["Colors"].Value);
connectionInfo.Resolution = (RdpResolutions)MiscTools.StringToEnum(typeof(RdpResolutions), Convert.ToString(xmlnode.Attributes["Resolution"].Value));
connectionInfo.RedirectSound = (RdpSounds)MiscTools.StringToEnum(typeof(RdpSounds), Convert.ToString(xmlnode.Attributes["RedirectSound"].Value));
}
else
{
switch (Convert.ToInt32(xmlnode.Attributes["Colors"].Value))
{
case 0:
connectionInfo.Colors = RdpProtocol.RDPColors.Colors256;
connectionInfo.Colors = RdpColors.Colors256;
break;
case 1:
connectionInfo.Colors = RdpProtocol.RDPColors.Colors16Bit;
connectionInfo.Colors = RdpColors.Colors16Bit;
break;
case 2:
connectionInfo.Colors = RdpProtocol.RDPColors.Colors24Bit;
connectionInfo.Colors = RdpColors.Colors24Bit;
break;
case 3:
connectionInfo.Colors = RdpProtocol.RDPColors.Colors32Bit;
connectionInfo.Colors = RdpColors.Colors32Bit;
break;
// ReSharper disable once RedundantCaseLabel
case 4:
default:
connectionInfo.Colors = RdpProtocol.RDPColors.Colors15Bit;
connectionInfo.Colors = RdpColors.Colors15Bit;
break;
}
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Convert.ToInt32(xmlnode.Attributes["RedirectSound"].Value);
connectionInfo.RedirectSound = (RdpSounds)Convert.ToInt32(xmlnode.Attributes["RedirectSound"].Value);
}
if (_confVersion >= 1.3)
@@ -421,7 +421,7 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.8)
{
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)MiscTools.StringToEnum(typeof(RdpProtocol.AuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value);
connectionInfo.RDPAuthenticationLevel = (RdpAuthenticationLevel)MiscTools.StringToEnum(typeof(RdpAuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value);
connectionInfo.Inheritance.RDPAuthenticationLevel = bool.Parse(xmlnode.Attributes["InheritRDPAuthenticationLevel"].Value);
}
@@ -448,9 +448,9 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.2)
{
// Get settings
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)MiscTools.StringToEnum(typeof(RdpProtocol.RDGatewayUsageMethod), Convert.ToString(xmlnode.Attributes["RDGatewayUsageMethod"].Value));
connectionInfo.RDGatewayUsageMethod = (RDGatewayUsageMethod)MiscTools.StringToEnum(typeof(RDGatewayUsageMethod), Convert.ToString(xmlnode.Attributes["RDGatewayUsageMethod"].Value));
connectionInfo.RDGatewayHostname = xmlnode.Attributes["RDGatewayHostname"].Value;
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)MiscTools.StringToEnum(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), Convert.ToString(xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value));
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)MiscTools.StringToEnum(typeof(RDGatewayUseConnectionCredentials), Convert.ToString(xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value));
connectionInfo.RDGatewayUsername = xmlnode.Attributes["RDGatewayUsername"].Value;
connectionInfo.RDGatewayPassword = _decryptor.Decrypt(Convert.ToString(xmlnode.Attributes["RDGatewayPassword"].Value));
connectionInfo.RDGatewayDomain = xmlnode.Attributes["RDGatewayDomain"].Value;
@@ -492,7 +492,7 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.6)
{
connectionInfo.ConstantID = xmlnode.Attributes["Id"]?.Value ?? connectionInfo.ConstantID;
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)MiscTools.StringToEnum(typeof(RdpProtocol.RDPSoundQuality), Convert.ToString(xmlnode.Attributes["SoundQuality"].Value));
connectionInfo.SoundQuality = (RdpSoundQuality)MiscTools.StringToEnum(typeof(RdpSoundQuality), Convert.ToString(xmlnode.Attributes["SoundQuality"].Value));
connectionInfo.Inheritance.SoundQuality = bool.Parse(xmlnode.Attributes["InheritSoundQuality"].Value);
connectionInfo.RDPMinutesToIdleTimeout = Convert.ToInt32(xmlnode.Attributes["RDPMinutesToIdleTimeout"]?.Value ?? "0");
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = bool.Parse(xmlnode.Attributes["InheritRDPMinutesToIdleTimeout"]?.Value ?? "False");

View File

@@ -15,7 +15,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
{
public ConnectionTreeModel Deserialize(DataTable table)
{
@@ -85,12 +85,12 @@ namespace mRemoteNG.Config.Serializers
connectionInfo.UseCredSsp = (bool)dataRow["UseCredSsp"];
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), (string)dataRow["RenderingEngine"]);
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength), (string)dataRow["ICAEncryptionStrength"]);
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
connectionInfo.RDPAuthenticationLevel = (RdpAuthenticationLevel)Enum.Parse(typeof(RdpAuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
connectionInfo.RDPAlertIdleTimeout = (bool)dataRow["RDPAlertIdleTimeout"];
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors) ,(string)dataRow["Colors"]);
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), (string)dataRow["Resolution"]);
connectionInfo.Colors = (RdpColors)Enum.Parse(typeof(RdpColors) ,(string)dataRow["Colors"]);
connectionInfo.Resolution = (RdpResolutions)Enum.Parse(typeof(RdpResolutions), (string)dataRow["Resolution"]);
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
@@ -101,8 +101,8 @@ namespace mRemoteNG.Config.Serializers
connectionInfo.RedirectPorts = (bool)dataRow["RedirectPorts"];
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), (string)dataRow["SoundQuality"]);
connectionInfo.RedirectSound = (RdpSounds)Enum.Parse(typeof(RdpSounds), (string)dataRow["RedirectSound"]);
connectionInfo.SoundQuality = (RdpSoundQuality)Enum.Parse(typeof(RdpSoundQuality), (string)dataRow["SoundQuality"]);
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
connectionInfo.PleaseConnect = (bool)dataRow["Connected"];
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
@@ -121,9 +121,9 @@ namespace mRemoteNG.Config.Serializers
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), (string)dataRow["VNCSmartSizeMode"]);
connectionInfo.VNCViewOnly = (bool)dataRow["VNCViewOnly"];
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
connectionInfo.RDGatewayUsageMethod = (RDGatewayUsageMethod)Enum.Parse(typeof(RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
connectionInfo.RDGatewayPassword = (string)dataRow["RDGatewayPassword"];
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];

View File

@@ -5,6 +5,7 @@ using mRemoteNG.App;
using mRemoteNG.Config.Import;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
@@ -14,12 +15,12 @@ namespace mRemoteNG.Config.Serializers
public class ActiveDirectoryDeserializer
{
private readonly string _ldapPath;
private readonly bool _importSubOU;
private readonly bool _importSubOu;
public ActiveDirectoryDeserializer(string ldapPath, bool importSubOU)
public ActiveDirectoryDeserializer(string ldapPath, bool importSubOu)
{
_ldapPath = ldapPath;
_importSubOU = importSubOU;
_ldapPath = ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
_importSubOu = importSubOu;
}
public ConnectionTreeModel Deserialize()
@@ -64,9 +65,10 @@ namespace mRemoteNG.Config.Serializers
if (directoryEntry.Properties["objectClass"].Contains("organizationalUnit"))
{
// check/continue here so we don't create empty connection objects
if(!_importSubOU) continue;
if(!_importSubOu) continue;
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOU);
// TODO - this is a circular call. A deserializer should not call an importer
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOu);
continue;
}

View File

@@ -0,0 +1,690 @@
using System;
using System.Collections.Generic;
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.MiscSerializers
{
public class CsvConnectionsDeserializerMremotengFormat : IDeserializer<string, ConnectionTreeModel>
{
public ConnectionTreeModel Deserialize(string serializedData)
{
var root = new RootNodeInfo(RootNodeType.Connection);
var lines = serializedData.Split(new []{"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
var csvHeaders = new List<string>();
for (var lineNumber = 0; lineNumber < lines.Length; lineNumber++)
{
var line = lines[lineNumber].Split(';');
if (lineNumber == 0)
csvHeaders = line.ToList();
else
{
var connectionInfo = ParseConnectionInfo(csvHeaders, line);
var folder = ParseConnectionFolder(line[csvHeaders.IndexOf("Folder")], root);
folder.AddChild(connectionInfo);
}
}
var connectionTreeModel = new ConnectionTreeModel();
connectionTreeModel.AddRootNode(root);
return connectionTreeModel;
}
private ContainerInfo ParseConnectionFolder(string folderString, ContainerInfo rootContainer)
{
var containerNames = folderString.Split('\\');
var parentContainer = rootContainer;
for (var i = containerNames.Length - 2; i >= 0; i--)
{
var containerName = containerNames[i];
var container = parentContainer.Children.OfType<ContainerInfo>().FirstOrDefault(info => info.Name == containerName);
if (container == null)
{
container = new ContainerInfo {Name = containerName};
parentContainer.AddChild(container);
}
parentContainer = container;
}
return parentContainer;
}
private ConnectionInfo ParseConnectionInfo(IList<string> headers, string[] connectionCsv)
{
var connectionRecord = new ConnectionInfo();
connectionRecord.Name = headers.Contains("Name") ? connectionCsv[headers.IndexOf("Name")] : "";
connectionRecord.Description = headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
connectionRecord.Icon = headers.Contains("Icon") ? connectionCsv[headers.IndexOf("Icon")] : "";
connectionRecord.Panel = headers.Contains("Panel") ? connectionCsv[headers.IndexOf("Panel")] : "";
connectionRecord.Username = headers.Contains("Username") ? connectionCsv[headers.IndexOf("Username")] : "";
connectionRecord.Password = headers.Contains("Password") ? connectionCsv[headers.IndexOf("Password")] : "";
connectionRecord.Domain = headers.Contains("Domain") ? connectionCsv[headers.IndexOf("Domain")] : "";
connectionRecord.Hostname = headers.Contains("Hostname") ? connectionCsv[headers.IndexOf("Hostname")] : "";
connectionRecord.PuttySession = headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo") ? connectionCsv[headers.IndexOf("LoadBalanceInfo")] : "";
connectionRecord.PreExtApp = headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
connectionRecord.PostExtApp = headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
connectionRecord.MacAddress = headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
connectionRecord.UserField = headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
connectionRecord.ExtApp = headers.Contains("ExtApp") ? connectionCsv[headers.IndexOf("ExtApp")] : "";
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername") ? connectionCsv[headers.IndexOf("VNCProxyUsername")] : "";
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword") ? connectionCsv[headers.IndexOf("VNCProxyPassword")] : "";
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername") ? connectionCsv[headers.IndexOf("RDGatewayUsername")] : "";
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword") ? connectionCsv[headers.IndexOf("RDGatewayPassword")] : "";
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain") ? connectionCsv[headers.IndexOf("RDGatewayDomain")] : "";
connectionRecord.VNCProxyIP = headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname") ? connectionCsv[headers.IndexOf("RDGatewayHostname")] : "";
if (headers.Contains("Protocol"))
{
ProtocolType protocolType;
if (Enum.TryParse(connectionCsv[headers.IndexOf("Protocol")], out protocolType))
connectionRecord.Protocol = protocolType;
}
if (headers.Contains("Port"))
{
int port;
if (int.TryParse(connectionCsv[headers.IndexOf("Port")], out port))
connectionRecord.Port = port;
}
if (headers.Contains("ConnectToConsole"))
{
bool useConsoleSession;
if (bool.TryParse(connectionCsv[headers.IndexOf("ConnectToConsole")], out useConsoleSession))
connectionRecord.UseConsoleSession = useConsoleSession;
}
if (headers.Contains("UseCredSsp"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("UseCredSsp")], out value))
connectionRecord.UseCredSsp = value;
}
if (headers.Contains("RenderingEngine"))
{
HTTPBase.RenderingEngine value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RenderingEngine")], out value))
connectionRecord.RenderingEngine = value;
}
if (headers.Contains("ICAEncryptionStrength"))
{
IcaProtocol.EncryptionStrength value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("ICAEncryptionStrength")], out value))
connectionRecord.ICAEncryptionStrength = value;
}
if (headers.Contains("RDPAuthenticationLevel"))
{
RdpAuthenticationLevel value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDPAuthenticationLevel")], out value))
connectionRecord.RDPAuthenticationLevel = value;
}
if (headers.Contains("Colors"))
{
RdpColors value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("Colors")], out value))
connectionRecord.Colors = value;
}
if (headers.Contains("Resolution"))
{
RdpResolutions value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("Resolution")], out value))
connectionRecord.Resolution = value;
}
if (headers.Contains("AutomaticResize"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("AutomaticResize")], out value))
connectionRecord.AutomaticResize = value;
}
if (headers.Contains("DisplayWallpaper"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayWallpaper")], out value))
connectionRecord.DisplayWallpaper = value;
}
if (headers.Contains("DisplayThemes"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayThemes")], out value))
connectionRecord.DisplayThemes = value;
}
if (headers.Contains("EnableFontSmoothing"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("EnableFontSmoothing")], out value))
connectionRecord.EnableFontSmoothing = value;
}
if (headers.Contains("EnableDesktopComposition"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("EnableDesktopComposition")], out value))
connectionRecord.EnableDesktopComposition = value;
}
if (headers.Contains("CacheBitmaps"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("CacheBitmaps")], out value))
connectionRecord.CacheBitmaps = value;
}
if (headers.Contains("RedirectDiskDrives"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectDiskDrives")], out value))
connectionRecord.RedirectDiskDrives = value;
}
if (headers.Contains("RedirectPorts"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPorts")], out value))
connectionRecord.RedirectPorts = value;
}
if (headers.Contains("RedirectPrinters"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out value))
connectionRecord.RedirectPrinters = value;
}
if (headers.Contains("RedirectSmartCards"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectSmartCards")], out value))
connectionRecord.RedirectSmartCards = value;
}
if (headers.Contains("RedirectSound"))
{
RdpSounds value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RedirectSound")], out value))
connectionRecord.RedirectSound = value;
}
if (headers.Contains("RedirectKeys"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectKeys")], out value))
connectionRecord.RedirectKeys = value;
}
if (headers.Contains("VNCCompression"))
{
ProtocolVNC.Compression value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCCompression")], out value))
connectionRecord.VNCCompression = value;
}
if (headers.Contains("VNCEncoding"))
{
ProtocolVNC.Encoding value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCEncoding")], out value))
connectionRecord.VNCEncoding = value;
}
if (headers.Contains("VNCAuthMode"))
{
ProtocolVNC.AuthMode value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCAuthMode")], out value))
connectionRecord.VNCAuthMode = value;
}
if (headers.Contains("VNCProxyType"))
{
ProtocolVNC.ProxyType value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCProxyType")], out value))
connectionRecord.VNCProxyType = value;
}
if (headers.Contains("VNCProxyPort"))
{
int value;
if (int.TryParse(connectionCsv[headers.IndexOf("VNCProxyPort")], out value))
connectionRecord.VNCProxyPort = value;
}
if (headers.Contains("VNCColors"))
{
ProtocolVNC.Colors value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCColors")], out value))
connectionRecord.VNCColors = value;
}
if (headers.Contains("VNCSmartSizeMode"))
{
ProtocolVNC.SmartSizeMode value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCSmartSizeMode")], out value))
connectionRecord.VNCSmartSizeMode = value;
}
if (headers.Contains("VNCViewOnly"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("VNCViewOnly")], out value))
connectionRecord.VNCViewOnly = value;
}
if (headers.Contains("RDGatewayUsageMethod"))
{
RDGatewayUsageMethod value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUsageMethod")], out value))
connectionRecord.RDGatewayUsageMethod = value;
}
if (headers.Contains("RDGatewayUseConnectionCredentials"))
{
RDGatewayUseConnectionCredentials value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUseConnectionCredentials")], out value))
connectionRecord.RDGatewayUseConnectionCredentials = value;
}
#region Inheritance
if (headers.Contains("InheritCacheBitmaps"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCacheBitmaps")], out value))
connectionRecord.Inheritance.CacheBitmaps = value;
}
if (headers.Contains("InheritColors"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritColors")], out value))
connectionRecord.Inheritance.Colors = value;
}
if (headers.Contains("InheritDescription"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDescription")], out value))
connectionRecord.Inheritance.Description = value;
}
if (headers.Contains("InheritDisplayThemes"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayThemes")], out value))
connectionRecord.Inheritance.DisplayThemes = value;
}
if (headers.Contains("InheritDisplayWallpaper"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayWallpaper")], out value))
connectionRecord.Inheritance.DisplayWallpaper = value;
}
if (headers.Contains("InheritEnableFontSmoothing"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableFontSmoothing")], out value))
connectionRecord.Inheritance.EnableFontSmoothing = value;
}
if (headers.Contains("InheritEnableDesktopComposition"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableDesktopComposition")], out value))
connectionRecord.Inheritance.EnableDesktopComposition = value;
}
if (headers.Contains("InheritDomain"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDomain")], out value))
connectionRecord.Inheritance.Domain = value;
}
if (headers.Contains("InheritIcon"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritIcon")], out value))
connectionRecord.Inheritance.Icon = value;
}
if (headers.Contains("InheritPanel"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPanel")], out value))
connectionRecord.Inheritance.Panel = value;
}
if (headers.Contains("InheritPassword"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPassword")], out value))
connectionRecord.Inheritance.Password = value;
}
if (headers.Contains("InheritPort"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPort")], out value))
connectionRecord.Inheritance.Port = value;
}
if (headers.Contains("InheritProtocol"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritProtocol")], out value))
connectionRecord.Inheritance.Protocol = value;
}
if (headers.Contains("InheritPuttySession"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPuttySession")], out value))
connectionRecord.Inheritance.PuttySession = value;
}
if (headers.Contains("InheritRedirectDiskDrives"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectDiskDrives")], out value))
connectionRecord.Inheritance.RedirectDiskDrives = value;
}
if (headers.Contains("InheritRedirectKeys"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectKeys")], out value))
connectionRecord.Inheritance.RedirectKeys = value;
}
if (headers.Contains("InheritRedirectPorts"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPorts")], out value))
connectionRecord.Inheritance.RedirectPorts = value;
}
if (headers.Contains("InheritRedirectPrinters"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPrinters")], out value))
connectionRecord.Inheritance.RedirectPrinters = value;
}
if (headers.Contains("InheritRedirectSmartCards"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSmartCards")], out value))
connectionRecord.Inheritance.RedirectSmartCards = value;
}
if (headers.Contains("InheritRedirectSound"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSound")], out value))
connectionRecord.Inheritance.RedirectSound = value;
}
if (headers.Contains("InheritResolution"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritResolution")], out value))
connectionRecord.Inheritance.Resolution = value;
}
if (headers.Contains("InheritAutomaticResize"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritAutomaticResize")], out value))
connectionRecord.Inheritance.AutomaticResize = value;
}
if (headers.Contains("InheritUseConsoleSession"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseConsoleSession")], out value))
connectionRecord.Inheritance.UseConsoleSession = value;
}
if (headers.Contains("InheritUseCredSsp"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseCredSsp")], out value))
connectionRecord.Inheritance.UseCredSsp = value;
}
if (headers.Contains("InheritRenderingEngine"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRenderingEngine")], out value))
connectionRecord.Inheritance.RenderingEngine = value;
}
if (headers.Contains("InheritUsername"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUsername")], out value))
connectionRecord.Inheritance.Username = value;
}
if (headers.Contains("InheritICAEncryptionStrength"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritICAEncryptionStrength")], out value))
connectionRecord.Inheritance.ICAEncryptionStrength = value;
}
if (headers.Contains("InheritRDPAuthenticationLevel"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAuthenticationLevel")], out value))
connectionRecord.Inheritance.RDPAuthenticationLevel = value;
}
if (headers.Contains("InheritLoadBalanceInfo"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritLoadBalanceInfo")], out value))
connectionRecord.Inheritance.LoadBalanceInfo = value;
}
if (headers.Contains("InheritPreExtApp"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPreExtApp")], out value))
connectionRecord.Inheritance.PreExtApp = value;
}
if (headers.Contains("InheritPostExtApp"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPostExtApp")], out value))
connectionRecord.Inheritance.PostExtApp = value;
}
if (headers.Contains("InheritMacAddress"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritMacAddress")], out value))
connectionRecord.Inheritance.MacAddress = value;
}
if (headers.Contains("InheritUserField"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUserField")], out value))
connectionRecord.Inheritance.UserField = value;
}
if (headers.Contains("InheritExtApp"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritExtApp")], out value))
connectionRecord.Inheritance.ExtApp = value;
}
if (headers.Contains("InheritVNCCompression"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCCompression")], out value))
connectionRecord.Inheritance.VNCCompression = value;
}
if (headers.Contains("InheritVNCEncoding"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCEncoding")], out value))
connectionRecord.Inheritance.VNCEncoding = value;
}
if (headers.Contains("InheritVNCAuthMode"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCAuthMode")], out value))
connectionRecord.Inheritance.VNCAuthMode = value;
}
if (headers.Contains("InheritVNCProxyType"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyType")], out value))
connectionRecord.Inheritance.VNCProxyType = value;
}
if (headers.Contains("InheritVNCProxyIP"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyIP")], out value))
connectionRecord.Inheritance.VNCProxyIP = value;
}
if (headers.Contains("InheritVNCProxyPort"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPort")], out value))
connectionRecord.Inheritance.VNCProxyPort = value;
}
if (headers.Contains("InheritVNCProxyUsername"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyUsername")], out value))
connectionRecord.Inheritance.VNCProxyUsername = value;
}
if (headers.Contains("InheritVNCProxyPassword"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPassword")], out value))
connectionRecord.Inheritance.VNCProxyPassword = value;
}
if (headers.Contains("InheritVNCColors"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCColors")], out value))
connectionRecord.Inheritance.VNCColors = value;
}
if (headers.Contains("InheritVNCSmartSizeMode"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCSmartSizeMode")], out value))
connectionRecord.Inheritance.VNCSmartSizeMode = value;
}
if (headers.Contains("InheritVNCViewOnly"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCViewOnly")], out value))
connectionRecord.Inheritance.VNCViewOnly = value;
}
if (headers.Contains("InheritRDGatewayUsageMethod"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsageMethod")], out value))
connectionRecord.Inheritance.RDGatewayUsageMethod = value;
}
if (headers.Contains("InheritRDGatewayHostname"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayHostname")], out value))
connectionRecord.Inheritance.RDGatewayHostname = value;
}
if (headers.Contains("InheritRDGatewayUseConnectionCredentials"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out value))
connectionRecord.Inheritance.RDGatewayUseConnectionCredentials = value;
}
if (headers.Contains("InheritRDGatewayUsername"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsername")], out value))
connectionRecord.Inheritance.RDGatewayUsername = value;
}
if (headers.Contains("InheritRDGatewayPassword"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayPassword")], out value))
connectionRecord.Inheritance.RDGatewayPassword = value;
}
if (headers.Contains("InheritRDGatewayDomain"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayDomain")], out value))
connectionRecord.Inheritance.RDGatewayDomain = value;
}
if (headers.Contains("InheritRDPAlertIdleTimeout"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAlertIdleTimeout")], out value))
connectionRecord.Inheritance.RDPAlertIdleTimeout = value;
}
if (headers.Contains("InheritRDPMinutesToIdleTimeout"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPMinutesToIdleTimeout")], out value))
connectionRecord.Inheritance.RDPMinutesToIdleTimeout = value;
}
if (headers.Contains("InheritSoundQuality"))
{
bool value;
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSoundQuality")], out value))
connectionRecord.Inheritance.SoundQuality = value;
}
#endregion
return connectionRecord;
}
}
}

View File

@@ -61,7 +61,7 @@ namespace mRemoteNG.Config.Serializers
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 (_saveFilter.SaveInheritance)
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";
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;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality";
_csv += csvHeader;
}
@@ -87,63 +87,67 @@ namespace mRemoteNG.Config.Serializers
{
var csvLine = Environment.NewLine;
csvLine += con.Name + ";" + GetNodePath(con) + ";" + con.Description + ";" + con.Icon + ";" + con.Panel + ";";
csvLine += CleanStringForCsv(con.Name) + ";" +
CleanStringForCsv(GetNodePath(con)) + ";" +
CleanStringForCsv(con.Description) + ";" +
CleanStringForCsv(con.Icon) + ";" +
CleanStringForCsv(con.Panel) + ";";
if (_saveFilter.SaveUsername)
csvLine += con.Username + ";";
csvLine += CleanStringForCsv(con.Username) + ";";
if (_saveFilter.SavePassword)
csvLine += con.Password + ";";
csvLine += CleanStringForCsv(con.Password) + ";";
if (_saveFilter.SaveDomain)
csvLine += con.Domain + ";";
csvLine += CleanStringForCsv(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) + ";" +
con.RDGatewayUsageMethod + ";" +
con.RDGatewayHostname + ";" +
con.RDGatewayUseConnectionCredentials + ";" +
con.RDGatewayUsername + ";" +
con.RDGatewayPassword + ";" +
con.RDGatewayDomain + ";";
csvLine += CleanStringForCsv(con.Hostname) + ";" +
CleanStringForCsv(con.Protocol) + ";" +
CleanStringForCsv(con.PuttySession) + ";" +
CleanStringForCsv(con.Port) + ";" +
CleanStringForCsv(con.UseConsoleSession) + ";" +
CleanStringForCsv(con.UseCredSsp) + ";" +
CleanStringForCsv(con.RenderingEngine) + ";" +
CleanStringForCsv(con.ICAEncryptionStrength) + ";" +
CleanStringForCsv(con.RDPAuthenticationLevel) + ";" +
CleanStringForCsv(con.LoadBalanceInfo) + ";" +
CleanStringForCsv(con.Colors) + ";" +
CleanStringForCsv(con.Resolution) + ";" +
CleanStringForCsv(con.AutomaticResize) + ";" +
CleanStringForCsv(con.DisplayWallpaper) + ";" +
CleanStringForCsv(con.DisplayThemes) + ";" +
CleanStringForCsv(con.EnableFontSmoothing) + ";" +
CleanStringForCsv(con.EnableDesktopComposition) + ";" +
CleanStringForCsv(con.CacheBitmaps) + ";" +
CleanStringForCsv(con.RedirectDiskDrives) + ";" +
CleanStringForCsv(con.RedirectPorts) + ";" +
CleanStringForCsv(con.RedirectPrinters) + ";" +
CleanStringForCsv(con.RedirectSmartCards) + ";" +
CleanStringForCsv(con.RedirectSound) + ";" +
CleanStringForCsv(con.RedirectKeys) + ";" +
CleanStringForCsv(con.PreExtApp) + ";" +
CleanStringForCsv(con.PostExtApp) + ";" +
CleanStringForCsv(con.MacAddress) + ";" +
CleanStringForCsv(con.UserField) + ";" +
CleanStringForCsv(con.ExtApp) + ";" +
CleanStringForCsv(con.VNCCompression) + ";" +
CleanStringForCsv(con.VNCEncoding) + ";" +
CleanStringForCsv(con.VNCAuthMode) + ";" +
CleanStringForCsv(con.VNCProxyType) + ";" +
CleanStringForCsv(con.VNCProxyIP) + ";" +
CleanStringForCsv(con.VNCProxyPort) + ";" +
CleanStringForCsv(con.VNCProxyUsername) + ";" +
CleanStringForCsv(con.VNCProxyPassword) + ";" +
CleanStringForCsv(con.VNCColors) + ";" +
CleanStringForCsv(con.VNCSmartSizeMode) + ";" +
CleanStringForCsv(con.VNCViewOnly) + ";" +
CleanStringForCsv(con.RDGatewayUsageMethod) + ";" +
CleanStringForCsv(con.RDGatewayHostname) + ";" +
CleanStringForCsv(con.RDGatewayUseConnectionCredentials) + ";" +
CleanStringForCsv(con.RDGatewayUsername) + ";" +
CleanStringForCsv(con.RDGatewayPassword) + ";" +
CleanStringForCsv(con.RDGatewayDomain) + ";";
if (_saveFilter.SaveInheritance)
@@ -192,27 +196,40 @@ namespace mRemoteNG.Config.Serializers
con.Inheritance.VNCProxyPassword + ";" +
con.Inheritance.VNCColors + ";" +
con.Inheritance.VNCSmartSizeMode + ";" +
con.Inheritance.VNCViewOnly +
con.Inheritance.VNCViewOnly + ";" +
con.Inheritance.RDGatewayUsageMethod + ";" +
con.Inheritance.RDGatewayHostname + ";" +
con.Inheritance.RDGatewayUseConnectionCredentials + ";" +
con.Inheritance.RDGatewayUsername + ";" +
con.Inheritance.RDGatewayPassword + ";" +
con.Inheritance.RDGatewayDomain + ";";
con.Inheritance.RDGatewayDomain + ";" +
con.Inheritance.RDPAlertIdleTimeout + ";" +
con.Inheritance.RDPMinutesToIdleTimeout + ";" +
con.Inheritance.SoundQuality;
}
_csv += csvLine;
}
/// <summary>
/// Remove text that is unsafe for use in CSV files
/// </summary>
/// <param name="text"></param>
private string CleanStringForCsv(object text)
{
return text.ToString().Replace(";", "");
}
private string GetNodePath(ConnectionInfo connectionInfo)
{
var nodePath = "";
var container = connectionInfo.Parent;
if (container == null) return nodePath;
while (container != _serializationTarget)
var currentItem = connectionInfo;
while (currentItem != _serializationTarget)
{
container = container.Parent;
nodePath += $@"{container.Name}\";
currentItem = currentItem.Parent;
if (currentItem == null)
break;
nodePath += $@"{currentItem.Name}\";
}
nodePath = nodePath.TrimEnd('\\');
return nodePath;

View File

@@ -6,7 +6,7 @@ using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class RemoteDesktopConnectionDeserializer : IDeserializer<string, ConnectionTreeModel>
public class RemoteDesktopConnectionDeserializer : IDeserializer<string, ConnectionTreeModel>
{
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
@@ -59,19 +59,19 @@ namespace mRemoteNG.Config.Serializers
switch (value)
{
case "8":
connectionInfo.Colors = RdpProtocol.RDPColors.Colors256;
connectionInfo.Colors = RdpColors.Colors256;
break;
case "15":
connectionInfo.Colors = RdpProtocol.RDPColors.Colors15Bit;
connectionInfo.Colors = RdpColors.Colors15Bit;
break;
case "16":
connectionInfo.Colors = RdpProtocol.RDPColors.Colors16Bit;
connectionInfo.Colors = RdpColors.Colors16Bit;
break;
case "24":
connectionInfo.Colors = RdpProtocol.RDPColors.Colors24Bit;
connectionInfo.Colors = RdpColors.Colors24Bit;
break;
case "32":
connectionInfo.Colors = RdpProtocol.RDPColors.Colors32Bit;
connectionInfo.Colors = RdpColors.Colors32Bit;
break;
}
break;
@@ -79,7 +79,7 @@ namespace mRemoteNG.Config.Serializers
connectionInfo.CacheBitmaps = value == "1";
break;
case "screen mode id":
connectionInfo.Resolution = value == "2" ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.RDPResolutions.FitToWindow;
connectionInfo.Resolution = value == "2" ? RdpResolutions.Fullscreen : RdpResolutions.FitToWindow;
break;
case "connect to console":
connectionInfo.UseConsoleSession = value == "1";
@@ -112,13 +112,13 @@ namespace mRemoteNG.Config.Serializers
switch (value)
{
case "0":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.BringToThisComputer;
connectionInfo.RedirectSound = RdpSounds.BringToThisComputer;
break;
case "1":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer;
connectionInfo.RedirectSound = RdpSounds.LeaveAtRemoteComputer;
break;
case "2":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
connectionInfo.RedirectSound = RdpSounds.DoNotPlay;
break;
}
break;

View File

@@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
@@ -7,13 +9,11 @@ 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<string, ConnectionTreeModel>
public class RemoteDesktopConnectionManagerDeserializer : IDeserializer<string, ConnectionTreeModel>
{
private static int _schemaVersion; /* 1 = RDCMan v2.2
3 = RDCMan v2.7 */
@@ -176,7 +176,7 @@ namespace mRemoteNG.Config.Serializers
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
if (gatewaySettingsNode?.Attributes?["inherit"].Value == "None")
{
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RdpProtocol.RDGatewayUsageMethod.Always : RdpProtocol.RDGatewayUsageMethod.Never;
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RDGatewayUsageMethod.Always : RDGatewayUsageMethod.Never;
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName")?.InnerText;
connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName")?.InnerText;
@@ -203,26 +203,26 @@ namespace mRemoteNG.Config.Serializers
var resolutionString = remoteDesktopNode.SelectSingleNode("./size")?.InnerText.Replace(" ", "");
try
{
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), "Res" + resolutionString);
connectionInfo.Resolution = (RdpResolutions)Enum.Parse(typeof(RdpResolutions), "Res" + resolutionString);
}
catch (ArgumentException)
{
connectionInfo.Resolution = RdpProtocol.RDPResolutions.FitToWindow;
connectionInfo.Resolution = RdpResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./sameSizeAsClientArea")?.InnerText == "True")
{
connectionInfo.Resolution = RdpProtocol.RDPResolutions.FitToWindow;
connectionInfo.Resolution = RdpResolutions.FitToWindow;
}
if (remoteDesktopNode.SelectSingleNode("./fullScreen")?.InnerText == "True")
{
connectionInfo.Resolution = RdpProtocol.RDPResolutions.Fullscreen;
connectionInfo.Resolution = RdpResolutions.Fullscreen;
}
var colorDepth = remoteDesktopNode.SelectSingleNode("./colorDepth")?.InnerText;
if (colorDepth != null)
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), colorDepth);
connectionInfo.Colors = (RdpColors)Enum.Parse(typeof(RdpColors), colorDepth);
}
else
{
@@ -238,15 +238,15 @@ namespace mRemoteNG.Config.Serializers
{
case "0": // Bring to this computer
case "Client":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.BringToThisComputer;
connectionInfo.RedirectSound = RdpSounds.BringToThisComputer;
break;
case "1": // Leave at remote computer
case "Remote":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer;
connectionInfo.RedirectSound = RdpSounds.LeaveAtRemoteComputer;
break;
case "2": // Do not play
case "NoSound":
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
connectionInfo.RedirectSound = RdpSounds.DoNotPlay;
break;
}
@@ -294,15 +294,15 @@ namespace mRemoteNG.Config.Serializers
{
case "0": // No authentication
case "None":
connectionInfo.RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.NoAuth;
connectionInfo.RDPAuthenticationLevel = RdpAuthenticationLevel.NoAuth;
break;
case "1": // Do not connect if authentication fails
case "Required":
connectionInfo.RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.AuthRequired;
connectionInfo.RDPAuthenticationLevel = RdpAuthenticationLevel.AuthRequired;
break;
case "2": // Warn if authentication fails
case "Warn":
connectionInfo.RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.WarnOnFailedAuth;
connectionInfo.RDPAuthenticationLevel = RdpAuthenticationLevel.WarnOnFailedAuth;
break;
}
}

View File

@@ -26,28 +26,29 @@ namespace mRemoteNG.Connection
private string _domain = "";
private ProtocolType _protocol;
private RdpVersionEnum _rdpProtocolVersion;
private string _extApp;
private int _port;
private string _puttySession;
private IcaProtocol.EncryptionStrength _icaEncryption;
private bool _useConsoleSession;
private RdpProtocol.AuthenticationLevel _rdpAuthenticationLevel;
private RdpAuthenticationLevel _rdpAuthenticationLevel;
private int _rdpMinutesToIdleTimeout;
private bool _rdpAlertIdleTimeout;
private string _loadBalanceInfo;
private HTTPBase.RenderingEngine _renderingEngine;
private bool _useCredSsp;
private RdpProtocol.RDGatewayUsageMethod _rdGatewayUsageMethod;
private RDGatewayUsageMethod _rdGatewayUsageMethod;
private string _rdGatewayHostname;
private RdpProtocol.RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private string _rdGatewayUsername;
private string _rdGatewayPassword;
private string _rdGatewayDomain;
private RdpProtocol.RDPResolutions _resolution;
private RdpResolutions _resolution;
private bool _automaticResize;
private RdpProtocol.RDPColors _colors;
private RdpColors _colors;
private bool _cacheBitmaps;
private bool _displayWallpaper;
private bool _displayThemes;
@@ -59,8 +60,8 @@ namespace mRemoteNG.Connection
private bool _redirectPrinters;
private bool _redirectPorts;
private bool _redirectSmartCards;
private RdpProtocol.RDPSounds _redirectSound;
private RdpProtocol.RDPSoundQuality _soundQuality;
private RdpSounds _redirectSound;
private RdpSoundQuality _soundQuality;
private string _preExtApp;
private string _postExtApp;
@@ -170,6 +171,16 @@ namespace mRemoteNG.Connection
set { SetField(ref _protocol, value, "Protocol"); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRdpProtocolVersion"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRdpProtocolVersion"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public virtual RdpVersionEnum RdpProtocolVersion
{
get { return GetPropertyValue(nameof(RdpProtocolVersion), _rdpProtocolVersion); }
set { SetField(ref _rdpProtocolVersion, value, nameof(RdpProtocolVersion)); }
}
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalTool"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionExternalTool"),
@@ -223,7 +234,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationLevel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationLevel"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.AuthenticationLevel RDPAuthenticationLevel
public RdpAuthenticationLevel RDPAuthenticationLevel
{
get { return GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel); }
set { SetField(ref _rdpAuthenticationLevel, value, "RDPAuthenticationLevel"); }
@@ -288,7 +299,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsageMethod"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsageMethod"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDGatewayUsageMethod RDGatewayUsageMethod
public RDGatewayUsageMethod RDGatewayUsageMethod
{
get { return GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod); }
set { SetField(ref _rdGatewayUsageMethod, value, "RDGatewayUsageMethod"); }
@@ -307,7 +318,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUseConnectionCredentials"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUseConnectionCredentials"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
public RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
{
get { return GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials); }
set { SetField(ref _rdGatewayUseConnectionCredentials, value, "RDGatewayUseConnectionCredentials"); }
@@ -347,7 +358,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameResolution"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionResolution"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDPResolutions Resolution
public RdpResolutions Resolution
{
get { return GetPropertyValue("Resolution", _resolution); }
set { SetField(ref _resolution, value, "Resolution"); }
@@ -367,7 +378,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDPColors Colors
public RdpColors Colors
{
get { return GetPropertyValue("Colors", _colors); }
set { SetField(ref _colors, value, "Colors"); }
@@ -479,7 +490,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSounds"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSounds"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDPSounds RedirectSound
public RdpSounds RedirectSound
{
get { return GetPropertyValue("RedirectSound", _redirectSound); }
set { SetField(ref _redirectSound, value, "RedirectSound"); }
@@ -489,7 +500,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameSoundQuality"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionSoundQuality"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpProtocol.RDPSoundQuality SoundQuality
public RdpSoundQuality SoundQuality
{
get { return GetPropertyValue("SoundQuality", _soundQuality); }
set { SetField(ref _soundQuality, value, "SoundQuality"); }

View File

@@ -168,7 +168,13 @@ namespace mRemoteNG.Connection
#region Private Methods
protected override TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
{
return ShouldThisPropertyBeInherited(propertyName) ? GetInheritedPropertyValue<TPropertyType>(propertyName) : value;
if (!ShouldThisPropertyBeInherited(propertyName))
return value;
var inheritedValue = GetInheritedPropertyValue<TPropertyType>(propertyName);
if (inheritedValue.Equals(default(TPropertyType)))
return value;
return inheritedValue;
}
private bool ShouldThisPropertyBeInherited(string propertyName)
@@ -191,15 +197,21 @@ namespace mRemoteNG.Connection
private TPropertyType GetInheritedPropertyValue<TPropertyType>(string propertyName)
{
var connectionInfoType = Parent.GetType();
var parentPropertyInfo = connectionInfoType.GetProperty(propertyName);
if (parentPropertyInfo == null)
return default(TPropertyType); // shouldn't get here...
var parentPropertyValue = (TPropertyType)parentPropertyInfo.GetValue(Parent, null);
try
{
var connectionInfoType = Parent.GetType();
var parentPropertyInfo = connectionInfoType.GetProperty(propertyName);
if (parentPropertyInfo == null)
return default(TPropertyType); // shouldn't get here...
var parentPropertyValue = (TPropertyType)parentPropertyInfo.GetValue(Parent, null);
return parentPropertyValue;
return parentPropertyValue;
}
catch (Exception e)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Error retrieving inherited property '{propertyName}'", e);
return default(TPropertyType);
}
}
private static int GetDefaultPort(ProtocolType protocol)
@@ -210,7 +222,7 @@ namespace mRemoteNG.Connection
switch (protocol)
{
case ProtocolType.RDP:
return (int)RdpProtocol.Defaults.Port;
return (int)RdpProtocol6.Defaults.Port;
case ProtocolType.VNC:
return (int)ProtocolVNC.Defaults.Port;
case ProtocolType.SSH1:
@@ -257,12 +269,13 @@ namespace mRemoteNG.Connection
private void SetProtocolDefaults()
{
Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), Settings.Default.ConDefaultProtocol);
ExtApp = Settings.Default.ConDefaultExtApp;
RdpProtocolVersion = RdpVersionEnum.Rdc8;
ExtApp = Settings.Default.ConDefaultExtApp;
Port = 0;
PuttySession = Settings.Default.ConDefaultPuttySession;
ICAEncryptionStrength = (IcaProtocol.EncryptionStrength) Enum.Parse(typeof(IcaProtocol.EncryptionStrength), Settings.Default.ConDefaultICAEncryptionStrength);
UseConsoleSession = Settings.Default.ConDefaultUseConsoleSession;
RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel) Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
RDPAuthenticationLevel = (RdpAuthenticationLevel) Enum.Parse(typeof(RdpAuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
RDPMinutesToIdleTimeout = Settings.Default.ConDefaultRDPMinutesToIdleTimeout;
RDPAlertIdleTimeout = Settings.Default.ConDefaultRDPAlertIdleTimeout;
LoadBalanceInfo = Settings.Default.ConDefaultLoadBalanceInfo;
@@ -272,9 +285,9 @@ namespace mRemoteNG.Connection
private void SetRdGatewayDefaults()
{
RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod) Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
RDGatewayUsageMethod = (RDGatewayUsageMethod) Enum.Parse(typeof(RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
RDGatewayHostname = Settings.Default.ConDefaultRDGatewayHostname;
RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials) Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials);
RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials) Enum.Parse(typeof(RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials);
RDGatewayUsername = Settings.Default.ConDefaultRDGatewayUsername;
RDGatewayPassword = Settings.Default.ConDefaultRDGatewayPassword;
RDGatewayDomain = Settings.Default.ConDefaultRDGatewayDomain;
@@ -282,9 +295,9 @@ namespace mRemoteNG.Connection
private void SetAppearanceDefaults()
{
Resolution = (RdpProtocol.RDPResolutions) Enum.Parse(typeof(RdpProtocol.RDPResolutions), Settings.Default.ConDefaultResolution);
Resolution = (RdpResolutions) Enum.Parse(typeof(RdpResolutions), Settings.Default.ConDefaultResolution);
AutomaticResize = Settings.Default.ConDefaultAutomaticResize;
Colors = (RdpProtocol.RDPColors) Enum.Parse(typeof(RdpProtocol.RDPColors), Settings.Default.ConDefaultColors);
Colors = (RdpColors) Enum.Parse(typeof(RdpColors), Settings.Default.ConDefaultColors);
CacheBitmaps = Settings.Default.ConDefaultCacheBitmaps;
DisplayWallpaper = Settings.Default.ConDefaultDisplayWallpaper;
DisplayThemes = Settings.Default.ConDefaultDisplayThemes;
@@ -299,8 +312,8 @@ namespace mRemoteNG.Connection
RedirectPrinters = Settings.Default.ConDefaultRedirectPrinters;
RedirectPorts = Settings.Default.ConDefaultRedirectPorts;
RedirectSmartCards = Settings.Default.ConDefaultRedirectSmartCards;
RedirectSound = (RdpProtocol.RDPSounds) Enum.Parse(typeof(RdpProtocol.RDPSounds), Settings.Default.ConDefaultRedirectSound);
SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), Settings.Default.ConDefaultSoundQuality);
RedirectSound = (RdpSounds) Enum.Parse(typeof(RdpSounds), Settings.Default.ConDefaultRedirectSound);
SoundQuality = (RdpSoundQuality)Enum.Parse(typeof(RdpSoundQuality), Settings.Default.ConDefaultSoundQuality);
}
private void SetMiscDefaults()

View File

@@ -100,7 +100,7 @@ namespace mRemoteNG.Connection
var connectionContainer = SetConnectionContainer(connectionInfo, connectionForm);
SetConnectionFormEventHandlers(newProtocol, connectionForm);
SetConnectionEventHandlers(newProtocol);
BuildConnectionInterfaceController(connectionInfo, newProtocol, connectionContainer);
BuildConnectionInterfaceController(newProtocol, connectionContainer);
newProtocol.Force = force;
@@ -144,7 +144,7 @@ namespace mRemoteNG.Connection
{
var ic = t.Controls[0] as InterfaceControl;
if (ic == null) continue;
if (ic.Info == connectionInfo)
if (ic.Protocol.Info == connectionInfo)
{
return ic;
}
@@ -213,9 +213,9 @@ namespace mRemoteNG.Connection
newProtocol.ErrorOccured += Prot_Event_ErrorOccured;
}
private static void BuildConnectionInterfaceController(ConnectionInfo connectionInfo, ProtocolBase newProtocol, Control connectionContainer)
private static void BuildConnectionInterfaceController(ProtocolBase newProtocol, Control connectionContainer)
{
newProtocol.InterfaceControl = new InterfaceControl(connectionContainer, newProtocol, connectionInfo);
newProtocol.InterfaceControl = new InterfaceControl(connectionContainer, newProtocol);
}
#endregion
@@ -233,7 +233,7 @@ namespace mRemoteNG.Connection
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, disconnectedMessage), true);
var prot = (ProtocolBase)sender;
if (prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
if (prot.Info.Protocol != ProtocolType.RDP) return;
var reasonCode = disconnectedMessage.Split("\r\n".ToCharArray())[0];
var desc = disconnectedMessage.Replace("\r\n", " ");
@@ -246,26 +246,27 @@ namespace mRemoteNG.Connection
}
}
private static void Prot_Event_Closed(object sender)
private static void Prot_Event_Closed(object sender, EventArgs args)
{
try
{
var prot = (ProtocolBase)sender;
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnenctionCloseEvent, true);
string connDetail;
if (prot.InterfaceControl.Info.Hostname == "" && prot.InterfaceControl.Info.Protocol == ProtocolType.IntApp)
connDetail = prot.InterfaceControl.Info.ExtApp;
else if (prot.InterfaceControl.Info.Hostname != "")
connDetail = prot.InterfaceControl.Info.Hostname;
if (prot.Info.Hostname == "" && prot.Info.Protocol == ProtocolType.IntApp)
connDetail = prot.Info.ExtApp;
else if (prot.Info.Hostname != "")
connDetail = prot.Info.Hostname;
else
connDetail = "UNKNOWN";
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strConnenctionClosedByUser, connDetail, prot.InterfaceControl.Info.Protocol, Environment.UserName));
prot.InterfaceControl.Info.OpenConnections.Remove(prot);
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
string.Format(Language.strConnenctionClosedByUser, connDetail, prot.Info.Protocol, Environment.UserName));
prot.Info.OpenConnections.Remove(prot);
if (prot.InterfaceControl.Info.PostExtApp == "") return;
var extA = Runtime.ExternalToolsService.GetExtAppByName(prot.InterfaceControl.Info.PostExtApp);
extA?.Start(prot.InterfaceControl.Info);
if (prot.Info.PostExtApp == "") return;
var extA = Runtime.ExternalToolsService.GetExtAppByName(prot.Info.PostExtApp);
extA?.Start(prot.Info);
}
catch (Exception ex)
{
@@ -273,11 +274,12 @@ namespace mRemoteNG.Connection
}
}
private static void Prot_Event_Connected(object sender)
private static void Prot_Event_Connected(object sender, EventArgs args)
{
var prot = (ProtocolBase)sender;
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventConnected, true);
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol, Environment.UserName, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField));
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
string.Format(Language.strConnectionEventConnectedDetail, prot.Info.Hostname, prot.Info.Protocol, Environment.UserName, prot.Info.Description, prot.Info.UserField));
}
private static void Prot_Event_ErrorOccured(object sender, string errorMessage)
@@ -287,9 +289,12 @@ namespace mRemoteNG.Connection
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, RdpProtocol.FatalErrors.GetError(errorMessage)));
if (prot.Info.Protocol != ProtocolType.RDP) return;
var errorMessageAsInt = Convert.ToInt32(errorMessage);
if (errorMessageAsInt > -1)
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
string.Format(Language.strConnectionRdpErrorDetail, errorMessage, RdpErrorTranslator.Translate(errorMessageAsInt)));
}
catch (Exception ex)
{

View File

@@ -10,15 +10,12 @@ namespace mRemoteNG.Connection
public sealed partial class InterfaceControl
{
public ProtocolBase Protocol { get; set; }
public ConnectionInfo Info { get; set; }
public InterfaceControl(Control parent, ProtocolBase protocol, ConnectionInfo info)
public InterfaceControl(Control parent, ProtocolBase protocol)
{
try
{
Protocol = protocol;
Info = info;
Parent = parent;
Location = new Point(0, 0);
Size = Parent.Size;

View File

@@ -3,7 +3,8 @@ namespace mRemoteNG.Connection.Protocol.Http
public class ProtocolHTTP : HTTPBase
{
public ProtocolHTTP(RenderingEngine RenderingEngine) : base(RenderingEngine)
public ProtocolHTTP(ConnectionInfo connectionInfo, RenderingEngine renderingEngine)
: base(connectionInfo, renderingEngine)
{
httpOrS = "http";
defaultPort = (int)Defaults.Port;

View File

@@ -9,20 +9,19 @@ namespace mRemoteNG.Connection.Protocol.Http
{
public class HTTPBase : ProtocolBase
{
#region Private Properties
private Control wBrowser;
private string tabTitle;
protected string httpOrS;
protected int defaultPort;
private string tabTitle;
#endregion
#region Public Methods
protected HTTPBase(RenderingEngine RenderingEngine)
{
protected HTTPBase(ConnectionInfo connectionInfo, RenderingEngine renderingEngine)
: base(connectionInfo)
{
try
{
if (RenderingEngine == RenderingEngine.Gecko)
if (renderingEngine == RenderingEngine.Gecko)
{
if(!Xpcom.IsInitialized)
Xpcom.Initialize("Firefox");
@@ -58,7 +57,7 @@ namespace mRemoteNG.Connection.Protocol.Http
{
wBrowser = Control;
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
if (Info.RenderingEngine == RenderingEngine.Gecko)
{
var GeckoBrowser = (GeckoWebBrowser) wBrowser;
if (GeckoBrowser != null)
@@ -96,7 +95,7 @@ namespace mRemoteNG.Connection.Protocol.Http
{
try
{
var strHost = InterfaceControl.Info.Hostname;
var strHost = Info.Hostname;
/*
* Commenting out since this codes doesn't actually do anything at this time...
* Possibly related to MR-221 and/or MR-533 ????
@@ -108,7 +107,7 @@ namespace mRemoteNG.Connection.Protocol.Http
strAuth = "Authorization: Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(InterfaceControl.Info.Username + ":" + InterfaceControl.Info.Password)) + Environment.NewLine;
}
*/
if (InterfaceControl.Info.Port != defaultPort)
if (Info.Port != defaultPort)
{
if (strHost.EndsWith("/"))
{
@@ -120,13 +119,13 @@ namespace mRemoteNG.Connection.Protocol.Http
strHost = httpOrS + "://" + strHost;
}
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
if (Info.RenderingEngine == RenderingEngine.Gecko)
{
((GeckoWebBrowser)wBrowser).Navigate(strHost + ":" + InterfaceControl.Info.Port);
((GeckoWebBrowser)wBrowser).Navigate(strHost + ":" + Info.Port);
}
else
{
((WebBrowser)wBrowser).Navigate(strHost + ":" + InterfaceControl.Info.Port);
((WebBrowser)wBrowser).Navigate(strHost + ":" + Info.Port);
}
}
else
@@ -136,7 +135,7 @@ namespace mRemoteNG.Connection.Protocol.Http
strHost = httpOrS + "://" + strHost;
}
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
if (Info.RenderingEngine == RenderingEngine.Gecko)
{
((GeckoWebBrowser)wBrowser).Navigate(strHost);
}
@@ -181,7 +180,7 @@ namespace mRemoteNG.Connection.Protocol.Http
if (tabP == null) return;
string shortTitle;
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
if (Info.RenderingEngine == RenderingEngine.Gecko)
{
if (((GeckoWebBrowser) wBrowser).DocumentTitle.Length >= 15)
{
@@ -229,7 +228,7 @@ namespace mRemoteNG.Connection.Protocol.Http
if (tabP == null) return;
string shortTitle;
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
if (Info.RenderingEngine == RenderingEngine.Gecko)
{
if (((GeckoWebBrowser)wBrowser).DocumentTitle.Length >= 15)
{

View File

@@ -2,8 +2,8 @@ namespace mRemoteNG.Connection.Protocol.Http
{
public class ProtocolHTTPS : HTTPBase
{
public ProtocolHTTPS(RenderingEngine RenderingEngine) : base(RenderingEngine)
public ProtocolHTTPS(ConnectionInfo connectionInfo, RenderingEngine renderingEngine)
: base(connectionInfo, renderingEngine)
{
httpOrS = "https";
defaultPort = (int)Defaults.Port;

View File

@@ -16,11 +16,11 @@ namespace mRemoteNG.Connection.Protocol.ICA
public class IcaProtocol : ProtocolBase
{
private AxICAClient _icaClient;
private ConnectionInfo _info;
private readonly FrmMain _frmMain = FrmMain.Default;
#region Public Methods
public IcaProtocol()
public IcaProtocol(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
try
{
@@ -39,7 +39,6 @@ namespace mRemoteNG.Connection.Protocol.ICA
try
{
_icaClient = (AxICAClient)Control;
_info = InterfaceControl.Info;
_icaClient.CreateControl();
while (!_icaClient.Created)
@@ -48,7 +47,7 @@ namespace mRemoteNG.Connection.Protocol.ICA
Application.DoEvents();
}
_icaClient.Address = _info.Hostname;
_icaClient.Address = Info.Hostname;
SetCredentials();
SetResolution();
SetColors();
@@ -78,8 +77,8 @@ namespace mRemoteNG.Connection.Protocol.ICA
_icaClient.Hotkey11Shift = null;
_icaClient.Hotkey11Char = null;
_icaClient.PersistentCacheEnabled = _info.CacheBitmaps;
_icaClient.Title = _info.Name;
_icaClient.PersistentCacheEnabled = Info.CacheBitmaps;
_icaClient.Title = Info.Name;
return true;
}
catch (Exception ex)
@@ -117,9 +116,9 @@ namespace mRemoteNG.Connection.Protocol.ICA
return;
}
var user = _info?.Username ?? "";
var pass = _info?.Password ?? "";
var dom = _info?.Domain ?? "";
var user = Info?.Username ?? "";
var pass = Info?.Password ?? "";
var dom = Info?.Domain ?? "";
if (string.IsNullOrEmpty(user))
{
@@ -187,22 +186,22 @@ namespace mRemoteNG.Connection.Protocol.ICA
return;
}
if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.FitToWindow)
if (Info.Resolution == RdpResolutions.FitToWindow)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0);
}
else if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.SmartSize)
else if (Info.Resolution == RdpResolutions.SmartSize)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0);
}
else if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.Fullscreen)
else if (Info.Resolution == RdpResolutions.Fullscreen)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, Screen.FromControl(_frmMain).Bounds.Width, Screen.FromControl(_frmMain).Bounds.Height, 0);
_icaClient.FullScreenWindow();
}
else
{
var resolution = RdpProtocol.GetResolutionRectangle(_info.Resolution);
var resolution = Info.Resolution.GetResolutionRectangle();
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, resolution.Width, resolution.Height, 0);
}
}
@@ -215,15 +214,15 @@ namespace mRemoteNG.Connection.Protocol.ICA
private void SetColors()
{
// ReSharper disable once SwitchStatementMissingSomeCases
switch (_info.Colors)
switch (Info.Colors)
{
case RdpProtocol.RDPColors.Colors256:
case RdpColors.Colors256:
_icaClient.SetProp("DesiredColor", "2");
break;
case RdpProtocol.RDPColors.Colors15Bit:
case RdpColors.Colors15Bit:
_icaClient.SetProp("DesiredColor", "4");
break;
case RdpProtocol.RDPColors.Colors16Bit:
case RdpColors.Colors16Bit:
_icaClient.SetProp("DesiredColor", "4");
break;
default:
@@ -235,7 +234,7 @@ namespace mRemoteNG.Connection.Protocol.ICA
private void SetSecurity()
{
// ReSharper disable once SwitchStatementMissingSomeCases
switch (_info.ICAEncryptionStrength)
switch (Info.ICAEncryptionStrength)
{
case EncryptionStrength.Encr128BitLogonOnly:
_icaClient.Encrypt = true;
@@ -275,22 +274,22 @@ namespace mRemoteNG.Connection.Protocol.ICA
#region Private Events & Handlers
private void ICAEvent_OnConnecting(object sender, EventArgs e)
{
Event_Connecting(this);
RaiseConnectionConnectingEvent(this);
}
private void ICAEvent_OnConnected(object sender, EventArgs e)
{
Event_Connected(this);
RaiseConnectionConnectedEvent(this);
}
private void ICAEvent_OnConnectFailed(object sender, EventArgs e)
{
Event_ErrorOccured(this, e.ToString());
RaiseErrorOccuredEvent(this, e.ToString());
}
private void ICAEvent_OnDisconnect(object sender, EventArgs e)
{
Event_Disconnected(this, e.ToString());
RaiseConnectionDisconnectedEvent(this, e.ToString());
if (Settings.Default.ReconnectOnDisconnect)
{
@@ -312,7 +311,7 @@ namespace mRemoteNG.Connection.Protocol.ICA
#region Reconnect Stuff
public void tmrReconnect_Elapsed(object sender, ElapsedEventArgs e)
{
var srvReady = PortScanner.IsPortOpen(_info.Hostname, Convert.ToString(_info.Port));
var srvReady = PortScanner.IsPortOpen(Info.Hostname, Convert.ToString(Info.Port));
ReconnectGroup.ServerReady = srvReady;

View File

@@ -11,27 +11,30 @@ namespace mRemoteNG.Connection.Protocol
{
public class IntegratedProgram : ProtocolBase
{
#region Private Fields
private ExternalTool _externalTool;
private IntPtr _handle;
private Process _process;
#endregion
public IntegratedProgram(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
}
#region Public Methods
public override bool Initialize()
{
if (InterfaceControl.Info == null)
if (Info == null)
return base.Initialize();
_externalTool = Runtime.ExternalToolsService.GetExtAppByName(InterfaceControl.Info.ExtApp);
_externalTool = Runtime.ExternalToolsService.GetExtAppByName(Info.ExtApp);
if (_externalTool == null)
{
Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, InterfaceControl.Info.ExtApp));
Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, Info.ExtApp));
return false;
}
_externalTool.ConnectionInfo = InterfaceControl.Info;
_externalTool.ConnectionInfo = Info;
return base.Initialize();
}
@@ -44,7 +47,7 @@ namespace mRemoteNG.Connection.Protocol
if (_externalTool.TryIntegrate == false)
{
_externalTool.Start(InterfaceControl.Info);
_externalTool.Start(Info);
/* Don't call close here... There's nothing for the override to do in this case since
* _process is not created in this scenario. When returning false, ProtocolBase.Close()
* will be called - which is just going to call IntegratedProgram.Close() again anyway...
@@ -169,7 +172,7 @@ namespace mRemoteNG.Connection.Protocol
#region Private Methods
private void ProcessExited(object sender, EventArgs e)
{
Event_Closed(this);
RaiseConnectionClosedEvent(this);
}
#endregion

View File

@@ -3,29 +3,21 @@ using System.Threading;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Tools;
using mRemoteNG.UI.Window;
namespace mRemoteNG.Connection.Protocol
{
public abstract class ProtocolBase
{
#region Private Variables
private UI.Window.ConnectionWindow _connectionWindow;
private ConnectionWindow _connectionWindow;
private InterfaceControl _interfaceControl;
private ConnectingEventHandler ConnectingEvent;
private ConnectedEventHandler ConnectedEvent;
private DisconnectedEventHandler DisconnectedEvent;
private ErrorOccuredEventHandler ErrorOccuredEvent;
private ClosingEventHandler ClosingEvent;
private ClosedEventHandler ClosedEvent;
#endregion
#region Public Properties
#region Control
private string Name { get; }
protected UI.Window.ConnectionWindow ConnectionWindow
protected ConnectionWindow ConnectionWindow
{
get { return _connectionWindow; }
private set
@@ -43,33 +35,38 @@ namespace mRemoteNG.Connection.Protocol
set
{
_interfaceControl = value;
ConnectionWindow = _interfaceControl.GetContainerControl() as UI.Window.ConnectionWindow;
ConnectionWindow = _interfaceControl.GetContainerControl() as ConnectionWindow;
}
}
protected Control Control { get; set; }
public ConnectionInfo Info { get; set; }
#endregion
public ConnectionInfo.Force Force { get; set; }
public readonly System.Timers.Timer tmrReconnect = new System.Timers.Timer(2000);
protected ReconnectGroup ReconnectGroup;
#endregion
protected ProtocolBase(string name)
protected ProtocolBase(ConnectionInfo connectionInfo, string name)
{
if (connectionInfo == null)
throw new ArgumentNullException(nameof(connectionInfo));
if (name == null)
throw new ArgumentNullException(nameof(name));
Info = connectionInfo;
Name = name;
}
protected ProtocolBase()
protected ProtocolBase(ConnectionInfo connectionInfo)
: this(connectionInfo, "")
{
}
#endregion
#region Methods
//public abstract int GetDefaultPort();
public virtual void Focus()
{
try
@@ -119,9 +116,8 @@ namespace mRemoteNG.Connection.Protocol
public virtual bool Connect()
{
if (InterfaceControl.Info.Protocol == ProtocolType.RDP) return false;
if (ConnectedEvent == null) return false;
ConnectedEvent(this);
if (Info.Protocol == ProtocolType.RDP) return false;
RaiseConnectionConnectedEvent(this);
return true;
}
@@ -140,7 +136,7 @@ namespace mRemoteNG.Connection.Protocol
private void CloseBG()
{
ClosedEvent?.Invoke(this);
RaiseConnectionClosedEvent(this);
try
{
tmrReconnect.Enabled = false;
@@ -225,83 +221,46 @@ namespace mRemoteNG.Connection.Protocol
#endregion
#region Events
public delegate void ConnectingEventHandler(object sender);
public event ConnectingEventHandler Connecting
{
add { ConnectingEvent = (ConnectingEventHandler) Delegate.Combine(ConnectingEvent, value); }
remove { ConnectingEvent = (ConnectingEventHandler) Delegate.Remove(ConnectingEvent, value); }
}
public event EventHandler Connecting;
public event EventHandler Connected;
public event EventHandler Closing;
public event EventHandler Closed;
public delegate void DisconnectedEventHandler(object sender, string disconnectedMessage);
public event DisconnectedEventHandler Disconnected;
public delegate void ErrorOccuredEventHandler(object sender, string errorMessage);
public event ErrorOccuredEventHandler ErrorOccured;
public delegate void ConnectedEventHandler(object sender);
public event ConnectedEventHandler Connected
protected void RaiseConnectionClosingEvent(object sender)
{
add { ConnectedEvent = (ConnectedEventHandler) Delegate.Combine(ConnectedEvent, value); }
remove { ConnectedEvent = (ConnectedEventHandler) Delegate.Remove(ConnectedEvent, value); }
}
public delegate void DisconnectedEventHandler(object sender, string DisconnectedMessage);
public event DisconnectedEventHandler Disconnected
{
add { DisconnectedEvent = (DisconnectedEventHandler) Delegate.Combine(DisconnectedEvent, value); }
remove { DisconnectedEvent = (DisconnectedEventHandler) Delegate.Remove(DisconnectedEvent, value); }
}
public delegate void ErrorOccuredEventHandler(object sender, string ErrorMessage);
public event ErrorOccuredEventHandler ErrorOccured
{
add { ErrorOccuredEvent = (ErrorOccuredEventHandler) Delegate.Combine(ErrorOccuredEvent, value); }
remove { ErrorOccuredEvent = (ErrorOccuredEventHandler) Delegate.Remove(ErrorOccuredEvent, value); }
}
public delegate void ClosingEventHandler(object sender);
public event ClosingEventHandler Closing
{
add { ClosingEvent = (ClosingEventHandler) Delegate.Combine(ClosingEvent, value); }
remove { ClosingEvent = (ClosingEventHandler) Delegate.Remove(ClosingEvent, value); }
}
public delegate void ClosedEventHandler(object sender);
public event ClosedEventHandler Closed
{
add { ClosedEvent = (ClosedEventHandler) Delegate.Combine(ClosedEvent, value); }
remove { ClosedEvent = (ClosedEventHandler) Delegate.Remove(ClosedEvent, value); }
}
public void Event_Closing(object sender)
{
ClosingEvent?.Invoke(sender);
Closing?.Invoke(sender, EventArgs.Empty);
}
protected void Event_Closed(object sender)
protected void RaiseConnectionClosedEvent(object sender)
{
ClosedEvent?.Invoke(sender);
Closed?.Invoke(sender, EventArgs.Empty);
}
protected void Event_Connecting(object sender)
protected void RaiseConnectionConnectingEvent(object sender)
{
ConnectingEvent?.Invoke(sender);
Connecting?.Invoke(sender, EventArgs.Empty);
}
protected void Event_Connected(object sender)
protected void RaiseConnectionConnectedEvent(object sender)
{
ConnectedEvent?.Invoke(sender);
Connected?.Invoke(sender, EventArgs.Empty);
}
protected void Event_Disconnected(object sender, string DisconnectedMessage)
protected void RaiseConnectionDisconnectedEvent(object sender, string disconnectedMessage)
{
DisconnectedEvent?.Invoke(sender, DisconnectedMessage);
Disconnected?.Invoke(sender, disconnectedMessage);
}
protected void Event_ErrorOccured(object sender, string ErrorMsg)
protected void RaiseErrorOccuredEvent(object sender, string errorMsg)
{
ErrorOccuredEvent?.Invoke(sender, ErrorMsg);
ErrorOccured?.Invoke(sender, errorMsg);
}
protected void Event_ReconnectGroupCloseClicked()
{
Close();
}
#endregion
}
}

View File

@@ -1,4 +1,5 @@
using mRemoteNG.Connection.Protocol.Http;
using System;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
using mRemoteNG.Connection.Protocol.RAW;
using mRemoteNG.Connection.Protocol.RDP;
@@ -6,11 +7,10 @@ using mRemoteNG.Connection.Protocol.Rlogin;
using mRemoteNG.Connection.Protocol.SSH;
using mRemoteNG.Connection.Protocol.Telnet;
using mRemoteNG.Connection.Protocol.VNC;
using System;
namespace mRemoteNG.Connection.Protocol
{
public class ProtocolFactory
public class ProtocolFactory
{
public ProtocolBase CreateProtocol(ConnectionInfo connectionInfo)
{
@@ -19,42 +19,38 @@ namespace mRemoteNG.Connection.Protocol
switch (connectionInfo.Protocol)
{
case ProtocolType.RDP:
newProtocol = new RdpProtocol
{
LoadBalanceInfoUseUtf8 = Settings.Default.RdpLoadBalanceInfoUseUtf8
};
((RdpProtocol) newProtocol).tmrReconnect.Elapsed += ((RdpProtocol) newProtocol).tmrReconnect_Elapsed;
newProtocol = new RdpProtocolFactory().CreateProtocol(connectionInfo);
break;
case ProtocolType.VNC:
newProtocol = new ProtocolVNC();
newProtocol = new ProtocolVNC(connectionInfo);
break;
case ProtocolType.SSH1:
newProtocol = new ProtocolSSH1();
newProtocol = new ProtocolSSH1(connectionInfo);
break;
case ProtocolType.SSH2:
newProtocol = new ProtocolSSH2();
newProtocol = new ProtocolSSH2(connectionInfo);
break;
case ProtocolType.Telnet:
newProtocol = new ProtocolTelnet();
newProtocol = new ProtocolTelnet(connectionInfo);
break;
case ProtocolType.Rlogin:
newProtocol = new ProtocolRlogin();
newProtocol = new ProtocolRlogin(connectionInfo);
break;
case ProtocolType.RAW:
newProtocol = new RawProtocol();
newProtocol = new RawProtocol(connectionInfo);
break;
case ProtocolType.HTTP:
newProtocol = new ProtocolHTTP(connectionInfo.RenderingEngine);
newProtocol = new ProtocolHTTP(connectionInfo, connectionInfo.RenderingEngine);
break;
case ProtocolType.HTTPS:
newProtocol = new ProtocolHTTPS(connectionInfo.RenderingEngine);
newProtocol = new ProtocolHTTPS(connectionInfo, connectionInfo.RenderingEngine);
break;
case ProtocolType.ICA:
newProtocol = new IcaProtocol();
newProtocol = new IcaProtocol(connectionInfo);
((IcaProtocol) newProtocol).tmrReconnect.Elapsed += ((IcaProtocol) newProtocol).tmrReconnect_Elapsed;
break;
case ProtocolType.IntApp:
newProtocol = new IntegratedProgram();
newProtocol = new IntegratedProgram(connectionInfo);
if (connectionInfo.ExtApp == "")
{
throw (new Exception(Language.strNoExtAppDefined));

View File

@@ -36,10 +36,15 @@ namespace mRemoteNG.Connection.Protocol
#endregion
public PuttyBase(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
}
#region Private Events & Handlers
private void ProcessExited(object sender, EventArgs e)
{
Event_Closed(this);
RaiseConnectionClosedEvent(this);
}
#endregion
@@ -61,9 +66,9 @@ namespace mRemoteNG.Connection.Protocol
var arguments = new CommandLineArguments {EscapeForShell = false};
arguments.Add("-load", InterfaceControl.Info.PuttySession);
arguments.Add("-load", Info.PuttySession);
if (!(InterfaceControl.Info is PuttySessionInfo))
if (!(Info is PuttySessionInfo))
{
arguments.Add("-" + PuttyProtocol);
@@ -72,9 +77,9 @@ namespace mRemoteNG.Connection.Protocol
var username = "";
var password = "";
if (!string.IsNullOrEmpty(InterfaceControl.Info?.Username))
if (!string.IsNullOrEmpty(Info?.Username))
{
username = InterfaceControl.Info.Username;
username = Info.Username;
}
else
{
@@ -90,9 +95,9 @@ namespace mRemoteNG.Connection.Protocol
}
}
if (!string.IsNullOrEmpty(InterfaceControl.Info?.Password))
if (!string.IsNullOrEmpty(Info?.Password))
{
password = InterfaceControl.Info.Password;
password = Info.Password;
}
else
{
@@ -118,8 +123,8 @@ namespace mRemoteNG.Connection.Protocol
}
}
arguments.Add("-P", InterfaceControl.Info.Port.ToString());
arguments.Add(InterfaceControl.Info.Hostname);
arguments.Add("-P", Info.Port.ToString());
arguments.Add(Info.Hostname);
}
if (_isPuttyNg)

View File

@@ -2,8 +2,9 @@ namespace mRemoteNG.Connection.Protocol.RAW
{
public class RawProtocol : PuttyBase
{
public RawProtocol()
{
public RawProtocol(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.raw;
}

View File

@@ -0,0 +1,14 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RDGatewayUsageMethod
{
[LocalizedAttributes.LocalizedDescription("strNever")]
Never = 0, // TSC_PROXY_MODE_NONE_DIRECT
[LocalizedAttributes.LocalizedDescription("strAlways")]
Always = 1, // TSC_PROXY_MODE_DIRECT
[LocalizedAttributes.LocalizedDescription("strDetect")]
Detect = 2 // TSC_PROXY_MODE_DETECT
}
}

View File

@@ -0,0 +1,14 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RDGatewayUseConnectionCredentials
{
[LocalizedAttributes.LocalizedDescription("strUseDifferentUsernameAndPassword")]
No = 0,
[LocalizedAttributes.LocalizedDescription("strUseSameUsernameAndPassword")]
Yes = 1,
[LocalizedAttributes.LocalizedDescription("strUseSmartCard")]
SmartCard = 2
}
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpPerformanceFlags
{
[Description("strRDPDisableWallpaper")]DisableWallpaper = 0x1,
// [Description("strRDPDisableFullWindowdrag")]DisableFullWindowDrag = 0x2,
// [Description("strRDPDisableMenuAnimations")]DisableMenuAnimations = 0x4,
[Description("strRDPDisableThemes")]DisableThemes = 0x8,
// [Description("strRDPDisableCursorShadow")]DisableCursorShadow = 0x20,
// [Description("strRDPDisableCursorblinking")]DisableCursorBlinking = 0x40,
[Description("strRDPEnableFontSmoothing")]EnableFontSmoothing = 0x80,
[Description("strRDPEnableDesktopComposition")]EnableDesktopComposition = 0x100
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.ComponentModel;
using System.Drawing;
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpResolutions
{
[LocalizedAttributes.LocalizedDescription("strRDPFitToPanel")]
FitToWindow,
[LocalizedAttributes.LocalizedDescription("strFullscreen")]
Fullscreen,
[LocalizedAttributes.LocalizedDescription("strRDPSmartSize")]
SmartSize,
[Description("800x600")]
Res800x600,
[Description("1024x768")]
Res1024x768,
[Description("1152x864")]
Res1152x864,
[Description("1280x800")]
Res1280x800,
[Description("1280x1024")]
Res1280x1024,
[Description("1366x768")]
Res1366x768,
[Description("1440x900")]
Res1440x900,
[Description("1600x900")]
Res1600x900,
[Description("1600x1200")]
Res1600x1200,
[Description("1680x1050")]
Res1680x1050,
[Description("1920x1080")]
Res1920x1080,
[Description("1920x1200")]
Res1920x1200,
[Description("2048x1536")]
Res2048x1536,
[Description("2560x1440")]
Res2560x1440,
[Description("2560x1600")]
Res2560x1600,
[Description("2560x2048")]
Res2560x2048,
[Description("3840x2160")]
Res3840x2160
}
public static class RdpResolutionExtensions
{
public static Rectangle GetResolutionRectangle(this RdpResolutions resolution)
{
string[] resolutionParts = null;
if (resolution != RdpResolutions.FitToWindow & resolution != RdpResolutions.Fullscreen & resolution != RdpResolutions.SmartSize)
{
resolutionParts = resolution.ToString().Replace("Res", "").Split('x');
}
if (resolutionParts == null || resolutionParts.Length != 2)
{
return new Rectangle(0, 0, 0, 0);
}
return new Rectangle(0, 0, Convert.ToInt32(resolutionParts[0]), Convert.ToInt32(resolutionParts[1]));
}
}
}

View File

@@ -0,0 +1,14 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpSoundQuality
{
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityDynamic")]
Dynamic = 0,
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityMedium")]
Medium = 1,
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityHigh")]
High = 2
}
}

View File

@@ -0,0 +1,14 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpSounds
{
[LocalizedAttributes.LocalizedDescription("strRDPSoundBringToThisComputer")]
BringToThisComputer = 0,
[LocalizedAttributes.LocalizedDescription("strRDPSoundLeaveAtRemoteComputer")]
LeaveAtRemoteComputer = 1,
[LocalizedAttributes.LocalizedDescription("strRDPSoundDoNotPlay")]
DoNotPlay = 2
}
}

View File

@@ -0,0 +1,14 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpAuthenticationLevel
{
[LocalizedAttributes.LocalizedDescription("strAlwaysConnectEvenIfAuthFails")]
NoAuth = 0,
[LocalizedAttributes.LocalizedDescription("strDontConnectWhenAuthFails")]
AuthRequired = 1,
[LocalizedAttributes.LocalizedDescription("strWarnIfAuthFails")]
WarnOnFailedAuth = 2
}
}

View File

@@ -0,0 +1,18 @@
using mRemoteNG.Tools;
namespace mRemoteNG.Connection.Protocol.RDP
{
public enum RdpColors
{
[LocalizedAttributes.LocalizedDescription("strRDP256Colors")]
Colors256 = 8,
[LocalizedAttributes.LocalizedDescription("strRDP32768Colors")]
Colors15Bit = 15,
[LocalizedAttributes.LocalizedDescription("strRDP65536Colors")]
Colors16Bit = 16,
[LocalizedAttributes.LocalizedDescription("strRDP16777216Colors")]
Colors24Bit = 24,
[LocalizedAttributes.LocalizedDescription("strRDP4294967296Colors")]
Colors32Bit = 32
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
namespace mRemoteNG.Connection.Protocol.RDP
{
public static class RdpVersion
{
public static readonly Version RDC60 = new Version(6, 0, 6000);
public static readonly Version RDC61 = new Version(6, 0, 6001);
public static readonly Version RDC70 = new Version(6, 1, 7600);
public static readonly Version RDC80 = new Version(6, 2, 9200);
public static readonly Version RDC81 = new Version(6, 3, 9600);
}
/// <summary>
/// Represents a version of the RDP Client
/// </summary>
public enum RdpVersionEnum
{
Rdc6,
Rdc7,
Rdc8,
Rdc9,
Rdc10
}
public static class RdpVersionEnumExtensions
{
public static IEnumerable<RdpVersionEnum> GetAll(this RdpVersionEnum versionEnum)
{
return new[]
{
RdpVersionEnum.Rdc6,
RdpVersionEnum.Rdc7,
RdpVersionEnum.Rdc8,
RdpVersionEnum.Rdc9,
RdpVersionEnum.Rdc10
};
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections;
using mRemoteNG.App;
namespace mRemoteNG.Connection.Protocol.RDP
{
public static class RdpErrorTranslator
{
private static Hashtable _description;
private static void InitDescription()
{
_description = new Hashtable
{
{0, Language.strRdpErrorUnknown},
{1, Language.strRdpErrorCode1},
{2, Language.strRdpErrorOutOfMemory},
{3, Language.strRdpErrorWindowCreation},
{4, Language.strRdpErrorCode2},
{5, Language.strRdpErrorCode3},
{6, Language.strRdpErrorCode4},
{7, Language.strRdpErrorConnection},
{100, Language.strRdpErrorWinsock}
};
}
/// <summary>
/// Translates the provided RDP error ID to
/// a user-friendly error message.
/// </summary>
/// <param name="id"></param>
public static string Translate(int id)
{
try
{
if (_description == null)
InitDescription();
return (string)_description?[id];
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpErrorGetFailure, ex);
return string.Format(Language.strRdpErrorUnknown, id);
}
}
}
}

View File

@@ -1,933 +0,0 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using AxMSTSCLib;
using mRemoteNG.App;
using mRemoteNG.Messages;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tools;
using mRemoteNG.UI.Forms;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocol : ProtocolBase
{
/* RDP v8 requires Windows 7 with:
* https://support.microsoft.com/en-us/kb/2592687
* OR
* https://support.microsoft.com/en-us/kb/2923545
*
* Windows 8+ support RDP v8 out of the box.
*/
private MsRdpClient8NotSafeForScripting _rdpClient;
private Version _rdpVersion;
private ConnectionInfo _connectionInfo;
private bool _loginComplete;
private bool _redirectKeys;
private bool _alertOnIdleDisconnect;
private readonly FrmMain _frmMain = FrmMain.Default;
#region Properties
public bool SmartSize
{
get
{
return _rdpClient.AdvancedSettings2.SmartSizing;
}
private set
{
_rdpClient.AdvancedSettings2.SmartSizing = value;
ReconnectForResize();
}
}
public bool Fullscreen
{
get
{
return _rdpClient.FullScreen;
}
private set
{
_rdpClient.FullScreen = value;
ReconnectForResize();
}
}
private bool RedirectKeys
{
/*
get
{
return _redirectKeys;
}
*/
set
{
_redirectKeys = value;
try
{
if (!_redirectKeys)
{
return;
}
Debug.Assert(Convert.ToBoolean(_rdpClient.SecuredSettingsEnabled));
var msRdpClientSecuredSettings = _rdpClient.SecuredSettings2;
msRdpClientSecuredSettings.KeyboardHookMode = 1; // Apply key combinations at the remote server.
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetRedirectKeysFailed, ex);
}
}
}
public bool LoadBalanceInfoUseUtf8 { get; set; }
#endregion
#region Constructors
public RdpProtocol()
{
Control = new AxMsRdpClient8NotSafeForScripting();
}
#endregion
#region Public Methods
public override bool Initialize()
{
base.Initialize();
try
{
Control.CreateControl();
_connectionInfo = InterfaceControl.Info;
try
{
while (!Control.Created)
{
Thread.Sleep(0);
Application.DoEvents();
}
_rdpClient = (MsRdpClient8NotSafeForScripting)((AxMsRdpClient8NotSafeForScripting)Control).GetOcx();
}
catch (System.Runtime.InteropServices.COMException ex)
{
Runtime.MessageCollector.AddExceptionMessage(Language.strRdpControlCreationFailed, ex);
Control.Dispose();
return false;
}
_rdpVersion = new Version(_rdpClient.Version);
_rdpClient.Server = _connectionInfo.Hostname;
SetCredentials();
SetResolution();
_rdpClient.FullScreenTitle = _connectionInfo.Name;
_alertOnIdleDisconnect = _connectionInfo.RDPAlertIdleTimeout;
_rdpClient.AdvancedSettings2.MinutesToIdleTimeout = _connectionInfo.RDPMinutesToIdleTimeout;
//not user changeable
_rdpClient.AdvancedSettings2.GrabFocusOnConnect = true;
_rdpClient.AdvancedSettings3.EnableAutoReconnect = true;
_rdpClient.AdvancedSettings3.MaxReconnectAttempts = Settings.Default.RdpReconnectionCount;
_rdpClient.AdvancedSettings2.keepAliveInterval = 60000; //in milliseconds (10,000 = 10 seconds)
_rdpClient.AdvancedSettings5.AuthenticationLevel = 0;
_rdpClient.AdvancedSettings2.EncryptionEnabled = 1;
_rdpClient.AdvancedSettings2.overallConnectionTimeout = Settings.Default.ConRDPOverallConnectionTimeout;
_rdpClient.AdvancedSettings2.BitmapPeristence = Convert.ToInt32(_connectionInfo.CacheBitmaps);
if (_rdpVersion >= Versions.RDC61)
{
_rdpClient.AdvancedSettings7.EnableCredSspSupport = _connectionInfo.UseCredSsp;
_rdpClient.AdvancedSettings8.AudioQualityMode = (uint)_connectionInfo.SoundQuality;
}
SetUseConsoleSession();
SetPort();
RedirectKeys = _connectionInfo.RedirectKeys;
SetRedirection();
SetAuthenticationLevel();
SetLoadBalanceInfo();
SetRdGateway();
_rdpClient.ColorDepth = (int)_connectionInfo.Colors;
SetPerformanceFlags();
_rdpClient.ConnectingText = Language.strConnecting;
Control.Anchor = AnchorStyles.None;
return true;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPropsFailed, ex);
return false;
}
}
public override bool Connect()
{
_loginComplete = false;
SetEventHandlers();
try
{
_rdpClient.Connect();
base.Connect();
return true;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strConnectionOpenFailed, ex);
}
return false;
}
public override void Disconnect()
{
try
{
_rdpClient.Disconnect();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpDisconnectFailed, ex);
Close();
}
}
public void ToggleFullscreen()
{
try
{
Fullscreen = !Fullscreen;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpToggleFullscreenFailed, ex);
}
}
public void ToggleSmartSize()
{
try
{
SmartSize = !SmartSize;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpToggleSmartSizeFailed, ex);
}
}
public override void Focus()
{
try
{
if (Control.ContainsFocus == false)
{
Control.Focus();
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpFocusFailed, ex);
}
}
private Size _controlBeginningSize;
public override void ResizeBegin(object sender, EventArgs e)
{
_controlBeginningSize = Control.Size;
}
public override void Resize(object sender, EventArgs e)
{
if (DoResize() && _controlBeginningSize.IsEmpty)
{
ReconnectForResize();
}
base.Resize(sender, e);
}
public override void ResizeEnd(object sender, EventArgs e)
{
DoResize();
if (!(Control.Size == _controlBeginningSize))
{
ReconnectForResize();
}
_controlBeginningSize = Size.Empty;
}
#endregion
#region Private Methods
private bool DoResize()
{
Control.Location = InterfaceControl.Location;
if (!(Control.Size == InterfaceControl.Size) && !(InterfaceControl.Size == Size.Empty)) // kmscode - this doesn't look right to me. But I'm not aware of any functionality issues with this currently...
{
Control.Size = InterfaceControl.Size;
return true;
}
else
{
return false;
}
}
private void ReconnectForResize()
{
if (_rdpVersion < Versions.RDC80)
{
return;
}
if (!_loginComplete)
{
return;
}
if (!InterfaceControl.Info.AutomaticResize)
{
return;
}
if (!(InterfaceControl.Info.Resolution == RDPResolutions.FitToWindow | InterfaceControl.Info.Resolution == RDPResolutions.Fullscreen))
{
return;
}
if (SmartSize)
{
return;
}
var size = !Fullscreen ? Control.Size : Screen.FromControl(Control).Bounds.Size;
IMsRdpClient8 msRdpClient8 = _rdpClient;
msRdpClient8.Reconnect((uint)size.Width, (uint)size.Height);
}
private void SetRdGateway()
{
try
{
if (_rdpClient.TransportSettings.GatewayIsSupported == 0)
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strRdpGatewayNotSupported, true);
return;
}
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strRdpGatewayIsSupported, true);
if (_connectionInfo.RDGatewayUsageMethod != RDGatewayUsageMethod.Never)
{
_rdpClient.TransportSettings.GatewayUsageMethod = (uint)_connectionInfo.RDGatewayUsageMethod;
_rdpClient.TransportSettings.GatewayHostname = _connectionInfo.RDGatewayHostname;
_rdpClient.TransportSettings.GatewayProfileUsageMethod = 1; // TSC_PROXY_PROFILE_MODE_EXPLICIT
if (_connectionInfo.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.SmartCard)
{
_rdpClient.TransportSettings.GatewayCredsSource = 1; // TSC_PROXY_CREDS_MODE_SMARTCARD
}
if (_rdpVersion >= Versions.RDC61 && (Force & ConnectionInfo.Force.NoCredentials) != ConnectionInfo.Force.NoCredentials)
{
if (_connectionInfo.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.Yes)
{
_rdpClient.TransportSettings2.GatewayUsername = _connectionInfo.Username;
_rdpClient.TransportSettings2.GatewayPassword = _connectionInfo.Password;
_rdpClient.TransportSettings2.GatewayDomain = _connectionInfo?.Domain;
}
else if (_connectionInfo.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.SmartCard)
{
_rdpClient.TransportSettings2.GatewayCredSharing = 0;
}
else
{
_rdpClient.TransportSettings2.GatewayUsername = _connectionInfo.RDGatewayUsername;
_rdpClient.TransportSettings2.GatewayPassword = _connectionInfo.RDGatewayPassword;
_rdpClient.TransportSettings2.GatewayDomain = _connectionInfo.RDGatewayDomain;
_rdpClient.TransportSettings2.GatewayCredSharing = 0;
}
}
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetGatewayFailed, ex);
}
}
private void SetUseConsoleSession()
{
try
{
bool value;
if ((Force & ConnectionInfo.Force.UseConsoleSession) == ConnectionInfo.Force.UseConsoleSession)
{
value = true;
}
else if ((Force & ConnectionInfo.Force.DontUseConsoleSession) == ConnectionInfo.Force.DontUseConsoleSession)
{
value = false;
}
else
{
value = _connectionInfo.UseConsoleSession;
}
if (_rdpVersion >= Versions.RDC61)
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion), true);
_rdpClient.AdvancedSettings7.ConnectToAdministerServer = value;
}
else
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion) + Environment.NewLine + "No longer supported in this RDP version. Reference: https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx", true);
// ConnectToServerConsole is deprecated
//https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx
//_rdpClient.AdvancedSettings2.ConnectToServerConsole = value;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetConsoleSessionFailed, ex);
}
}
private void SetCredentials()
{
try
{
if ((Force & ConnectionInfo.Force.NoCredentials) == ConnectionInfo.Force.NoCredentials)
{
return;
}
var userName = _connectionInfo?.Username ?? "";
var password = _connectionInfo?.Password ?? "";
var domain = _connectionInfo?.Domain ?? "";
if (string.IsNullOrEmpty(userName))
{
if (Settings.Default.EmptyCredentials == "windows")
{
_rdpClient.UserName = Environment.UserName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
_rdpClient.UserName = Settings.Default.DefaultUsername;
}
}
else
{
_rdpClient.UserName = userName;
}
if (string.IsNullOrEmpty(password))
{
if (Settings.Default.EmptyCredentials == "custom")
{
if (Settings.Default.DefaultPassword != "")
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
_rdpClient.AdvancedSettings2.ClearTextPassword = cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey);
}
}
}
else
{
_rdpClient.AdvancedSettings2.ClearTextPassword = password;
}
if (string.IsNullOrEmpty(domain))
{
if (Settings.Default.EmptyCredentials == "windows")
{
_rdpClient.Domain = Environment.UserDomainName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
_rdpClient.Domain = Settings.Default.DefaultDomain;
}
}
else
{
_rdpClient.Domain = domain;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetCredentialsFailed, ex);
}
}
private void SetResolution()
{
try
{
if ((Force & ConnectionInfo.Force.Fullscreen) == ConnectionInfo.Force.Fullscreen)
{
_rdpClient.FullScreen = true;
_rdpClient.DesktopWidth = Screen.FromControl(_frmMain).Bounds.Width;
_rdpClient.DesktopHeight = Screen.FromControl(_frmMain).Bounds.Height;
return;
}
if ((InterfaceControl.Info.Resolution == RDPResolutions.FitToWindow) || (InterfaceControl.Info.Resolution == RDPResolutions.SmartSize))
{
_rdpClient.DesktopWidth = InterfaceControl.Size.Width;
_rdpClient.DesktopHeight = InterfaceControl.Size.Height;
if (InterfaceControl.Info.Resolution == RDPResolutions.SmartSize)
{
_rdpClient.AdvancedSettings2.SmartSizing = true;
}
}
else if (InterfaceControl.Info.Resolution == RDPResolutions.Fullscreen)
{
_rdpClient.FullScreen = true;
_rdpClient.DesktopWidth = Screen.FromControl(_frmMain).Bounds.Width;
_rdpClient.DesktopHeight = Screen.FromControl(_frmMain).Bounds.Height;
}
else
{
var resolution = GetResolutionRectangle(_connectionInfo.Resolution);
_rdpClient.DesktopWidth = resolution.Width;
_rdpClient.DesktopHeight = resolution.Height;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetResolutionFailed, ex);
}
}
private void SetPort()
{
try
{
if (_connectionInfo.Port != (int)Defaults.Port)
{
_rdpClient.AdvancedSettings2.RDPPort = _connectionInfo.Port;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPortFailed, ex);
}
}
private void SetRedirection()
{
try
{
_rdpClient.AdvancedSettings2.RedirectDrives = _connectionInfo.RedirectDiskDrives;
_rdpClient.AdvancedSettings2.RedirectPorts = _connectionInfo.RedirectPorts;
_rdpClient.AdvancedSettings2.RedirectPrinters = _connectionInfo.RedirectPrinters;
_rdpClient.AdvancedSettings2.RedirectSmartCards = _connectionInfo.RedirectSmartCards;
_rdpClient.SecuredSettings2.AudioRedirectionMode = (int)_connectionInfo.RedirectSound;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetRedirectionFailed, ex);
}
}
private void SetPerformanceFlags()
{
try
{
var pFlags = 0;
if (_connectionInfo.DisplayThemes == false)
{
pFlags += Convert.ToInt32(RDPPerformanceFlags.DisableThemes);
}
if (_connectionInfo.DisplayWallpaper == false)
{
pFlags += Convert.ToInt32(RDPPerformanceFlags.DisableWallpaper);
}
if (_connectionInfo.EnableFontSmoothing)
{
pFlags += Convert.ToInt32(RDPPerformanceFlags.EnableFontSmoothing);
}
if (_connectionInfo.EnableDesktopComposition)
{
pFlags += Convert.ToInt32(RDPPerformanceFlags.EnableDesktopComposition);
}
_rdpClient.AdvancedSettings2.PerformanceFlags = pFlags;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPerformanceFlagsFailed, ex);
}
}
private void SetAuthenticationLevel()
{
try
{
_rdpClient.AdvancedSettings5.AuthenticationLevel = (uint)_connectionInfo.RDPAuthenticationLevel;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetAuthenticationLevelFailed, ex);
}
}
private void SetLoadBalanceInfo()
{
if (string.IsNullOrEmpty(_connectionInfo.LoadBalanceInfo))
{
return;
}
try
{
_rdpClient.AdvancedSettings2.LoadBalanceInfo = LoadBalanceInfoUseUtf8
? new AzureLoadBalanceInfoEncoder().Encode(_connectionInfo.LoadBalanceInfo)
: _connectionInfo.LoadBalanceInfo;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("Unable to set load balance info.", ex);
}
}
private void SetEventHandlers()
{
try
{
_rdpClient.OnConnecting += RDPEvent_OnConnecting;
_rdpClient.OnConnected += RDPEvent_OnConnected;
_rdpClient.OnLoginComplete += RDPEvent_OnLoginComplete;
_rdpClient.OnFatalError += RDPEvent_OnFatalError;
_rdpClient.OnDisconnected += RDPEvent_OnDisconnected;
_rdpClient.OnLeaveFullScreenMode += RDPEvent_OnLeaveFullscreenMode;
_rdpClient.OnIdleTimeoutNotification += RDPEvent_OnIdleTimeoutNotification;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetEventHandlersFailed, ex);
}
}
#endregion
#region Private Events & Handlers
private void RDPEvent_OnIdleTimeoutNotification()
{
Close(); //Simply close the RDP Session if the idle timeout has been triggered.
if (_alertOnIdleDisconnect)
{
string message = "The " + _connectionInfo.Name + " session was disconnected due to inactivity";
const string caption = "Session Disconnected";
MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void RDPEvent_OnFatalError(int errorCode)
{
Event_ErrorOccured(this, Convert.ToString(errorCode));
}
private void RDPEvent_OnDisconnected(int discReason)
{
const int UI_ERR_NORMAL_DISCONNECT = 0xB08;
if (discReason != UI_ERR_NORMAL_DISCONNECT)
{
var reason = _rdpClient.GetErrorDescription((uint)discReason, (uint) _rdpClient.ExtendedDisconnectReason);
Event_Disconnected(this, discReason + "\r\n" + reason);
}
if (Settings.Default.ReconnectOnDisconnect)
{
ReconnectGroup = new ReconnectGroup();
ReconnectGroup.CloseClicked += Event_ReconnectGroupCloseClicked;
ReconnectGroup.Left = (int) ((double) Control.Width / 2 - (double) ReconnectGroup.Width / 2);
ReconnectGroup.Top = (int) ((double) Control.Height / 2 - (double) ReconnectGroup.Height / 2);
ReconnectGroup.Parent = Control;
ReconnectGroup.Show();
tmrReconnect.Enabled = true;
}
else
{
Close();
}
}
private void RDPEvent_OnConnecting()
{
Event_Connecting(this);
}
private void RDPEvent_OnConnected()
{
Event_Connected(this);
}
private void RDPEvent_OnLoginComplete()
{
_loginComplete = true;
}
private void RDPEvent_OnLeaveFullscreenMode()
{
Fullscreen = false;
_leaveFullscreenEvent?.Invoke(this, new EventArgs());
}
#endregion
#region Public Events & Handlers
public delegate void LeaveFullscreenEventHandler(object sender, EventArgs e);
private LeaveFullscreenEventHandler _leaveFullscreenEvent;
public event LeaveFullscreenEventHandler LeaveFullscreen
{
add
{
_leaveFullscreenEvent = (LeaveFullscreenEventHandler)Delegate.Combine(_leaveFullscreenEvent, value);
}
remove
{
_leaveFullscreenEvent = (LeaveFullscreenEventHandler)Delegate.Remove(_leaveFullscreenEvent, value);
}
}
#endregion
#region Enums
public enum Defaults
{
Colors = RDPColors.Colors16Bit,
Sounds = RDPSounds.DoNotPlay,
Resolution = RDPResolutions.FitToWindow,
Port = 3389
}
public enum RDPColors
{
[LocalizedAttributes.LocalizedDescription("strRDP256Colors")]
Colors256 = 8,
[LocalizedAttributes.LocalizedDescription("strRDP32768Colors")]
Colors15Bit = 15,
[LocalizedAttributes.LocalizedDescription("strRDP65536Colors")]
Colors16Bit = 16,
[LocalizedAttributes.LocalizedDescription("strRDP16777216Colors")]
Colors24Bit = 24,
[LocalizedAttributes.LocalizedDescription("strRDP4294967296Colors")]
Colors32Bit = 32
}
public enum RDPSounds
{
[LocalizedAttributes.LocalizedDescription("strRDPSoundBringToThisComputer")]
BringToThisComputer = 0,
[LocalizedAttributes.LocalizedDescription("strRDPSoundLeaveAtRemoteComputer")]
LeaveAtRemoteComputer = 1,
[LocalizedAttributes.LocalizedDescription("strRDPSoundDoNotPlay")]
DoNotPlay = 2
}
public enum RDPSoundQuality
{
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityDynamic")]
Dynamic = 0,
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityMedium")]
Medium = 1,
[LocalizedAttributes.LocalizedDescription("strRDPSoundQualityHigh")]
High = 2
}
private enum RDPPerformanceFlags
{
[Description("strRDPDisableWallpaper")]DisableWallpaper = 0x1,
// [Description("strRDPDisableFullWindowdrag")]DisableFullWindowDrag = 0x2,
// [Description("strRDPDisableMenuAnimations")]DisableMenuAnimations = 0x4,
[Description("strRDPDisableThemes")]DisableThemes = 0x8,
// [Description("strRDPDisableCursorShadow")]DisableCursorShadow = 0x20,
// [Description("strRDPDisableCursorblinking")]DisableCursorBlinking = 0x40,
[Description("strRDPEnableFontSmoothing")]EnableFontSmoothing = 0x80,
[Description("strRDPEnableDesktopComposition")]EnableDesktopComposition = 0x100
}
public enum RDPResolutions
{
[LocalizedAttributes.LocalizedDescription("strRDPFitToPanel")]
FitToWindow,
[LocalizedAttributes.LocalizedDescription("strFullscreen")]
Fullscreen,
[LocalizedAttributes.LocalizedDescription("strRDPSmartSize")]
SmartSize,
[Description("800x600")]
Res800x600,
[Description("1024x768")]
Res1024x768,
[Description("1152x864")]
Res1152x864,
[Description("1280x800")]
Res1280x800,
[Description("1280x1024")]
Res1280x1024,
[Description("1366x768")]
Res1366x768,
[Description("1440x900")]
Res1440x900,
[Description("1600x900")]
Res1600x900,
[Description("1600x1200")]
Res1600x1200,
[Description("1680x1050")]
Res1680x1050,
[Description("1920x1080")]
Res1920x1080,
[Description("1920x1200")]
Res1920x1200,
[Description("2048x1536")]
Res2048x1536,
[Description("2560x1440")]
Res2560x1440,
[Description("2560x1600")]
Res2560x1600,
[Description("2560x2048")]
Res2560x2048,
[Description("3840x2160")]
Res3840x2160
}
public enum AuthenticationLevel
{
[LocalizedAttributes.LocalizedDescription("strAlwaysConnectEvenIfAuthFails")]
NoAuth = 0,
[LocalizedAttributes.LocalizedDescription("strDontConnectWhenAuthFails")]
AuthRequired = 1,
[LocalizedAttributes.LocalizedDescription("strWarnIfAuthFails")]
WarnOnFailedAuth = 2
}
public enum RDGatewayUsageMethod
{
[LocalizedAttributes.LocalizedDescription("strNever")]
Never = 0, // TSC_PROXY_MODE_NONE_DIRECT
[LocalizedAttributes.LocalizedDescription("strAlways")]
Always = 1, // TSC_PROXY_MODE_DIRECT
[LocalizedAttributes.LocalizedDescription("strDetect")]
Detect = 2 // TSC_PROXY_MODE_DETECT
}
public enum RDGatewayUseConnectionCredentials
{
[LocalizedAttributes.LocalizedDescription("strUseDifferentUsernameAndPassword")]
No = 0,
[LocalizedAttributes.LocalizedDescription("strUseSameUsernameAndPassword")]
Yes = 1,
[LocalizedAttributes.LocalizedDescription("strUseSmartCard")]
SmartCard = 2
}
#endregion
#region Resolution
public static Rectangle GetResolutionRectangle(RDPResolutions resolution)
{
string[] resolutionParts = null;
if (resolution != RDPResolutions.FitToWindow & resolution != RDPResolutions.Fullscreen & resolution != RDPResolutions.SmartSize)
{
resolutionParts = resolution.ToString().Replace("Res", "").Split('x');
}
if (resolutionParts == null || resolutionParts.Length != 2)
{
return new Rectangle(0, 0, 0, 0);
}
else
{
return new Rectangle(0, 0, Convert.ToInt32(resolutionParts[0]), Convert.ToInt32(resolutionParts[1]));
}
}
#endregion
public static class Versions
{
public static readonly Version RDC60 = new Version(6, 0, 6000);
public static readonly Version RDC61 = new Version(6, 0, 6001);
public static readonly Version RDC70 = new Version(6, 1, 7600);
public static readonly Version RDC80 = new Version(6, 2, 9200);
public static readonly Version RDC81 = new Version(6, 3, 9600);
}
#region Fatal Errors
public static class FatalErrors
{
private static Hashtable _description;
private static void InitDescription()
{
_description = new Hashtable
{
{"0", "Language.strRdpErrorUnknown"},
{"1", "Language.strRdpErrorCode1"},
{"2", "Language.strRdpErrorOutOfMemory"},
{"3", "Language.strRdpErrorWindowCreation"},
{"4", "Language.strRdpErrorCode2"},
{"5", "Language.strRdpErrorCode3"},
{"6", "Language.strRdpErrorCode4"},
{"7", "Language.strRdpErrorConnection"},
{"100", "Language.strRdpErrorWinsock"}
};
}
public static string GetError(string id)
{
try
{
if (_description == null)
InitDescription();
return (string)_description?[id];
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpErrorGetFailure, ex);
return string.Format(Language.strRdpErrorUnknown, id);
}
}
}
#endregion
#region Reconnect Stuff
public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
var srvReady = PortScanner.IsPortOpen(_connectionInfo.Hostname, Convert.ToString(_connectionInfo.Port));
ReconnectGroup.ServerReady = srvReady;
if (ReconnectGroup.ReconnectWhenReady && srvReady)
{
tmrReconnect.Enabled = false;
ReconnectGroup.DisposeReconnectGroup();
//SetProps()
_rdpClient.Connect();
}
}
#endregion
}
}

View File

@@ -0,0 +1,20 @@
using AxMSTSCLib;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocol10 : RdpProtocol9
{
public RdpProtocol10(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new AxMsRdpClient10NotSafeForScripting();
RdpVersionEnum = RdpVersionEnum.Rdc10;
}
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
{
return (MsRdpClient6NotSafeForScripting)((AxMsRdpClient10NotSafeForScripting)Control).GetOcx();
}
}
}

View File

@@ -0,0 +1,657 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using AxMSTSCLib;
using mRemoteNG.App;
using mRemoteNG.Messages;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tools;
using mRemoteNG.UI.Forms;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocol6 : ProtocolBase
{
private Version _rdpVersion;
private bool _redirectKeys;
private bool _alertOnIdleDisconnect;
private readonly FrmMain _frmMain = FrmMain.Default;
protected MsRdpClient6NotSafeForScripting RdpClient;
protected bool LoginComplete;
#region Properties
public virtual bool SmartSize
{
get
{
return RdpClient.AdvancedSettings2.SmartSizing;
}
protected set
{
RdpClient.AdvancedSettings2.SmartSizing = value;
}
}
public virtual bool Fullscreen
{
get
{
return RdpClient.FullScreen;
}
protected set
{
RdpClient.FullScreen = value;
}
}
private bool RedirectKeys
{
/*
get
{
return _redirectKeys;
}
*/
set
{
_redirectKeys = value;
try
{
if (!_redirectKeys)
{
return;
}
Debug.Assert(Convert.ToBoolean(RdpClient.SecuredSettingsEnabled));
var msRdpClientSecuredSettings = RdpClient.SecuredSettings2;
msRdpClientSecuredSettings.KeyboardHookMode = 1; // Apply key combinations at the remote server.
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetRedirectKeysFailed, ex);
}
}
}
public bool LoadBalanceInfoUseUtf8 { get; set; }
public RdpVersionEnum RdpVersionEnum { get; protected set; }
#endregion
public RdpProtocol6(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new AxMsRdpClient6NotSafeForScripting();
Connecting += OnConnectingDebugMessage;
RdpVersionEnum = RdpVersionEnum.Rdc6;
}
#region Public Methods
public override bool Initialize()
{
base.Initialize();
try
{
Control.CreateControl();
try
{
while (!Control.Created)
{
Thread.Sleep(0);
Application.DoEvents();
}
RdpClient = CreateRdpClientControl();
}
catch (System.Runtime.InteropServices.COMException ex)
{
Runtime.MessageCollector.AddExceptionMessage(Language.strRdpControlCreationFailed, ex);
Control.Dispose();
return false;
}
_rdpVersion = new Version(RdpClient.Version);
RdpClient.Server = Info.Hostname;
SetCredentials();
SetResolution();
RdpClient.FullScreenTitle = Info.Name;
_alertOnIdleDisconnect = Info.RDPAlertIdleTimeout;
RdpClient.AdvancedSettings2.MinutesToIdleTimeout = Info.RDPMinutesToIdleTimeout;
//not user changeable
RdpClient.AdvancedSettings2.GrabFocusOnConnect = true;
RdpClient.AdvancedSettings3.EnableAutoReconnect = true;
RdpClient.AdvancedSettings3.MaxReconnectAttempts = Settings.Default.RdpReconnectionCount;
RdpClient.AdvancedSettings2.keepAliveInterval = 60000; //in milliseconds (10,000 = 10 seconds)
RdpClient.AdvancedSettings5.AuthenticationLevel = 0;
RdpClient.AdvancedSettings2.EncryptionEnabled = 1;
RdpClient.AdvancedSettings2.overallConnectionTimeout = Settings.Default.ConRDPOverallConnectionTimeout;
RdpClient.AdvancedSettings2.BitmapPeristence = Convert.ToInt32(Info.CacheBitmaps);
if (_rdpVersion >= RdpVersion.RDC61)
{
RdpClient.AdvancedSettings7.EnableCredSspSupport = Info.UseCredSsp;
}
SetUseConsoleSession();
SetPort();
RedirectKeys = Info.RedirectKeys;
SetRedirection();
SetAuthenticationLevel();
SetLoadBalanceInfo();
SetRdGateway();
RdpClient.ColorDepth = (int)Info.Colors;
SetPerformanceFlags();
RdpClient.ConnectingText = Language.strConnecting;
Control.Anchor = AnchorStyles.None;
tmrReconnect.Elapsed += tmrReconnect_Elapsed;
return true;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPropsFailed, ex);
return false;
}
}
public override bool Connect()
{
LoginComplete = false;
SetEventHandlers();
try
{
RdpClient.Connect();
base.Connect();
return true;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strConnectionOpenFailed, ex);
}
return false;
}
public override void Disconnect()
{
try
{
RdpClient.Disconnect();
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpDisconnectFailed, ex);
Close();
}
}
public void ToggleFullscreen()
{
try
{
Fullscreen = !Fullscreen;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpToggleFullscreenFailed, ex);
}
}
public void ToggleSmartSize()
{
try
{
SmartSize = !SmartSize;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpToggleSmartSizeFailed, ex);
}
}
public override void Focus()
{
try
{
if (Control.ContainsFocus == false)
{
Control.Focus();
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpFocusFailed, ex);
}
}
#endregion
#region Private Methods
protected virtual MsRdpClient6NotSafeForScripting CreateRdpClientControl()
{
return (MsRdpClient6NotSafeForScripting)((AxMsRdpClient6NotSafeForScripting)Control).GetOcx();
}
private void SetRdGateway()
{
try
{
if (RdpClient.TransportSettings.GatewayIsSupported == 0)
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strRdpGatewayNotSupported, true);
return;
}
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strRdpGatewayIsSupported, true);
if (Info.RDGatewayUsageMethod != RDGatewayUsageMethod.Never)
{
RdpClient.TransportSettings.GatewayUsageMethod = (uint)Info.RDGatewayUsageMethod;
RdpClient.TransportSettings.GatewayHostname = Info.RDGatewayHostname;
RdpClient.TransportSettings.GatewayProfileUsageMethod = 1; // TSC_PROXY_PROFILE_MODE_EXPLICIT
if (Info.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.SmartCard)
{
RdpClient.TransportSettings.GatewayCredsSource = 1; // TSC_PROXY_CREDS_MODE_SMARTCARD
}
if (_rdpVersion >= RdpVersion.RDC61 && (Force & ConnectionInfo.Force.NoCredentials) != ConnectionInfo.Force.NoCredentials)
{
if (Info.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.Yes)
{
RdpClient.TransportSettings2.GatewayUsername = Info.Username;
RdpClient.TransportSettings2.GatewayPassword = Info.Password;
RdpClient.TransportSettings2.GatewayDomain = Info?.Domain;
}
else if (Info.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.SmartCard)
{
RdpClient.TransportSettings2.GatewayCredSharing = 0;
}
else
{
RdpClient.TransportSettings2.GatewayUsername = Info.RDGatewayUsername;
RdpClient.TransportSettings2.GatewayPassword = Info.RDGatewayPassword;
RdpClient.TransportSettings2.GatewayDomain = Info.RDGatewayDomain;
RdpClient.TransportSettings2.GatewayCredSharing = 0;
}
}
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetGatewayFailed, ex);
}
}
private void SetUseConsoleSession()
{
try
{
bool value;
if ((Force & ConnectionInfo.Force.UseConsoleSession) == ConnectionInfo.Force.UseConsoleSession)
{
value = true;
}
else if ((Force & ConnectionInfo.Force.DontUseConsoleSession) == ConnectionInfo.Force.DontUseConsoleSession)
{
value = false;
}
else
{
value = Info.UseConsoleSession;
}
if (_rdpVersion >= RdpVersion.RDC61)
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion), true);
RdpClient.AdvancedSettings7.ConnectToAdministerServer = value;
}
else
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion) + Environment.NewLine + "No longer supported in this RDP version. Reference: https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx", true);
// ConnectToServerConsole is deprecated
//https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx
//_rdpClient.AdvancedSettings2.ConnectToServerConsole = value;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetConsoleSessionFailed, ex);
}
}
private void SetCredentials()
{
try
{
if ((Force & ConnectionInfo.Force.NoCredentials) == ConnectionInfo.Force.NoCredentials)
{
return;
}
var userName = Info?.Username ?? "";
var password = Info?.Password ?? "";
var domain = Info?.Domain ?? "";
if (string.IsNullOrEmpty(userName))
{
if (Settings.Default.EmptyCredentials == "windows")
{
RdpClient.UserName = Environment.UserName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
RdpClient.UserName = Settings.Default.DefaultUsername;
}
}
else
{
RdpClient.UserName = userName;
}
if (string.IsNullOrEmpty(password))
{
if (Settings.Default.EmptyCredentials == "custom")
{
if (Settings.Default.DefaultPassword != "")
{
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
RdpClient.AdvancedSettings2.ClearTextPassword = cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey);
}
}
}
else
{
RdpClient.AdvancedSettings2.ClearTextPassword = password;
}
if (string.IsNullOrEmpty(domain))
{
if (Settings.Default.EmptyCredentials == "windows")
{
RdpClient.Domain = Environment.UserDomainName;
}
else if (Settings.Default.EmptyCredentials == "custom")
{
RdpClient.Domain = Settings.Default.DefaultDomain;
}
}
else
{
RdpClient.Domain = domain;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetCredentialsFailed, ex);
}
}
private void SetResolution()
{
try
{
if ((Force & ConnectionInfo.Force.Fullscreen) == ConnectionInfo.Force.Fullscreen)
{
RdpClient.FullScreen = true;
RdpClient.DesktopWidth = Screen.FromControl(_frmMain).Bounds.Width;
RdpClient.DesktopHeight = Screen.FromControl(_frmMain).Bounds.Height;
return;
}
if ((Info.Resolution == RdpResolutions.FitToWindow) || (Info.Resolution == RdpResolutions.SmartSize))
{
RdpClient.DesktopWidth = InterfaceControl.Size.Width;
RdpClient.DesktopHeight = InterfaceControl.Size.Height;
if (Info.Resolution == RdpResolutions.SmartSize)
{
RdpClient.AdvancedSettings2.SmartSizing = true;
}
}
else if (Info.Resolution == RdpResolutions.Fullscreen)
{
RdpClient.FullScreen = true;
RdpClient.DesktopWidth = Screen.FromControl(_frmMain).Bounds.Width;
RdpClient.DesktopHeight = Screen.FromControl(_frmMain).Bounds.Height;
}
else
{
var resolution = Info.Resolution.GetResolutionRectangle();
RdpClient.DesktopWidth = resolution.Width;
RdpClient.DesktopHeight = resolution.Height;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetResolutionFailed, ex);
}
}
private void SetPort()
{
try
{
if (Info.Port != (int)Defaults.Port)
{
RdpClient.AdvancedSettings2.RDPPort = Info.Port;
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPortFailed, ex);
}
}
private void SetRedirection()
{
try
{
RdpClient.AdvancedSettings2.RedirectDrives = Info.RedirectDiskDrives;
RdpClient.AdvancedSettings2.RedirectPorts = Info.RedirectPorts;
RdpClient.AdvancedSettings2.RedirectPrinters = Info.RedirectPrinters;
RdpClient.AdvancedSettings2.RedirectSmartCards = Info.RedirectSmartCards;
RdpClient.SecuredSettings2.AudioRedirectionMode = (int)Info.RedirectSound;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetRedirectionFailed, ex);
}
}
private void SetPerformanceFlags()
{
try
{
var pFlags = 0;
if (Info.DisplayThemes == false)
{
pFlags += Convert.ToInt32(RdpPerformanceFlags.DisableThemes);
}
if (Info.DisplayWallpaper == false)
{
pFlags += Convert.ToInt32(RdpPerformanceFlags.DisableWallpaper);
}
if (Info.EnableFontSmoothing)
{
pFlags += Convert.ToInt32(RdpPerformanceFlags.EnableFontSmoothing);
}
if (Info.EnableDesktopComposition)
{
pFlags += Convert.ToInt32(RdpPerformanceFlags.EnableDesktopComposition);
}
RdpClient.AdvancedSettings2.PerformanceFlags = pFlags;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPerformanceFlagsFailed, ex);
}
}
private void SetAuthenticationLevel()
{
try
{
RdpClient.AdvancedSettings5.AuthenticationLevel = (uint)Info.RDPAuthenticationLevel;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetAuthenticationLevelFailed, ex);
}
}
private void SetLoadBalanceInfo()
{
if (string.IsNullOrEmpty(Info.LoadBalanceInfo))
{
return;
}
try
{
RdpClient.AdvancedSettings2.LoadBalanceInfo = LoadBalanceInfoUseUtf8
? new AzureLoadBalanceInfoEncoder().Encode(Info.LoadBalanceInfo)
: Info.LoadBalanceInfo;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("Unable to set load balance info.", ex);
}
}
private void SetEventHandlers()
{
try
{
RdpClient.OnConnecting += RDPEvent_OnConnecting;
RdpClient.OnConnected += RDPEvent_OnConnected;
RdpClient.OnLoginComplete += RDPEvent_OnLoginComplete;
RdpClient.OnFatalError += RDPEvent_OnFatalError;
RdpClient.OnDisconnected += RDPEvent_OnDisconnected;
RdpClient.OnLeaveFullScreenMode += RDPEvent_OnLeaveFullscreenMode;
RdpClient.OnIdleTimeoutNotification += RDPEvent_OnIdleTimeoutNotification;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetEventHandlersFailed, ex);
}
}
private void OnConnectingDebugMessage(object sender, EventArgs args)
{
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
$"Connection requested RDP version: '{Info.RdpProtocolVersion}'. Using RDP provider: '{sender.GetType().Name}'");
}
#endregion
#region Private Events & Handlers
private void RDPEvent_OnIdleTimeoutNotification()
{
Close(); //Simply close the RDP Session if the idle timeout has been triggered.
if (_alertOnIdleDisconnect)
{
string message = "The " + Info.Name + " session was disconnected due to inactivity";
const string caption = "Session Disconnected";
MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void RDPEvent_OnFatalError(int errorCode)
{
RaiseErrorOccuredEvent(this, Convert.ToString(errorCode));
}
private void RDPEvent_OnDisconnected(int discReason)
{
const int UI_ERR_NORMAL_DISCONNECT = 0xB08;
if (discReason != UI_ERR_NORMAL_DISCONNECT)
{
var reason = RdpClient.GetErrorDescription((uint)discReason, (uint) RdpClient.ExtendedDisconnectReason);
RaiseConnectionDisconnectedEvent(this, discReason + "\r\n" + reason);
}
if (Settings.Default.ReconnectOnDisconnect)
{
ReconnectGroup = new ReconnectGroup();
ReconnectGroup.CloseClicked += Close;
ReconnectGroup.Left = (int) ((double) Control.Width / 2 - (double) ReconnectGroup.Width / 2);
ReconnectGroup.Top = (int) ((double) Control.Height / 2 - (double) ReconnectGroup.Height / 2);
ReconnectGroup.Parent = Control;
ReconnectGroup.Show();
tmrReconnect.Enabled = true;
}
else
{
Close();
}
}
private void RDPEvent_OnConnecting()
{
RaiseConnectionConnectingEvent(this);
}
private void RDPEvent_OnConnected()
{
RaiseConnectionConnectedEvent(this);
}
private void RDPEvent_OnLoginComplete()
{
LoginComplete = true;
}
private void RDPEvent_OnLeaveFullscreenMode()
{
Fullscreen = false;
LeaveFullscreen?.Invoke(this, new EventArgs());
}
#endregion
public delegate void LeaveFullscreenEventHandler(object sender, EventArgs e);
public event LeaveFullscreenEventHandler LeaveFullscreen;
public enum Defaults
{
Colors = RdpColors.Colors16Bit,
Sounds = RdpSounds.DoNotPlay,
Resolution = RdpResolutions.FitToWindow,
Port = 3389
}
#region Reconnect Stuff
public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
var srvReady = PortScanner.IsPortOpen(Info.Hostname, Convert.ToString(Info.Port));
ReconnectGroup.ServerReady = srvReady;
if (ReconnectGroup.ReconnectWhenReady && srvReady)
{
tmrReconnect.Enabled = false;
ReconnectGroup.DisposeReconnectGroup();
//SetProps()
RdpClient.Connect();
}
}
#endregion
}
}

View File

@@ -0,0 +1,20 @@
using AxMSTSCLib;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocol7 : RdpProtocol6
{
public RdpProtocol7(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new AxMsRdpClient7NotSafeForScripting();
RdpVersionEnum = RdpVersionEnum.Rdc7;
}
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
{
return (MsRdpClient6NotSafeForScripting)((AxMsRdpClient7NotSafeForScripting)Control).GetOcx();
}
}
}

View File

@@ -0,0 +1,125 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using AxMSTSCLib;
using mRemoteNG.App;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
/* RDP v8 requires Windows 7 with:
* https://support.microsoft.com/en-us/kb/2592687
* OR
* https://support.microsoft.com/en-us/kb/2923545
*
* Windows 8+ support RDP v8 out of the box.
*/
public class RdpProtocol8 : RdpProtocol7
{
private MsRdpClient8NotSafeForScripting _rdpClient => (MsRdpClient8NotSafeForScripting)RdpClient;
private Size _controlBeginningSize;
public override bool SmartSize
{
get { return base.SmartSize; }
protected set
{
base.SmartSize = value;
ReconnectForResize();
}
}
public override bool Fullscreen
{
get => base.Fullscreen;
protected set
{
base.Fullscreen = value;
ReconnectForResize();
}
}
public RdpProtocol8(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new AxMsRdpClient8NotSafeForScripting();
RdpVersionEnum = RdpVersionEnum.Rdc8;
}
public override bool Initialize()
{
base.Initialize();
try
{
_rdpClient.AdvancedSettings8.AudioQualityMode = (uint)Info.SoundQuality;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetPropsFailed, ex);
return false;
}
return true;
}
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
{
return (MsRdpClient6NotSafeForScripting)((AxMsRdpClient8NotSafeForScripting)Control).GetOcx();
}
public override void ResizeBegin(object sender, EventArgs e)
{
_controlBeginningSize = Control.Size;
}
public override void Resize(object sender, EventArgs e)
{
if (DoResize() && _controlBeginningSize.IsEmpty)
{
ReconnectForResize();
}
base.Resize(sender, e);
}
public override void ResizeEnd(object sender, EventArgs e)
{
DoResize();
if (!(Control.Size == _controlBeginningSize))
{
ReconnectForResize();
}
_controlBeginningSize = Size.Empty;
}
private void ReconnectForResize()
{
if (!LoginComplete)
return;
if (!Info.AutomaticResize)
return;
if (!(Info.Resolution == RdpResolutions.FitToWindow | Info.Resolution == RdpResolutions.Fullscreen))
return;
if (SmartSize)
return;
var size = Fullscreen
? Screen.FromControl(Control).Bounds.Size
: Control.Size;
_rdpClient.Reconnect((uint)size.Width, (uint)size.Height);
}
private bool DoResize()
{
Control.Location = InterfaceControl.Location;
if (!(Control.Size == InterfaceControl.Size) && !(InterfaceControl.Size == Size.Empty)) // kmscode - this doesn't look right to me. But I'm not aware of any functionality issues with this currently...
{
Control.Size = InterfaceControl.Size;
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,20 @@
using AxMSTSCLib;
using MSTSCLib;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocol9 : RdpProtocol8
{
public RdpProtocol9(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new AxMsRdpClient9NotSafeForScripting();
RdpVersionEnum = RdpVersionEnum.Rdc9;
}
protected override MsRdpClient6NotSafeForScripting CreateRdpClientControl()
{
return (MsRdpClient6NotSafeForScripting)((AxMsRdpClient9NotSafeForScripting)Control).GetOcx();
}
}
}

View File

@@ -0,0 +1,42 @@
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpProtocolFactory
{
public ProtocolBase CreateProtocol(ConnectionInfo connectionInfo)
{
return CreateProtocol(connectionInfo.RdpProtocolVersion, connectionInfo);
}
public ProtocolBase CreateProtocol(RdpVersionEnum version, ConnectionInfo connectionInfo)
{
RdpProtocol6 newProtocol = null;
// ReSharper disable once SwitchStatementMissingSomeCases
switch (version)
{
case RdpVersionEnum.Rdc6:
newProtocol = new RdpProtocol6(connectionInfo);
break;
case RdpVersionEnum.Rdc7:
newProtocol = new RdpProtocol7(connectionInfo);
break;
case RdpVersionEnum.Rdc8:
newProtocol = new RdpProtocol8(connectionInfo);
break;
case RdpVersionEnum.Rdc9:
newProtocol = new RdpProtocol9(connectionInfo);
break;
case RdpVersionEnum.Rdc10:
newProtocol = new RdpProtocol10(connectionInfo);
break;
}
if (newProtocol != null)
{
newProtocol.LoadBalanceInfoUseUtf8 = Settings.Default.RdpLoadBalanceInfoUseUtf8;
}
return newProtocol;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace mRemoteNG.Connection.Protocol.RDP
{
public class RdpSupportTester
{
/// <summary>
/// Returns a list of the RDP versions that can be used on the current
/// host.
/// </summary>
/// <returns></returns>
public List<RdpVersionEnum> GetSupportedRdpVersions()
{
var supportedVersions = new List<RdpVersionEnum>();
var connectionInfo = new ConnectionInfo();
var rdpFactory = new RdpProtocolFactory();
foreach (var version in RdpVersionEnum.Rdc6.GetAll())
{
var protocol = rdpFactory.CreateProtocol(version, connectionInfo);
if (RdpClientIsSupported(protocol))
supportedVersions.Add(version);
}
return supportedVersions;
}
private bool RdpClientIsSupported(ProtocolBase rdpProtocol)
{
try
{
return rdpProtocol.Initialize();
}
catch (Exception)
{
return false;
}
finally
{
rdpProtocol.Close();
}
}
}
}

View File

@@ -2,10 +2,10 @@ namespace mRemoteNG.Connection.Protocol.Rlogin
{
public class ProtocolRlogin : PuttyBase
{
public ProtocolRlogin()
{
this.PuttyProtocol = Putty_Protocol.rlogin;
public ProtocolRlogin(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.rlogin;
}
public enum Defaults

View File

@@ -4,11 +4,11 @@ namespace mRemoteNG.Connection.Protocol.SSH
{
public class ProtocolSSH1 : PuttyBase
{
public ProtocolSSH1()
public ProtocolSSH1(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
this.PuttyProtocol = Putty_Protocol.ssh;
this.PuttySSHVersion = Putty_SSHVersion.ssh1;
PuttyProtocol = Putty_Protocol.ssh;
PuttySSHVersion = Putty_SSHVersion.ssh1;
}
public enum Defaults

View File

@@ -2,11 +2,11 @@ namespace mRemoteNG.Connection.Protocol.SSH
{
public class ProtocolSSH2 : PuttyBase
{
public ProtocolSSH2()
{
this.PuttyProtocol = Putty_Protocol.ssh;
this.PuttySSHVersion = Putty_SSHVersion.ssh2;
public ProtocolSSH2(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.ssh;
PuttySSHVersion = Putty_SSHVersion.ssh2;
}
public enum Defaults

View File

@@ -2,10 +2,10 @@ namespace mRemoteNG.Connection.Protocol.Serial
{
public class ProtocolSerial : PuttyBase
{
public ProtocolSerial()
{
this.PuttyProtocol = Putty_Protocol.serial;
public ProtocolSerial(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.serial;
}
public enum Defaults

View File

@@ -2,10 +2,10 @@ namespace mRemoteNG.Connection.Protocol.Telnet
{
public class ProtocolTelnet : PuttyBase
{
public ProtocolTelnet()
{
this.PuttyProtocol = Putty_Protocol.telnet;
public ProtocolTelnet(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.telnet;
}
public enum Defaults

View File

@@ -10,7 +10,8 @@ namespace mRemoteNG.Connection.Protocol.VNC
{
public class ProtocolVNC : ProtocolBase
{
#region Properties
private VncSharp.RemoteDesktop _VNC;
public bool SmartSize
{
get { return _VNC.Scaled; }
@@ -22,16 +23,11 @@ namespace mRemoteNG.Connection.Protocol.VNC
get { return _VNC.ViewOnly; }
set { _VNC.ViewOnly = value; }
}
#endregion
#region Private Declarations
private VncSharp.RemoteDesktop _VNC;
private ConnectionInfo Info;
#endregion
#region Public Methods
public ProtocolVNC()
public ProtocolVNC(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
Control = new VncSharp.RemoteDesktop();
}
@@ -44,7 +40,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
{
_VNC = (VncSharp.RemoteDesktop)Control;
Info = InterfaceControl.Info;
Info = InterfaceControl.Protocol.Info;
_VNC.VncPort = Info.Port;
@@ -180,14 +176,14 @@ namespace mRemoteNG.Connection.Protocol.VNC
#region Private Events & Handlers
private void VNCEvent_Connected(object sender, EventArgs e)
{
Event_Connected(this);
RaiseConnectionConnectedEvent(this);
_VNC.AutoScroll = Info.VNCSmartSizeMode == SmartSizeMode.SmartSNo;
}
private void VNCEvent_Disconnected(object sender, EventArgs e)
{
FrmMain.ClipboardChanged -= VNCEvent_ClipboardChanged;
Event_Disconnected(sender, e.ToString());
RaiseConnectionDisconnectedEvent(sender, e.ToString());
Close();
}

View File

@@ -14,7 +14,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("Multi-protocol remote connections manager")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("mRemoteNG")]
[assembly: AssemblyCopyright("Copyright © 2017 mRemoteNG Dev Team; 2010-2013 Riley McArdle; 2007-2009 Felix Deimel")]
[assembly: AssemblyCopyright("Copyright © 2018 mRemoteNG Dev Team; 2010-2013 Riley McArdle; 2007-2009 Felix Deimel")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]

View File

@@ -19,7 +19,7 @@ namespace mRemoteNG {
// 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Language {
@@ -61,7 +61,7 @@ namespace mRemoteNG {
}
/// <summary>
/// Looks up a localized string similar to Create a New Configuration File.
/// Looks up a localized string similar to Create a New Connection File.
/// </summary>
internal static string ConfigurationCreateNew {
get {
@@ -78,15 +78,6 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to The Configuration File is Missing..
/// </summary>
internal static string ConfigurationFileNotFound {
get {
return ResourceManager.GetString("ConfigurationFileNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import an Existing File.
/// </summary>
@@ -96,6 +87,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to The connection file could not be found..
/// </summary>
internal static string ConnectionFileNotFound {
get {
return ResourceManager.GetString("ConnectionFileNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Connection successful.
/// </summary>
@@ -4668,6 +4668,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to Sets the version of the RDP protocol to use when opening connections..
/// </summary>
internal static string strPropertyDescriptionRdpProtocolVersion {
get {
return ResourceManager.GetString("strPropertyDescriptionRdpProtocolVersion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Select whether local disk drives should be shown on the remote host..
/// </summary>
@@ -5172,6 +5181,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to RDP Protocol Version.
/// </summary>
internal static string strPropertyNameRdpProtocolVersion {
get {
return ResourceManager.GetString("strPropertyNameRdpProtocolVersion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disk Drives.
/// </summary>

View File

@@ -2590,10 +2590,10 @@ This page will walk you through the process of upgrading your connections file o
<value>Could not find external tool with name "{0}"</value>
</data>
<data name="ConfigurationCreateNew" xml:space="preserve">
<value>Create a New Configuration File</value>
<value>Create a New Connection File</value>
</data>
<data name="ConfigurationFileNotFound" xml:space="preserve">
<value>The Configuration File is Missing.</value>
<data name="ConnectionFileNotFound" xml:space="preserve">
<value>The connection file could not be found.</value>
</data>
<data name="ConfigurationImportFile" xml:space="preserve">
<value>Import an Existing File</value>
@@ -2631,4 +2631,10 @@ This page will walk you through the process of upgrading your connections file o
<data name="LoadBalanceInfoUseUtf8" xml:space="preserve">
<value>Use UTF8 encoding for RDP "Load Balance Info" property</value>
</data>
<data name="strPropertyDescriptionRdpProtocolVersion" xml:space="preserve">
<value>Sets the version of the RDP protocol to use when opening connections.</value>
</data>
<data name="strPropertyNameRdpProtocolVersion" xml:space="preserve">
<value>RDP Protocol Version</value>
</data>
</root>

View File

@@ -21,5 +21,34 @@ namespace mRemoteNG.Tools
return new Maybe<U>();
}
}
/// <summary>
/// Throws an <see cref="ArgumentNullException"/> if the given value is
/// null. Otherwise, return the value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value"></param>
/// <param name="argName">
/// The name of the argument
/// </param>
public static T ThrowIfNull<T>(this T value, string argName)
{
if (value == null)
throw new ArgumentNullException(argName);
return value;
}
/// <summary>
/// Throws an <see cref="ArgumentException"/> if the value
/// is null or an empty string. Otherwise, returns the value.
/// </summary>
/// <param name="value"></param>
/// <param name="argName"></param>
public static string ThrowIfNullOrEmpty(this string value, string argName)
{
if (string.IsNullOrEmpty(value))
throw new ArgumentException("Value cannot be null or empty", argName);
return value;
}
}
}

View File

@@ -20,7 +20,7 @@ namespace mRemoteNG.Tools
public static int HttpPort { get; set; } = (int)ProtocolHTTP.Defaults.Port;
public static int HttpsPort { get; set; } = (int)ProtocolHTTPS.Defaults.Port;
public static int RloginPort { get; set; } = (int)ProtocolRlogin.Defaults.Port;
public static int RdpPort { get; set; } = (int)RdpProtocol.Defaults.Port;
public static int RdpPort { get; set; } = (int)RdpProtocol6.Defaults.Port;
public static int VncPort { get; set; } = (int)ProtocolVNC.Defaults.Port;
public ArrayList OpenPorts { get; set; }
public ArrayList ClosedPorts { get; set; }

View File

@@ -272,6 +272,7 @@ namespace mRemoteNG.UI.Controls
Expand(parent);
SelectObject(newNode, true);
EnsureModelVisible(newNode);
_allowEdit = true;
SelectedItem.BeginEdit();
}

View File

@@ -396,17 +396,28 @@ namespace mRemoteNG.UI.Forms
var controlThatWasClicked = FromChildHandle(NativeMethods.WindowFromPoint(MousePosition));
if (controlThatWasClicked != null)
{
if (controlThatWasClicked.CanSelect || controlThatWasClicked is MenuStrip ||
controlThatWasClicked is ToolStrip || controlThatWasClicked is Crownwood.Magic.Controls.TabControl ||
controlThatWasClicked is Crownwood.Magic.Controls.InertButton)
if (controlThatWasClicked is TreeView ||
controlThatWasClicked is ComboBox ||
controlThatWasClicked is TextBox)
{
controlThatWasClicked.Focus();
}
else if (controlThatWasClicked.CanSelect ||
controlThatWasClicked is MenuStrip ||
controlThatWasClicked is ToolStrip ||
controlThatWasClicked is Crownwood.Magic.Controls.TabControl ||
controlThatWasClicked is Crownwood.Magic.Controls.InertButton)
{
// Simulate a mouse event since one wasn't generated by Windows
MouseClickSimulator.Click(controlThatWasClicked, MousePosition);
SimulateClick(controlThatWasClicked);
controlThatWasClicked.Focus();
}
else
{
// This handles activations from clicks that did not start a size/move operation
ActivateConnection();
}
}
// This handles activations from clicks that did not start a size/move operation
ActivateConnection();
}
break;
case NativeMethods.WM_WINDOWPOSCHANGED:
@@ -441,7 +452,17 @@ namespace mRemoteNG.UI.Forms
base.WndProc(ref m);
}
private void SimulateClick(Control control)
{
var clientMousePosition = control.PointToClient(MousePosition);
var temp_wLow = clientMousePosition.X;
var temp_wHigh = clientMousePosition.Y;
NativeMethods.SendMessage(control.Handle, NativeMethods.WM_LBUTTONDOWN, (IntPtr)NativeMethods.MK_LBUTTON, (IntPtr)NativeMethods.MAKELPARAM(ref temp_wLow, ref temp_wHigh));
clientMousePosition.X = temp_wLow;
clientMousePosition.Y = temp_wHigh;
}
private void ActivateConnection()
{
var w = pnlDock.ActiveDocument as ConnectionWindow;

View File

@@ -437,7 +437,7 @@ namespace mRemoteNG.UI.Menu
foreach (var i in icList)
{
i.Protocol.Close();
ConnectionInitiator.OpenConnection(i.Info, ConnectionInfo.Force.DoNotJump);
ConnectionInitiator.OpenConnection(i.Protocol.Info, ConnectionInfo.Force.DoNotJump);
}
// throw it on the garbage collector

View File

@@ -9,9 +9,7 @@ namespace mRemoteNG.UI.Window
{
public partial class ActiveDirectoryImportWindow
{
private string CurrentDomain;
#region Constructors
private string _currentDomain;
public ActiveDirectoryImportWindow()
{
@@ -19,12 +17,10 @@ namespace mRemoteNG.UI.Window
FontOverrider.FontOverride(this);
WindowType = WindowType.ActiveDirectoryImport;
DockPnl = new DockContent();
CurrentDomain = Environment.UserDomainName;
_currentDomain = Environment.UserDomainName;
ApplyTheme();
}
#endregion
private new void ApplyTheme()
{
base.ApplyTheme();
@@ -38,8 +34,8 @@ namespace mRemoteNG.UI.Window
private void ADImport_Load(object sender, EventArgs e)
{
ApplyLanguage();
txtDomain.Text = CurrentDomain;
ActiveDirectoryTree.Domain = CurrentDomain;
txtDomain.Text = _currentDomain;
ActiveDirectoryTree.Domain = _currentDomain;
EnableDisableImportButton();
// Domain doesn't refresh on load, so it defaults to DOMAIN without this...
@@ -94,8 +90,8 @@ namespace mRemoteNG.UI.Window
private void ChangeDomain()
{
CurrentDomain = txtDomain.Text;
ActiveDirectoryTree.Domain = CurrentDomain;
_currentDomain = txtDomain.Text;
ActiveDirectoryTree.Domain = _currentDomain;
ActiveDirectoryTree.Refresh();
}

View File

@@ -2,6 +2,8 @@ using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using AxMSTSCLib;
using AxWFICALib;
@@ -458,42 +460,26 @@ namespace mRemoteNG.UI.Window
{
pnlCheck1.Visible = true;
try
var tester = new RdpSupportTester();
var supportedRdpVersions = tester.GetSupportedRdpVersions();
if (supportedRdpVersions.Any())
{
using (var rdpClient = new AxMsRdpClient8NotSafeForScripting())
{
rdpClient.CreateControl();
while (!rdpClient.Created)
{
Thread.Sleep(10);
System.Windows.Forms.Application.DoEvents();
}
if (!(new Version(rdpClient.Version) >= RdpProtocol.Versions.RDC80))
{
throw new Exception(
$"Found RDC Client version {rdpClient.Version} but version {RdpProtocol.Versions.RDC80} or higher is required.");
}
pbCheck1.Image = Resources.Good_Symbol;
lblCheck1.ForeColor = Color.DarkOliveGreen;
lblCheck1.Text = "RDP (Remote Desktop) " + Language.strCcCheckSucceeded;
txtCheck1.Text = string.Format(Language.strCcRDPOK, rdpClient.Version);
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "RDP installed", true);
}
pbCheck1.Image = Resources.Good_Symbol;
lblCheck1.ForeColor = Color.DarkOliveGreen;
lblCheck1.Text = "RDP (Remote Desktop) " + Language.strCcCheckSucceeded;
txtCheck1.Text = string.Format(Language.strCcRDPOK, supportedRdpVersions.Aggregate(new StringBuilder(), (builder, enum1) => builder.Append(enum1+",")));
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "RDP installed", true);
return;
}
catch (Exception ex)
{
pbCheck1.Image = Resources.Bad_Symbol;
lblCheck1.ForeColor = Color.Firebrick;
lblCheck1.Text = "RDP (Remote Desktop) " + Language.strCcCheckFailed;
txtCheck1.Text = string.Format(Language.strCcRDPFailed, GeneralAppInfo.UrlForum);
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
"RDP " + Language.strCcNotInstalledProperly, true);
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, ex.Message, true);
}
pbCheck1.Image = Resources.Bad_Symbol;
lblCheck1.ForeColor = Color.Firebrick;
lblCheck1.Text = "RDP (Remote Desktop) " + Language.strCcCheckFailed;
txtCheck1.Text = string.Format(Language.strCcRDPFailed, GeneralAppInfo.UrlForum);
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
"RDP " + Language.strCcNotInstalledProperly, true);
}
private void CheckVnc()

View File

@@ -878,7 +878,7 @@ namespace mRemoteNG.UI.Window
{
strHide.Add("RDPAlertIdleTimeout");
}
if (conI.RDGatewayUsageMethod == RdpProtocol.RDGatewayUsageMethod.Never)
if (conI.RDGatewayUsageMethod == RDGatewayUsageMethod.Never)
{
strHide.Add("RDGatewayDomain");
strHide.Add("RDGatewayHostname");
@@ -886,17 +886,17 @@ namespace mRemoteNG.UI.Window
strHide.Add("RDGatewayUseConnectionCredentials");
strHide.Add("RDGatewayUsername");
}
else if (conI.RDGatewayUseConnectionCredentials == RdpProtocol.RDGatewayUseConnectionCredentials.Yes)
else if (conI.RDGatewayUseConnectionCredentials == RDGatewayUseConnectionCredentials.Yes)
{
strHide.Add("RDGatewayDomain");
strHide.Add("RDGatewayPassword");
strHide.Add("RDGatewayUsername");
}
if (!(conI.Resolution == RdpProtocol.RDPResolutions.FitToWindow || conI.Resolution == RdpProtocol.RDPResolutions.Fullscreen))
if (!(conI.Resolution == RdpResolutions.FitToWindow || conI.Resolution == RdpResolutions.Fullscreen))
{
strHide.Add("AutomaticResize");
}
if (conI.RedirectSound != RdpProtocol.RDPSounds.BringToThisComputer)
if (conI.RedirectSound != RdpSounds.BringToThisComputer)
{
strHide.Add("SoundQuality");
}

View File

@@ -160,7 +160,7 @@ namespace mRemoteNG.UI.Window
else
{
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
FrmMain.Default.SelectedConnection = interfaceControl?.Info;
FrmMain.Default.SelectedConnection = interfaceControl?.Protocol.Info;
}
}
#endregion
@@ -178,7 +178,7 @@ namespace mRemoteNG.UI.Window
if(ThemeManager.getInstance().ThemingActive)
{
base.ApplyTheme();
this.vsToolStripExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
vsToolStripExtender = new VisualStudioToolStripExtender(components);
vsToolStripExtender.DefaultRenderer = _toolStripProfessionalRenderer;
vsToolStripExtender.SetStyle(cmenTab, ThemeManager.getInstance().ActiveTheme.Version, ThemeManager.getInstance().ActiveTheme.Theme);
TabController.BackColor = ThemeManager.getInstance().ActiveTheme.ExtendedPalette.getColor("Tab_Item_Background");
@@ -377,9 +377,9 @@ namespace mRemoteNG.UI.Window
var interfaceControl = (InterfaceControl)TabController.SelectedTab?.Tag;
if (interfaceControl == null) return;
if (interfaceControl.Info.Protocol == ProtocolType.RDP)
if (interfaceControl.Protocol.Info.Protocol == ProtocolType.RDP)
{
var rdp = (RdpProtocol)interfaceControl.Protocol;
var rdp = (RdpProtocol6)interfaceControl.Protocol;
cmenTabFullscreen.Visible = true;
cmenTabFullscreen.Checked = rdp.Fullscreen;
cmenTabSmartSize.Visible = true;
@@ -391,7 +391,7 @@ namespace mRemoteNG.UI.Window
cmenTabSmartSize.Visible = false;
}
if (interfaceControl.Info.Protocol == ProtocolType.VNC)
if (interfaceControl.Protocol.Info.Protocol == ProtocolType.VNC)
{
var vnc = (ProtocolVNC)interfaceControl.Protocol;
cmenTabSendSpecialKeys.Visible = true;
@@ -412,7 +412,7 @@ namespace mRemoteNG.UI.Window
cmenTabTransferFile.Visible = false;
}
if (interfaceControl.Info.Protocol == ProtocolType.SSH1 | interfaceControl.Info.Protocol == ProtocolType.SSH2)
if (interfaceControl.Protocol.Info.Protocol == ProtocolType.SSH1 | interfaceControl.Protocol.Info.Protocol == ProtocolType.SSH2)
{
cmenTabTransferFile.Visible = true;
}
@@ -443,7 +443,7 @@ namespace mRemoteNG.UI.Window
if (!(TabController.SelectedTab?.Tag is InterfaceControl)) return;
var interfaceControl = (InterfaceControl)TabController.SelectedTab?.Tag;
var protocol = interfaceControl.Protocol as RdpProtocol;
var protocol = interfaceControl.Protocol as RdpProtocol6;
if (protocol != null)
{
var rdp = protocol;
@@ -468,9 +468,9 @@ namespace mRemoteNG.UI.Window
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
if (interfaceControl == null) return;
if (interfaceControl.Info.Protocol == ProtocolType.SSH1 | interfaceControl.Info.Protocol == ProtocolType.SSH2)
if (interfaceControl.Protocol.Info.Protocol == ProtocolType.SSH1 | interfaceControl.Protocol.Info.Protocol == ProtocolType.SSH2)
SshTransferFile();
else if (interfaceControl.Info.Protocol == ProtocolType.VNC)
else if (interfaceControl.Protocol.Info.Protocol == ProtocolType.VNC)
VncTransferFile();
}
catch (Exception ex)
@@ -487,7 +487,7 @@ namespace mRemoteNG.UI.Window
if (interfaceControl == null) return;
Windows.Show(WindowType.SSHTransfer);
var connectionInfo = interfaceControl.Info;
var connectionInfo = interfaceControl.Protocol.Info;
Windows.SshtransferForm.Hostname = connectionInfo.Hostname;
Windows.SshtransferForm.Username = connectionInfo.Username;
@@ -577,7 +577,7 @@ namespace mRemoteNG.UI.Window
try
{
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
var rdp = interfaceControl?.Protocol as RdpProtocol;
var rdp = interfaceControl?.Protocol as RdpProtocol6;
rdp?.ToggleFullscreen();
}
catch (Exception ex)
@@ -640,7 +640,7 @@ namespace mRemoteNG.UI.Window
try
{
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
externalTool.Start(interfaceControl?.Info);
externalTool.Start(interfaceControl?.Protocol.Info);
}
catch (Exception ex)
{
@@ -667,7 +667,7 @@ namespace mRemoteNG.UI.Window
{
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
if (interfaceControl == null) return;
_connectionInitiator.OpenConnection(interfaceControl.Info, ConnectionInfo.Force.DoNotJump);
_connectionInitiator.OpenConnection(interfaceControl.Protocol.Info, ConnectionInfo.Force.DoNotJump);
_ignoreChangeSelectedTabClick = false;
}
catch (Exception ex)
@@ -683,7 +683,7 @@ namespace mRemoteNG.UI.Window
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
if (interfaceControl == null) return;
interfaceControl.Protocol.Close();
_connectionInitiator.OpenConnection(interfaceControl.Info, ConnectionInfo.Force.DoNotJump);
_connectionInitiator.OpenConnection(interfaceControl.Protocol.Info, ConnectionInfo.Force.DoNotJump);
}
catch (Exception ex)
{
@@ -714,7 +714,7 @@ namespace mRemoteNG.UI.Window
#endregion
#region Protocols
public void Prot_Event_Closed(object sender)
public void Prot_Event_Closed(object sender, EventArgs args)
{
var protocolBase = sender as ProtocolBase;
var tabPage = protocolBase?.InterfaceControl.Parent as TabPage;
@@ -844,7 +844,7 @@ namespace mRemoteNG.UI.Window
try
{
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
if (interfaceControl?.Info.Protocol == ProtocolType.VNC)
if (interfaceControl?.Protocol.Info.Protocol == ProtocolType.VNC)
((ProtocolVNC)interfaceControl.Protocol).RefreshScreen();
}
catch (Exception ex)
@@ -868,7 +868,7 @@ namespace mRemoteNG.UI.Window
if (tabClientRectangle.Contains(MousePosition))
{
var interfaceControl = selectedTab.Tag as InterfaceControl;
if (interfaceControl?.Info?.Protocol == ProtocolType.RDP)
if (interfaceControl?.Protocol.Info?.Protocol == ProtocolType.RDP)
{
interfaceControl.Protocol.Focus();
return; // Do not pass to base class

View File

@@ -157,6 +157,7 @@
<Compile Include="Config\DataProviders\FileBackupPruner.cs" />
<Compile Include="Config\DataProviders\InMemoryStringDataProvider.cs" />
<Compile Include="Config\ILoader.cs" />
<Compile Include="Config\Import\MRemoteNGCsvImporter.cs" />
<Compile Include="Config\ISaver.cs" />
<Compile Include="Config\Serializers\CredentialProviderSerializer\CredentialRepositoryListDeserializer.cs" />
<Compile Include="Config\CredentialRepositoryListLoader.cs" />
@@ -166,6 +167,7 @@
<Compile Include="Config\Serializers\ISecureSerializer.cs" />
<Compile Include="Config\Serializers\MiscSerializers\ActiveDirectoryDeserializer.cs" />
<Compile Include="Config\Serializers\CredentialProviderSerializer\CredentialRepositoryListSerializer.cs" />
<Compile Include="Config\Serializers\MiscSerializers\CsvConnectionsDeserializerMremotengFormat.cs" />
<Compile Include="Config\Serializers\MiscSerializers\CsvConnectionsSerializerMremotengFormat.cs" />
<Compile Include="Config\Serializers\DataTableDeserializer.cs" />
<Compile Include="Config\Serializers\DataTableSerializer.cs" />
@@ -209,7 +211,7 @@
<Compile Include="Config\Settings\SettingsSaver.cs" />
<Compile Include="Config\ConfirmCloseEnum.cs" />
<Compile Include="Config\Import\ActiveDirectoryImporter.cs" />
<Compile Include="Config\Import\mRemoteNGImporter.cs" />
<Compile Include="Config\Import\MRemoteNGXmlImporter.cs" />
<Compile Include="Config\Import\PortScanImporter.cs" />
<Compile Include="Config\Import\PuttyConnectionManagerImporter.cs" />
<Compile Include="Config\Import\RemoteDesktopConnectionImporter.cs" />
@@ -234,7 +236,23 @@
<Compile Include="Connection\IHasParent.cs" />
<Compile Include="Connection\Protocol\Http\Connection.Protocol.HTTPS.CertEvent.cs" />
<Compile Include="Connection\Protocol\ProtocolFactory.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpVersion.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpAuthenticationLevel.cs" />
<Compile Include="Connection\Protocol\RDP\AzureLoadBalanceInfoEncoder.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RDGatewayUsageMethod.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RDGatewayUseConnectionCredentials.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpColors.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpPerformanceFlags.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpResolutions.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpSoundQuality.cs" />
<Compile Include="Connection\Protocol\RDP\Enums\RdpSounds.cs" />
<Compile Include="Connection\Protocol\RDP\RdpErrorTranslator.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol10.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol7.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol8.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol9.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocolFactory.cs" />
<Compile Include="Connection\Protocol\RDP\RdpSupportTester.cs" />
<Compile Include="Connection\Protocol\VNC\VNCEnum.cs" />
<Compile Include="Connection\WebHelper.cs" />
<Compile Include="Credential\PlaceholderCredentialRecord.cs" />
@@ -567,7 +585,7 @@
<Compile Include="Connection\Protocol\ProtocolType.cs" />
<Compile Include="Connection\Protocol\PuttyBase.cs" />
<Compile Include="Connection\Protocol\RAW\RawProtocol.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol.cs" />
<Compile Include="Connection\Protocol\RDP\RdpProtocol6.cs" />
<Compile Include="Connection\Protocol\Rlogin\Connection.Protocol.Rlogin.cs" />
<Compile Include="Connection\Protocol\Serial\Connection.Protocol.Serial.cs" />
<Compile Include="Connection\Protocol\SSH\Connection.Protocol.SSH1.cs" />

View File

@@ -4,6 +4,7 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=config_005Cserializers_005Cexportserializers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=config_005Cserializers_005Cexternalserializers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=config_005Cserializers_005Cmiscserializers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=connection_005Cprotocol_005Crdp_005Cnewfolder1/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=messages_005Cmessagefilteringoptions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=tree_005Cclickhandlers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ui_005Ccontrols_005Cconnectiontree/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>