Compare commits

..

70 Commits

Author SHA1 Message Date
David Sparer
e872581d3c updated changelog 2018-06-03 09:50:42 -05:00
David Sparer
defe9e094c made opening an empty panel on startup configurable in options 2018-05-31 06:26:43 -05:00
David Sparer
5662735cb8 bumped assembly version for next pre-release 2018-05-25 18:01:32 -05:00
David Sparer
8646dce21b update jenkins build to use newest msbuild (enables c# 7 lang features) 2018-05-20 11:07:43 -05:00
David Sparer
99a3eabbaf updated changelog 2018-05-19 17:00:57 -05:00
David Sparer
c57bd386f2 dont try to connect to folders in quick connect menu. resolves #924 2018-05-19 16:57:34 -05:00
David Sparer
f2a52b03df menu bar can be moved when "lock toolbar position" is turned off. closes #902 2018-05-19 12:57:29 -05:00
David Sparer
860e1ccfaa fix a mismerged language item 2018-05-18 21:33:16 -05:00
David Sparer
49967b38d4 update changelog 2018-05-18 21:32:51 -05:00
David Sparer
36038fff6d fix minor code typo 2018-05-18 20:52:17 -05:00
David Sparer
c5958954b0 apply language later in app startup 2018-05-18 20:45:27 -05:00
David Sparer
d0d63016ca Merge branch 'pr_948_target' into release/v1.76
# Conflicts:
#	mRemoteV1/Resources/Language/Language.resx
#	mRemoteV1/UI/Forms/frmMain.Designer.cs
#	mRemoteV1/UI/Menu/ViewMenu.cs
2018-05-18 20:04:23 -05:00
David Sparer
35f2484adf Merge pull request #948 from farosch/translation
some changes regarding tranlsation
2018-05-18 18:41:06 -05:00
David Sparer
c2cf496ded updated changelog and credits 2018-04-29 12:00:08 -05:00
David Sparer
8a172f02a9 updated changelog and credits for #942 2018-04-19 08:08:44 -05:00
David Sparer
f27935ea61 Merge pull request #942 from sli-pro/develop
Made several strings translatable and added Russian translations
2018-04-19 07:58:16 -05:00
Faryan Rezagholi
043df0aec3 fixed wording 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
63a2e18760 added missing items 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
c3ced7ed03 fix: translations of main file menu items were not loaded 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
f597e14b3d fix group box was not translatable 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
aff4ba9115 fix: set labels dock mode to fill (wasnt displaying longer translated texts) 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
554e0805e3 fix: title of options page was not translatable 2018-04-14 11:56:01 +02:00
Faryan Rezagholi
f4efa74a23 Added missing translation options in viewMenu.cs 2018-04-14 11:56:01 +02:00
Vladimir Semenov
ddc19587fa Edited and added a translation of the Russian language in the forms
- File/import
- File/Import from AD
- File/Export to File
- View/Lock Toolbar position
- View/Mylti SSH toolbar
- Tools/Options/Additionally
Related to question #940.
2018-04-10 13:41:34 +03:00
Vladimir Semenov
5f1232727e Edit and add a translation on the external tools form.
Added and corrected Russian and English translations in the external tools tab.
Adjusted the placement of components on the external tools form so that the text does not overlap during translation.
Related to question #940.
2018-04-10 09:58:59 +03:00
David Sparer
9c373e8f0a Merge pull request #938 from sli-pro/develop
Small visual correction of the forms
2018-04-07 11:25:55 -05:00
David Sparer
83942d788f Merge branch '916_default_properties_not_saving' into develop 2018-04-06 15:05:35 -05:00
David Sparer
73d6fec6f3 updated changelog 2018-04-06 15:05:00 -05:00
David Sparer
a37b5deaa1 finished updating some tests for default inheritance 2018-04-06 15:02:14 -05:00
Vladimir Semenov
3b9de847e7 Small visual correction of the forms
- for the main form set the minimum resolution 1140; 603.
- for the form of port scans, done visual editing of components.
2018-04-06 20:59:15 +03:00
David Sparer
924f1f1e48 improved tests for default connection info 2018-04-05 16:37:22 -05:00
David Sparer
7bdebbe25b Merge pull request #936 from sli-pro/develop
Update Language ru
2018-04-05 15:16:31 -05:00
David Sparer
8f46c25dc9 Merge pull request #935 from marcomsousa/develop
Update Language es
2018-04-05 15:15:04 -05:00
Vladimir Semenov
8bb4a03639 Update Language ru
Fix typos in Russian language
2018-04-05 18:51:47 +03:00
Marco Sousa
7b5bc5e057 Update Language es 2018-04-05 12:39:02 +02:00
David Sparer
35582a5e6a fixed bug with saving and loading default connection info data
updated tests to better cover this feature. related to #916
2018-03-22 16:54:50 -05:00
David Sparer
20340fd31f Merge pull request #913 from mRemoteNG/github-templates
Update .github templates
2018-03-22 07:44:10 -05:00
David Sparer
d6d7664b48 update readme shield 2018-03-14 19:30:25 -05:00
David Sparer
ce97e63876 bump version 2018-03-14 19:17:29 -05:00
David Sparer
378b98ff89 set release date 2018-03-14 19:09:02 -05:00
David Sparer
ce31199e57 updated changelog 2018-03-10 17:55:15 -06:00
David Sparer
227f3b2924 fix csv serialization bug where some empty fields would not be included
related to #911
2018-03-10 17:47:33 -06:00
David Sparer
5076f1354c fix bug where inheritance is incorrectly allowed on nodes under the root node after deserializing 2018-03-10 16:37:54 -06:00
Bennett Blodinger
e5a34388ae Update .github templates
Bumping up the quality of the templates with help from https://www.talater.com/open-source-templates
2018-03-09 09:46:03 -05:00
David Sparer
6a5f65c018 add a bit more documentation to the ps script that creates bulk connections 2018-03-09 08:08:29 -06:00
David Sparer
6d5f41b3d8 forgot to bump the stable branch when 1.75.7012 was released 2018-03-03 09:39:37 -06:00
David Sparer
64f10ead63 bump development channel download shield 2018-03-03 09:31:27 -06:00
David Sparer
575dae446f bump version and update changelog 2018-03-03 09:16:55 -06:00
David Sparer
9b438576f2 deserializing enums now ignores case. resolves #899 2018-02-27 09:48:09 -06:00
David Sparer
cbd32f1a07 added powershell script for creating bulk connections 2018-02-27 08:37:25 -06:00
David Sparer
516182ec40 the xml v2.6 schema must have the export field event if we dont use it. need to bump to v2.7 to get rid of it 2018-02-26 08:11:59 -06:00
David Sparer
4ad3a68d80 readded Export field to xml schema 2018-02-26 07:13:36 -06:00
David Sparer
2f9ba32c07 bump readme for development channel badge 2018-02-25 13:41:32 -06:00
David Sparer
dfc45a2904 update changelog 2018-02-25 12:59:58 -06:00
David Sparer
563fdffb67 fixed build scripts that publish to github
github no longer accepts tls1.0 connections, use tls1.2
2018-02-25 12:58:12 -06:00
David Sparer
f2e9c5e2c0 fixed issue with expanded property not being deserialized 2018-02-25 12:57:40 -06:00
David Sparer
86a591364c modified the xml serializer slightly to make it conform to the XSD file
This required all bools to be serialized to lower case which broke a few assumptions we made in the deserializer
2018-02-25 11:26:29 -06:00
David Sparer
2a82485f81 fixed build issue where installer wasnt being renamed with version number 2018-02-25 09:04:59 -06:00
David Sparer
e13549d361 fixed build issue where binary signatures were not being validated during release builds 2018-02-25 09:00:51 -06:00
David Sparer
a85c1bd7d3 bumped assembly and set release date 2018-02-24 15:19:09 -06:00
David Sparer
946679f490 dont attempt to close a tab if it is disposed 2018-02-24 15:09:09 -06:00
David Sparer
b6f27eac18 added another test and did some cleanup 2018-02-24 14:34:13 -06:00
David Sparer
2cc82145a3 csv serialization now fully preserves tree structure 2018-02-24 12:58:16 -06:00
David Sparer
2dae0f2d8e fix bug where sometimes containers would have their container flag turned off 2018-02-24 12:57:38 -06:00
David Sparer
412f6edc36 change guard checks to use extension method 2018-02-16 20:17:31 -06:00
David Sparer
764791b8e5 changed the Maybe type name to Optional, which is slightly more common 2018-02-16 20:17:30 -06:00
David Sparer
bd20d6ae7d moved classes to new namespace 2018-02-16 20:17:30 -06:00
David Sparer
8db0bf7bea make constant id readonly 2018-02-13 16:15:49 -06:00
David Sparer
cff6aa72fc update changelog 2018-02-13 14:38:58 -06:00
David Sparer
63ddf06057 Made port scan timeout configurable
resolves #648
2018-02-13 14:29:26 -06:00
141 changed files with 3791 additions and 2533 deletions

View File

@@ -1,16 +1,30 @@
<!--
Only file GitHub issues for bugs and feature requests. All other topics will be closed.
<!--- Provide a general summary of the issue in the Title above -->
Before opening an issue, please search for a duplicate or closed issue.
Please provide as much detail as possible for us to fix your issue.
-->
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
<!-- Bug -->
|Detail|Value|
|--:|---|
|Operating system | Windows 10 x64 |
|mRemoteNG version| 1.75.7008 |
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
<!-- Feature Request -->
<!-- If you file a feature request, please delete the bug section -->
## Steps to Reproduce (for bugs)
<!--- Provide an unambiguous set of steps to reproduce -->
<!--- this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used:
* Operating System and version (e.g. Windows 10 1709 x64):

View File

@@ -1,4 +1,29 @@
<!--
Please provide as much detail as possible with what your pull request does.
Include a reference to a filed issue if it exists.
-->
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
## Screenshots (if appropriate):
## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.

View File

@@ -1,12 +1,44 @@
1.76.0 Alpha 3 (2018-xx-xx):
1.76.4 Alpha 6 (2018-06-03):
Features/Enhancements:
----------------------
#948: Fixed issue where many menu item translations were not being used
#942: Improved Russian translation of several items
#924: Notification for "No Host Specified" when clicking folders in quick-connect menu
#902: Menu bar can once again be moved. View -> "Lock toolbar positions" now also locks the menu position
Added option for creating an empty panel on startup
Fixes:
------
#938: Minor layout improvements on the Port Scan screen
#916: Default properties were not being saved
1.76.3 Alpha 5 (2018-03-14):
Fixes:
------
#911: Csv exports sometimes do not include all fields
#807: Inheritance is sometimes turned on for nodes under root Connections node
1.76.2 Alpha 4 (2018-03-03):
Fixes:
------
#899: DoNotPlay is Case Sensitive in XML Serialization
1.76.1 Alpha 3 (2018-02-24):
Features/Enhancements:
----------------------
#625: Added ability to import mRemoteNG formatted CSV files
#648: The port scan ping timeout is now configurable
Fixes:
------
Fixed a few Xml serialization bugs that would occur if boolean values weren't capitalized
1.76.0 Alpha 2 (2018-02-01):

View File

@@ -23,6 +23,7 @@ github.com/DamianBis
github.com/pfjason
github.com/sirLoaf
github.com/Fyers
Vladimir Semenov (github.com/sli-pro)
Past Contributors
@@ -59,6 +60,8 @@ Lukas Plachy (github.com/rheingold)
Gyuha Shin
Stefan (github.com/polluks)
github.com/emazv72
Vladimir Semenov (github.com/sli-pro)
Marco Sousa (github.com/marcomsousa)
Included Source Code

8
Jenkinsfile vendored
View File

@@ -1,8 +1,8 @@
#!groovy
node('windows') {
def jobDir = pwd()
def solutionFilePath = "\"${jobDir}\\mRemoteV1.sln\""
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
def msBuild = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
def nunitConsolePath = "${jobDir}\\packages\\NUnit.ConsoleRunner.3.7.0\\tools\\nunit3-console.exe"
def openCoverPath = "${jobDir}\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe"
def reportGeneratorPath = "${jobDir}\\packages\\ReportGenerator.3.0.2\\tools\\ReportGenerator.exe"
@@ -24,11 +24,11 @@ node('windows') {
}
stage ('Build mRemoteNG (Normal)') {
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
bat "\"${msBuild}\" /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
}
stage ('Build mRemoteNG (Portable)') {
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
bat "\"${msBuild}\" /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
}
stage ('Run Unit Tests (Normal, w/coverage)') {

View File

@@ -10,9 +10,9 @@
| Update Channel | Build Status | Downloads |
| ---------------|--------------|-----------|
| 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) | [![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) |
| 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.7012/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
| Beta | | [![Github Releases (by Release)](https://img.shields.io/github/downloads/mRemoteNG/mRemoteNG/v1.75.7012/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
| 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.76Alpha5/total.svg)](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76Alpha5) |
mRemoteNG is the next generation of mRemote, a full-featured, multi-tab remote connections manager.

View File

@@ -0,0 +1,114 @@
#####################################
# Author: David Sparer
# Summary:
# This is intended to be a template for creating connections in bulk. This uses the serializers directly from the mRemoteNG binaries.
# You will still need to create the connection info objects, but the library will handle serialization. It is expected that you
# are familiar with PowerShell. If this is not the case, reach out to the mRemoteNG community for help.
# Usage:
# Replace or modify the examples that are shown toward the end of the script to create your own connection info objects.
#####################################
$EncryptionKey = (Get-Credential -Message "Enter the encryption key you would like to use. This must match the encryption key used by the rest of the confCons file." -UserName "DontNeedUsername").Password
$PathToMrngFolder = ""
if ($PathToMrngFolder -eq "") {
Write-Error -Message 'You must set the $PathToMrngFolder variable in this script to the folder which contains mRemoteNG.exe'
}
$assembly = [System.Reflection.Assembly]::LoadFile((Join-Path -Path $PathToMrngFolder -ChildPath "mRemoteNG.exe"))
$assembly = [System.Reflection.Assembly]::LoadFile((Join-Path -Path $PathToMrngFolder -ChildPath "BouncyCastle.Crypto.dll"))
function New-mRemoteNGXmlSerializer {
[CmdletBinding()]
param (
[SecureString]
$EncryptionKey
)
PROCESS {
$cryptoProvider = New-Object -TypeName mRemoteNG.Security.SymmetricEncryption.AeadCryptographyProvider
$saveFilter = New-Object -TypeName mRemoteNG.Security.SaveFilter -ArgumentList @($false)
$xmlSerializer = New-Object -TypeName mRemoteNG.Config.Serializers.XmlConnectionNodeSerializer -ArgumentList @($cryptoProvider, $encryptionKey, $saveFilter)
Write-Output $xmlSerializer
}
}
function New-mRemoteNGConnectionInfo {
[CmdletBinding()]
param ()
PROCESS {
$connectionInfo = New-Object -TypeName mRemoteNG.Connection.ConnectionInfo
Write-Output $connectionInfo
}
}
function New-mRemoteNGContainerInfo {
[CmdletBinding()]
param ()
PROCESS {
$connectionInfo = New-Object -TypeName mRemoteNG.Container.ContainerInfo
Write-Output $connectionInfo
}
}
# Setup the services needed to do serialization
$xmlSerializer = New-mRemoteNGXmlSerializer -EncryptionKey $EncryptionKey
#----------------------------------------------------------------
# Example 1: serialize many connections, no containers
# Here you can define the number of connection info objects to create
# You can also provide a list of desired hostnames and iterate over those
$xml = ""
foreach($i in 1..5)
{
$connectionInfo = New-mRemoteNGConnectionInfo
# Set connection info properties
$connectionInfo.Name = "server-$i"
$connectionInfo.Hostname = "some-win-server-$i"
$connectionInfo.Protocol = [mRemoteNG.Connection.Protocol.ProtocolType]::RDP
$connectionInfo.Inheritance.Username = $true
$connectionInfo.Inheritance.Domain = $true
$connectionInfo.Inheritance.Password = $true
$serializedConnection = $xmlSerializer.SerializeConnectionInfo($connectionInfo).ToString()
$xml += $serializedConnection + [System.Environment]::NewLine
}
Write-Output $xml
#----------------------------------------------------------------
# Example 2: serialize a container which has connections
# You can also create containers and add connections to them, which will be nested correctly when serialized
$xml = ""
$container = New-mRemoteNGContainerInfo
$container.Name = "ProductionServers"
$serializedContainer = $xmlSerializer.SerializeConnectionInfo($container)
foreach($i in 1..3)
{
$connectionInfo = New-mRemoteNGConnectionInfo
# Set connection info properties
$connectionInfo.Name = "server-$i"
$connectionInfo.Hostname = "some-linux-server-$i"
$connectionInfo.Protocol = [mRemoteNG.Connection.Protocol.ProtocolType]::SSH2
$connectionInfo.Inheritance.Username = $true
$connectionInfo.Inheritance.Domain = $true
$connectionInfo.Inheritance.Password = $true
# serialize the connection
$serializedConnection = $xmlSerializer.SerializeConnectionInfo($connectionInfo)
# add the connection to the container
$serializedContainer.Add($serializedConnection)
}
# Call ToString() on the top-level container to get the XML of it and all its children
Write-Output $serializedContainer.ToString()

View File

@@ -1,5 +1,6 @@
$githubUrl = 'https://api.github.com'
# GitHub doesn't support the default powershell protocol (TLS 1.0)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
function Publish-GitHubRelease {
param (

View File

@@ -45,5 +45,5 @@ Format-Table -AutoSize -Wrap -InputObject @{
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath
& "$PSScriptRoot\zip_portable_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName

View File

@@ -9,7 +9,7 @@ Write-Host $SolutionDir
Write-Host $renameTarget
$targetVersionedFile = "$SolutionDir\mRemoteV1\bin\Release\mRemoteNG.exe"
$version = &"$SolutionDir\Tools\sigcheck.exe" /accepteula -q -n $targetVersionedFile
$version = &"$SolutionDir\Tools\exes\sigcheck.exe" /accepteula -q -n $targetVersionedFile
$renameTargetFileObject = Get-Item -Path $renameTarget -ErrorAction SilentlyContinue

View File

@@ -8,6 +8,7 @@ param (
$ConfigurationName,
[string]
[Parameter(Mandatory=$true)]
# The code signing certificate to use when signing the files.
$CertificatePath
)

View File

@@ -4,6 +4,7 @@ using System.Security;
using System.Xml.Linq;
using mRemoteNG.Config;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;

View File

@@ -1,8 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.MiscSerializers;
using mRemoteNG.Config.Serializers.Csv;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
@@ -11,28 +10,29 @@ using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Credential;
using mRemoteNG.Security;
using mRemoteNGTests.TestHelpers;
using NSubstitute;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
{
public class CsvConnectionsDeserializerMremotengFormatTests
public class CsvConnectionsDeserializerMremotengFormatTests
{
private CsvConnectionsDeserializerMremotengFormat _deserializer;
private ICredentialRepositoryList _credentialRepositoryList;
private CsvConnectionsSerializerMremotengFormat _serializer;
[SetUp]
public void Setup()
{
_deserializer = new CsvConnectionsDeserializerMremotengFormat();
_credentialRepositoryList = Substitute.For<ICredentialRepositoryList>();
var credentialRepositoryList = Substitute.For<ICredentialRepositoryList>();
_serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), credentialRepositoryList);
}
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.ConnectionPropertyTestCases))]
public object ConnectionPropertiesDeserializedCorrectly(string propertyToCheck)
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var csv = serializer.Serialize(GetTestConnection());
var csv = _serializer.Serialize(GetTestConnection());
var deserializedConnections = _deserializer.Deserialize(csv);
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
var propertyValue = typeof(ConnectionInfo).GetProperty(propertyToCheck)?.GetValue(connection);
@@ -42,14 +42,29 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
[TestCaseSource(typeof(DeserializationTestSource), nameof(DeserializationTestSource.InheritanceTestCases))]
public object InheritancePropertiesDeserializedCorrectly(string propertyToCheck)
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var csv = serializer.Serialize(GetTestConnectionWithAllInherited());
var csv = _serializer.Serialize(GetTestConnectionWithAllInherited());
var deserializedConnections = _deserializer.Deserialize(csv);
var connection = deserializedConnections.GetRecursiveChildList().FirstOrDefault();
connection?.RemoveParent();
var propertyValue = typeof(ConnectionInfoInheritance).GetProperty(propertyToCheck)?.GetValue(connection?.Inheritance);
return propertyValue;
}
[Test]
public void TreeStructureDeserializedCorrectly()
{
//Root
// |- folder1
// | |- Con1
// |- Con2
var treeModel = new ConnectionTreeModelBuilder().Build();
var csv = _serializer.Serialize(treeModel);
var deserializedConnections = _deserializer.Deserialize(csv);
var con1 = deserializedConnections.GetRecursiveChildList().First(info => info.Name == "Con1");
var folder1 = deserializedConnections.GetRecursiveChildList().First(info => info.Name == "folder1");
Assert.That(con1.Parent, Is.EqualTo(folder1));
}
internal static ConnectionInfo GetTestConnection()
{
return new ConnectionInfo
@@ -82,9 +97,9 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
UseCredSsp = true,
RenderingEngine = HTTPBase.RenderingEngine.Gecko,
ICAEncryptionStrength = IcaProtocol.EncryptionStrength.Encr40Bit,
RDPAuthenticationLevel = RdpAuthenticationLevel.WarnOnFailedAuth,
Colors = RdpColors.Colors16Bit,
Resolution = RdpResolutions.Res1366x768,
RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.WarnOnFailedAuth,
Colors = RdpProtocol.RDPColors.Colors16Bit,
Resolution = RdpProtocol.RDPResolutions.Res1366x768,
AutomaticResize = true,
DisplayWallpaper = true,
DisplayThemes = true,
@@ -95,7 +110,7 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
RedirectPorts = true,
RedirectPrinters = true,
RedirectSmartCards = true,
RedirectSound = RdpSounds.LeaveAtRemoteComputer,
RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer,
RedirectKeys = true,
VNCCompression = ProtocolVNC.Compression.Comp4,
VNCEncoding = ProtocolVNC.Encoding.EncRRE,
@@ -105,8 +120,8 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
VNCColors = ProtocolVNC.Colors.Col8Bit,
VNCSmartSizeMode = ProtocolVNC.SmartSizeMode.SmartSAspect,
VNCViewOnly = true,
RDGatewayUsageMethod = RDGatewayUsageMethod.Detect,
RDGatewayUseConnectionCredentials = RDGatewayUseConnectionCredentials.SmartCard
RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Detect,
RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard
};
}

View File

@@ -1,13 +1,17 @@
using System;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Csv;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Credential;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNGTests.TestHelpers;
using NSubstitute;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.MiscSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
{
public class CsvConnectionsSerializerMremotengFormatTests
{
@@ -28,6 +32,24 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
_credentialRepositoryList.GetCredentialRecord(new Guid()).ReturnsForAnyArgs(credRecord);
}
[Test]
public void SerializesNodeId()
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var connectionInfo = BuildConnectionInfo();
var csv = serializer.Serialize(connectionInfo);
Assert.That(csv, Does.Match(connectionInfo.ConstantID));
}
[Test]
public void DoesntSerializeTheRootNode()
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var treeModel = new ConnectionTreeModelBuilder().Build();
var csv = serializer.Serialize(treeModel);
Assert.That(csv, Does.Not.Match($"{treeModel.RootNodes[0].ConstantID};.*;{TreeNodeType.Root}"));
}
[TestCase(Username)]
[TestCase(Domain)]
[TestCase(Password)]
@@ -82,6 +104,32 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
Assert.Throws<ArgumentNullException>(() => serializer.Serialize((ConnectionTreeModel)null));
}
[Test]
public void FoldersAreSerialized()
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var container = BuildContainer();
var csv = serializer.Serialize(container);
Assert.That(csv, Does.Match(container.Name));
Assert.That(csv, Does.Match(container.Username));
Assert.That(csv, Does.Match(container.Domain));
Assert.That(csv, Does.Match(container.Password));
Assert.That(csv, Does.Contain(TreeNodeType.Container.ToString()));
}
[Test]
public void SerializationIncludesRawInheritedValuesIfObjectInheritsFromParentOutsideOfSerializationScope()
{
var serializer = new CsvConnectionsSerializerMremotengFormat(new SaveFilter(), _credentialRepositoryList);
var treeModel = new ConnectionTreeModelBuilder().Build();
var serializationTarget = treeModel.GetRecursiveChildList().First(info => info.Name == "folder3");
var csv = serializer.Serialize(serializationTarget);
var lineWithFolder3 = csv.Split(new[] {Environment.NewLine}, StringSplitOptions.None).First(s => s.Contains(serializationTarget.Name));
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Username));
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Domain));
Assert.That(lineWithFolder3, Does.Contain(serializationTarget.Password));
}
private ConnectionInfo BuildConnectionInfo()
{
return new ConnectionInfo
@@ -93,5 +141,16 @@ namespace mRemoteNGTests.Config.Serializers.MiscSerializers
Inheritance = {Colors = true}
};
}
private ContainerInfo BuildContainer()
{
return new ContainerInfo
{
Name = "MyFolder",
Username = "BlahBlah1",
Domain = "aklkskkksh8",
Password = "qweraslkdjf87"
};
}
}
}

View File

@@ -0,0 +1,96 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Security;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class ValidateXmlSchemas
{
private XmlConnectionsSerializer _serializer;
private ConnectionTreeModel _connectionTreeModel;
private ICryptographyProvider _cryptographyProvider;
private XmlReaderSettings _xmlReaderSettings;
[SetUp]
public void Setup()
{
_connectionTreeModel = new ConnectionTreeModelBuilder().Build();
_cryptographyProvider = new AeadCryptographyProvider();
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(
_cryptographyProvider,
_connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
new SaveFilter());
_serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer);
_xmlReaderSettings = new XmlReaderSettings
{
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema |
XmlSchemaValidationFlags.ProcessSchemaLocation |
XmlSchemaValidationFlags.ReportValidationWarnings
};
}
[Test]
public void ValidateSchema()
{
var sb = new StringBuilder();
var xml = _serializer.Serialize(_connectionTreeModel);
var schemaFile = GetTargetPath("mremoteng_confcons_v2_6.xsd");
_xmlReaderSettings.Schemas.Add("http://mremoteng.org", schemaFile);
_xmlReaderSettings.ValidationEventHandler += (sender, args) =>
{
sb.AppendLine($"{args.Severity}: {args.Message}");
};
using (var stream = GenerateStreamFromString(xml))
{
var reader = XmlReader.Create(stream, _xmlReaderSettings);
while (reader.Read()) ;
}
Assert.That(sb.ToString(), Is.Empty);
}
public string GetTargetPath(string fileName, [CallerFilePath] string sourceFilePath = "")
{
const string debugOrRelease =
#if DEBUG
"Debug";
#else
"Release";
#endif
const string normalOrPortable =
#if PORTABLE
" Portable";
#else
"";
#endif
var path = Path.GetDirectoryName(sourceFilePath);
var filePath = $@"{path}\..\..\..\..\bin\{debugOrRelease}{normalOrPortable}\Schemas\{fileName}";
return filePath;
}
private Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
@@ -9,7 +10,7 @@ using mRemoteNG.Tree;
using mRemoteNGTests.Properties;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlConnectionsDeserializerTests
{
@@ -104,6 +105,14 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
Assert.That(folder22.Inheritance.Username, Is.True);
}
[TestCaseSource(typeof(XmlConnectionsDeserializerFixtureData), nameof(XmlConnectionsDeserializerFixtureData.FixtureParams))]
public void ExpandedPropertyGetsDeserialized(Datagram testData)
{
Setup(testData.ConfCons, testData.Password);
var folder1 = GetFolderNamed("Folder1", _connectionTreeModel.GetRecursiveChildList());
Assert.That(folder1.IsExpanded, Is.True);
}
private bool ContainsNodeNamed(string name, IEnumerable<ConnectionInfo> list)
{
return list.Any(node => node.Name == name);

View File

@@ -1,6 +1,7 @@
using System.Linq;
using System.Xml.XPath;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
@@ -9,7 +10,7 @@ using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlConnectionsDocumentCompilerTests
{

View File

@@ -1,6 +1,7 @@
using System.Linq;
using System.Xml.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
@@ -9,7 +10,7 @@ using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlConnectionsDocumentEncryptorTests
{

View File

@@ -2,6 +2,7 @@
using System.Xml;
using System.Xml.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
@@ -10,7 +11,7 @@ using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlConnectionsSerializerTests
{
@@ -55,7 +56,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
[TestCase("Username", "")]
[TestCase("Domain", "")]
[TestCase("Password", "")]
[TestCase("InheritAutomaticResize", "False")]
[TestCase("InheritAutomaticResize", "false")]
public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue)
{
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(

View File

@@ -2,13 +2,14 @@
using System.Collections;
using System.Xml.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Security;
using mRemoteNG.Security.Factories;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
{
public class XmlRootNodeSerializerTests
{
@@ -75,7 +76,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers
{
var element = _rootNodeSerializer.SerializeRootNodeInfo(_rootNodeInfo, _cryptographyProvider, fullFileEncryption);
var attributeValue = element.Attribute(XName.Get("FullFileEncryption"))?.Value;
Assert.That(attributeValue, Is.EqualTo(fullFileEncryption.ToString()));
Assert.That(bool.Parse(attributeValue), Is.EqualTo(fullFileEncryption));
}
[TestCase("", "ThisIsNotProtected")]

View File

@@ -1,4 +1,5 @@
using mRemoteNG.Config.Serializers;
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
@@ -26,7 +27,7 @@ namespace mRemoteNGTests.Config.Serializers
{
var model = CreateConnectionTreeModel();
var dataTable = _dataTableSerializer.Serialize(model);
Assert.That(dataTable.Rows.Count, Is.EqualTo(3));
Assert.That(dataTable.Rows.Count, Is.EqualTo(model.GetRecursiveChildList().Count()));
}
[Test]

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 RdpColors ExpectedColors = RdpColors.Colors24Bit;
private const RdpProtocol.RDPColors ExpectedColors = RdpProtocol.RDPColors.Colors24Bit;
private const bool ExpectedBitmapCaching = false;
private const RdpResolutions ExpectedResolutionMode = RdpResolutions.FitToWindow;
private const RdpProtocol.RDPResolutions ExpectedResolutionMode = RdpProtocol.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 RdpSounds ExpectedSoundRedirection = RdpSounds.BringToThisComputer;
private const RdpProtocol.RDPSounds ExpectedSoundRedirection = RdpProtocol.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 RDGatewayUsageMethod ExpectedGatewayUsageMethod = RDGatewayUsageMethod.Always;
private const RdpProtocol.RDGatewayUsageMethod ExpectedGatewayUsageMethod = RdpProtocol.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 RdpResolutions ExpectedRdpResolution = RdpResolutions.FitToWindow;
private const RdpColors ExpectedRdpColorDepth = RdpColors.Colors24Bit;
private const RdpSounds ExpectedAudioRedirection = RdpSounds.DoNotPlay;
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 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 RdpAuthenticationLevel ExpectedAuthLevel = RdpAuthenticationLevel.WarnOnFailedAuth;
private const RdpProtocol.AuthenticationLevel ExpectedAuthLevel = RdpProtocol.AuthenticationLevel.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 RDGatewayUsageMethod ExpectedGatewayUsageMethod = RDGatewayUsageMethod.Always;
private const RdpProtocol.RDGatewayUsageMethod ExpectedGatewayUsageMethod = RdpProtocol.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 RdpResolutions ExpectedRdpResolution = RdpResolutions.FitToWindow;
private const RdpColors ExpectedRdpColorDepth = RdpColors.Colors24Bit;
private const RdpSounds ExpectedAudioRedirection = RdpSounds.DoNotPlay;
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 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 RdpAuthenticationLevel ExpectedAuthLevel = RdpAuthenticationLevel.AuthRequired;
private const RdpProtocol.AuthenticationLevel ExpectedAuthLevel = RdpProtocol.AuthenticationLevel.AuthRequired;
[OneTimeSetUp]

View File

@@ -1,4 +1,5 @@
using mRemoteNG.Connection;
using System;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.ICA;
@@ -12,7 +13,11 @@ namespace mRemoteNGTests.Connection
public class AbstractConnectionInfoDataTests
{
#pragma warning disable 618
private class TestAbstractConnectionInfoData : AbstractConnectionRecord {}
private class TestAbstractConnectionInfoData : AbstractConnectionRecord {
public TestAbstractConnectionInfoData() : base(Guid.NewGuid().ToString())
{
}
}
#pragma warning restore 618
private TestAbstractConnectionInfoData _testAbstractConnectionInfoData;
@@ -160,7 +165,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDPAuthenticationLevel = RdpAuthenticationLevel.AuthRequired;
_testAbstractConnectionInfoData.RDPAuthenticationLevel = RdpProtocol.AuthenticationLevel.AuthRequired;
Assert.That(wasCalled, Is.True);
}
@@ -196,7 +201,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUsageMethod = RDGatewayUsageMethod.Always;
_testAbstractConnectionInfoData.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
Assert.That(wasCalled, Is.True);
}
@@ -214,7 +219,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RDGatewayUseConnectionCredentials = RDGatewayUseConnectionCredentials.SmartCard;
_testAbstractConnectionInfoData.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard;
Assert.That(wasCalled, Is.True);
}
@@ -250,7 +255,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Resolution = RdpResolutions.Res1366x768;
_testAbstractConnectionInfoData.Resolution = RdpProtocol.RDPResolutions.Res1366x768;
Assert.That(wasCalled, Is.True);
}
@@ -268,7 +273,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.Colors = RdpColors.Colors16Bit;
_testAbstractConnectionInfoData.Colors = RdpProtocol.RDPColors.Colors16Bit;
Assert.That(wasCalled, Is.True);
}
@@ -367,7 +372,7 @@ namespace mRemoteNGTests.Connection
{
var wasCalled = false;
_testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true;
_testAbstractConnectionInfoData.RedirectSound = RdpSounds.DoNotPlay;
_testAbstractConnectionInfoData.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
Assert.That(wasCalled, Is.True);
}

View File

@@ -27,22 +27,6 @@ namespace mRemoteNGTests.Connection
_connectionInfo = null;
}
[Test]
public void CreatingConnectionInfoWithParentSetsTheParentProperty()
{
var container = new ContainerInfo();
var connectionInfo = new ConnectionInfo(container);
Assert.That(connectionInfo.Parent, Is.EqualTo(container));
}
[Test]
public void CreatingConnectionInfoWithParentAddsToTheParentsChildList()
{
var container = new ContainerInfo();
var connectionInfo = new ConnectionInfo(container);
Assert.That(container.Children, Does.Contain(connectionInfo));
}
[Test]
public void CopyCreatesMemberwiseCopy()
{
@@ -81,7 +65,7 @@ namespace mRemoteNGTests.Connection
{
var eventWasCalled = false;
_connectionInfo.PropertyChanged += (sender, args) => eventWasCalled = true;
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionInfo));
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
Assert.That(eventWasCalled);
}
@@ -90,7 +74,7 @@ namespace mRemoteNGTests.Connection
{
var nameOfModifiedProperty = "";
_connectionInfo.PropertyChanged += (sender, args) => nameOfModifiedProperty = args.PropertyName;
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionInfo));
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
Assert.That(nameOfModifiedProperty, Is.EqualTo("OpenConnections"));
}

View File

@@ -1,73 +1,62 @@
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using System.Collections.Generic;
using System.Reflection;
using mRemoteNG.Connection;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
namespace mRemoteNGTests.Connection
{
public class DefaultConnectionInfoTests
{
private string _testDomain = "somedomain";
public class DefaultConnectionInfoTests
{
private ConnectionInfo _randomizedConnectionInfo;
[SetUp]
public void Setup()
{
DefaultConnectionInfo.Instance.Domain = "";
_randomizedConnectionInfo = ConnectionInfoHelpers.GetRandomizedConnectionInfo();
}
[Test]
public void LoadingDefaultInfoUpdatesAllProperties()
[TestCaseSource(nameof(GetConnectionInfoProperties))]
public void LoadingDefaultInfoUpdatesAllProperties(PropertyInfo property)
{
var connectionInfoSource = new ConnectionInfo { Domain = _testDomain };
DefaultConnectionInfo.Instance.LoadFrom(connectionInfoSource);
Assert.That(DefaultConnectionInfo.Instance.Domain, Is.EqualTo(_testDomain));
DefaultConnectionInfo.Instance.LoadFrom(_randomizedConnectionInfo);
var valueInDestination = property.GetValue(DefaultConnectionInfo.Instance);
var valueInSource = property.GetValue(_randomizedConnectionInfo);
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
[Test]
public void SavingDefaultConnectionInfoExportsAllProperties()
[TestCaseSource(nameof(GetConnectionInfoProperties))]
public void SavingDefaultConnectionInfoExportsAllProperties(PropertyInfo property)
{
var saveTarget = new ConnectionInfo();
DefaultConnectionInfo.Instance.Domain = _testDomain;
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
Assert.That(saveTarget.Domain, Is.EqualTo(_testDomain));
var valueInDestination = property.GetValue(saveTarget);
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance);
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
[Test]
public void CanSaveEnumValuesToString()
{
const ProtocolType targetProtocol = ProtocolType.RAW;
var saveTarget = new AllStringPropertySaveTarget();
DefaultConnectionInfo.Instance.Protocol = targetProtocol;
[TestCaseSource(nameof(GetConnectionInfoProperties))]
public void CanSaveDefaultConnectionToModelWithAllStringProperties(PropertyInfo property)
{
var saveTarget = new SerializableConnectionInfoAllPropertiesOfType<string>();
// randomize default connnection values to ensure we dont get false passing tests
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
Assert.That(saveTarget.Protocol, Is.EqualTo(targetProtocol.ToString()));
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance).ToString();
var valueInDestination = saveTarget.GetType().GetProperty(property.Name).GetValue(saveTarget).ToString();
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
[Test]
public void CanSaveIntegerValuesToString()
{
const int targetValue = 123;
var saveTarget = new AllStringPropertySaveTarget();
DefaultConnectionInfo.Instance.RDPMinutesToIdleTimeout = targetValue;
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
Assert.That(saveTarget.RDPMinutesToIdleTimeout, Is.EqualTo(targetValue.ToString()));
}
[Test]
public void CanSaveStringValuesToString()
{
const string targetName = "hello";
var saveTarget = new AllStringPropertySaveTarget();
DefaultConnectionInfo.Instance.Username = targetName;
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
Assert.That(saveTarget.Username, Is.EqualTo(targetName));
}
private class AllStringPropertySaveTarget
{
public string Username { get; set; }
public string Protocol { get; set; }
public string RDPMinutesToIdleTimeout { get; set; }
}
private static IEnumerable<PropertyInfo> GetConnectionInfoProperties()
{
return new ConnectionInfo().GetSerializableProperties();
}
}
}

View File

@@ -1,34 +1,40 @@
using mRemoteNG.Connection;
using System.Collections.Generic;
using System.Reflection;
using mRemoteNG.Connection;
using NUnit.Framework;
namespace mRemoteNGTests.Connection
{
public class DefaultConnectionInheritanceTests
public class DefaultConnectionInheritanceTests
{
[SetUp]
public void Setup()
[TestCaseSource(nameof(GetInheritanceProperties))]
public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
{
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
}
[Test]
public void LoadingDefaultInheritanceUpdatesAllProperties()
{
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
inheritanceSource.TurnOnInheritanceCompletely();
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
Assert.That(DefaultConnectionInheritance.Instance.EverythingInherited, Is.True);
}
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
[Test]
public void SavingDefaultInheritanceExportsAllProperties()
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
var valueInDestination = property.GetValue(DefaultConnectionInheritance.Instance);
var valueInSource = property.GetValue(inheritanceSource);
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
[TestCaseSource(nameof(GetInheritanceProperties))]
public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
{
var inheritanceDestination = new ConnectionInfoInheritance(new object(), true);
DefaultConnectionInheritance.Instance.AutomaticResize = true;
DefaultConnectionInheritance.Instance.SaveTo(inheritanceDestination);
Assert.That(inheritanceDestination.AutomaticResize, Is.True);
}
var saveTarget = new ConnectionInfoInheritance(new object(), true);
saveTarget.TurnOffInheritanceCompletely();
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
DefaultConnectionInheritance.Instance.SaveTo(saveTarget);
var valueInDestination = property.GetValue(saveTarget);
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
[Test]
public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
@@ -38,12 +44,20 @@ namespace mRemoteNGTests.Connection
Assert.That(inheritanceInstance.Domain, Is.True);
}
[Test]
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues()
[TestCaseSource(nameof(GetInheritanceProperties))]
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
{
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
var inheritanceInstance = new ConnectionInfoInheritance(new object());
Assert.That(inheritanceInstance.EverythingInherited, Is.True);
}
}
var valueInDestination = property.GetValue(inheritanceInstance);
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
}
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
{
return new ConnectionInfoInheritance(new object(), true).GetProperties();
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
using mRemoteNG.Connection;
using mRemoteNG.Tree.Root;
using NUnit.Framework;
namespace mRemoteNGTests.Container
{
public class RootNodeInfoTests
{
[Test]
public void InheritanceIsDisabledForNodesDirectlyUnderRootNode()
{
var rootNode = new RootNodeInfo(RootNodeType.Connection);
var con1 = new ConnectionInfo { Inheritance = { Password = true } };
rootNode.AddChild(con1);
Assert.That(con1.Inheritance.Password, Is.False);
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Linq;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;

View File

@@ -34,8 +34,9 @@
using System.Collections;
using System.Windows.Forms;
using NUnit.Extensions.Forms;
namespace NUnit.Extensions.Forms
namespace mRemoteNGTests
{
/// <summary>
/// A ControlTester for testing List Views.

View File

@@ -0,0 +1,132 @@
using System;
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;
namespace mRemoteNGTests.TestHelpers
{
internal class ConnectionInfoHelpers
{
private static readonly Random _random = new Random();
/// <summary>
/// Returns a <see cref="ConnectionInfo"/> object with randomized
/// values in all fields.
/// </summary>
internal static ConnectionInfo GetRandomizedConnectionInfo(bool randomizeInheritance = false)
{
var connectionInfo = new ConnectionInfo
{
// string types
Name = RandomString(),
Hostname = RandomString(),
Description = RandomString(),
Domain = RandomString(),
ExtApp = RandomString(),
Icon = RandomString(),
LoadBalanceInfo = RandomString(),
MacAddress = RandomString(),
Panel = RandomString(),
Password = RandomString(),
PostExtApp = RandomString(),
PreExtApp = RandomString(),
PuttySession = RandomString(),
RDGatewayHostname = RandomString(),
RDGatewayUsername = RandomString(),
RDGatewayDomain = RandomString(),
RDGatewayPassword = RandomString(),
UserField = RandomString(),
Username = RandomString(),
VNCProxyIP = RandomString(),
VNCProxyPassword = RandomString(),
VNCProxyUsername = RandomString(),
// bool types
AutomaticResize = RandomBool(),
CacheBitmaps = RandomBool(),
DisplayThemes = RandomBool(),
DisplayWallpaper = RandomBool(),
EnableDesktopComposition = RandomBool(),
EnableFontSmoothing = RandomBool(),
IsContainer = RandomBool(),
IsDefault = RandomBool(),
IsQuickConnect = RandomBool(),
PleaseConnect = RandomBool(),
RDPAlertIdleTimeout = RandomBool(),
RedirectDiskDrives = RandomBool(),
RedirectKeys = RandomBool(),
RedirectPorts = RandomBool(),
RedirectPrinters = RandomBool(),
RedirectSmartCards = RandomBool(),
UseConsoleSession = RandomBool(),
UseCredSsp = RandomBool(),
VNCViewOnly = RandomBool(),
// ints
Port = RandomInt(),
RDPMinutesToIdleTimeout = RandomInt(),
VNCProxyPort = RandomInt(),
// enums
Colors = RandomEnum<RdpProtocol.RDPColors>(),
ICAEncryptionStrength = RandomEnum<IcaProtocol.EncryptionStrength> (),
Protocol = RandomEnum<ProtocolType>(),
RDGatewayUsageMethod = RandomEnum<RdpProtocol.RDGatewayUsageMethod>(),
RDGatewayUseConnectionCredentials = RandomEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(),
RDPAuthenticationLevel = RandomEnum<RdpProtocol.AuthenticationLevel>(),
RedirectSound = RandomEnum<RdpProtocol.RDPSounds>(),
RenderingEngine = RandomEnum<HTTPBase.RenderingEngine>(),
Resolution = RandomEnum<RdpProtocol.RDPResolutions>(),
SoundQuality = RandomEnum<RdpProtocol.RDPSoundQuality>(),
VNCAuthMode = RandomEnum<ProtocolVNC.AuthMode>(),
VNCColors = RandomEnum<ProtocolVNC.Colors>(),
VNCCompression = RandomEnum<ProtocolVNC.Compression>(),
VNCEncoding = RandomEnum<ProtocolVNC.Encoding>(),
VNCProxyType = RandomEnum<ProtocolVNC.ProxyType>(),
VNCSmartSizeMode = RandomEnum<ProtocolVNC.SmartSizeMode>(),
};
if (randomizeInheritance)
connectionInfo.Inheritance = GetRandomizedInheritance(connectionInfo);
return connectionInfo;
}
internal static ConnectionInfoInheritance GetRandomizedInheritance(ConnectionInfo parent)
{
var inheritance = new ConnectionInfoInheritance(parent, true);
foreach (var property in inheritance.GetProperties())
{
property.SetValue(inheritance, RandomBool());
}
return inheritance;
}
internal static string RandomString()
{
return Guid.NewGuid().ToString("N");
}
internal static bool RandomBool()
{
return _random.Next() % 2 == 0;
}
internal static int RandomInt()
{
return _random.Next();
}
internal static T RandomEnum<T>() where T : struct, IConvertible
{
if (!typeof(T).IsEnum)
throw new ArgumentException("T must be an enum");
var values = Enum.GetValues(typeof(T));
return (T)values.GetValue(_random.Next(values.Length));
}
}
}

View File

@@ -7,17 +7,52 @@ namespace mRemoteNGTests.TestHelpers
{
public class ConnectionTreeModelBuilder
{
/// <summary>
/// Builds a tree which looks like:
/// Root
/// |- folder1
/// | |- con1
/// |- con2
/// |- folder2
/// |- folder3
/// |- con3
/// </summary>
/// <returns></returns>
public ConnectionTreeModel Build()
{
var model = new ConnectionTreeModel();
var root = new RootNodeInfo(RootNodeType.Connection);
var folder1 = new ContainerInfo { Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1" };
var folder2 = new ContainerInfo { Name = "folder2", Username = "user2", Domain = "domain2", Password = "password2" };
var folder3 = new ContainerInfo
{
Name = "folder3",
Inheritance =
{
Username = true,
Domain = true,
Password = true
}
};
var con1 = new ConnectionInfo { Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
var con2 = new ConnectionInfo { Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };
var con3 = new ContainerInfo
{
Name = "con3",
Inheritance =
{
Username = true,
Domain = true,
Password = true
}
};
root.AddChild(folder1);
root.AddChild(con2);
folder1.AddChild(con1);
root.AddChild(folder2);
folder2.AddChild(folder3);
folder3.AddChild(con3);
model.AddRootNode(root);
return model;
}

View File

@@ -0,0 +1,63 @@
namespace mRemoteNGTests.TestHelpers
{
/// <summary>
/// A ConnectionInfo that has only the serializable properties as string types.
/// Only used for testing.
/// </summary>
internal class SerializableConnectionInfoAllPropertiesOfType<TType>
{
public TType Description { get; set; }
public TType Icon { get; set; }
public TType Panel { get; set; }
public TType Username { get; set; }
public TType Password { get; set; }
public TType Domain { get; set; }
public TType Protocol { get; set; }
public TType ExtApp { get; set; }
public TType PuttySession { get; set; }
public TType ICAEncryptionStrength { get; set; }
public TType UseConsoleSession { get; set; }
public TType RDPAuthenticationLevel { get; set; }
public TType RDPMinutesToIdleTimeout { get; set; }
public TType RDPAlertIdleTimeout { get; set; }
public TType LoadBalanceInfo { get; set; }
public TType RenderingEngine { get; set; }
public TType UseCredSsp { get; set; }
public TType RDGatewayUsageMethod { get; set; }
public TType RDGatewayHostname { get; set; }
public TType RDGatewayUseConnectionCredentials { get; set; }
public TType RDGatewayUsername { get; set; }
public TType RDGatewayPassword { get; set; }
public TType RDGatewayDomain { get; set; }
public TType Resolution { get; set; }
public TType AutomaticResize { get; set; }
public TType Colors { get; set; }
public TType CacheBitmaps { get; set; }
public TType DisplayWallpaper { get; set; }
public TType DisplayThemes { get; set; }
public TType EnableFontSmoothing { get; set; }
public TType EnableDesktopComposition { get; set; }
public TType RedirectKeys { get; set; }
public TType RedirectDiskDrives { get; set; }
public TType RedirectPrinters { get; set; }
public TType RedirectPorts { get; set; }
public TType RedirectSmartCards { get; set; }
public TType RedirectSound { get; set; }
public TType SoundQuality { get; set; }
public TType PreExtApp { get; set; }
public TType PostExtApp { get; set; }
public TType MacAddress { get; set; }
public TType UserField { get; set; }
public TType VNCCompression { get; set; }
public TType VNCEncoding { get; set; }
public TType VNCAuthMode { get; set; }
public TType VNCProxyType { get; set; }
public TType VNCProxyIP { get; set; }
public TType VNCProxyPort { get; set; }
public TType VNCProxyUsername { get; set; }
public TType VNCProxyPassword { get; set; }
public TType VNCColors { get; set; }
public TType VNCSmartSizeMode { get; set; }
public TType VNCViewOnly { get; set; }
}
}

View File

@@ -3,12 +3,12 @@ using NUnit.Framework;
namespace mRemoteNGTests.Tools
{
public class MaybeTests
public class OptionalTests
{
[Test]
public void MaybeReturnsEmptyListWhenGivenNullValue()
{
var sut = new Maybe<object>(null);
var sut = new Optional<object>(null);
Assert.That(sut, Is.Empty);
}
@@ -16,7 +16,7 @@ namespace mRemoteNGTests.Tools
public void MaybeReturnsValueIfNotNull()
{
var expected = new object();
var sut = new Maybe<object>(expected);
var sut = new Optional<object>(expected);
Assert.That(sut, Has.Member(expected));
}

View File

@@ -8,7 +8,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.Tree
{
public class NodeSearcherTests
public class NodeSearcherTests
{
private NodeSearcher _nodeSearcher;
private ContainerInfo _folder1;
@@ -104,6 +104,14 @@ namespace mRemoteNGTests.Tree
_con4 = new ConnectionInfo { Name = "con4", Description="description6", Hostname="hostname6" };
_con5 = new ConnectionInfo { Name = "con5", Description="description7", Hostname="hostname7" };
_folder1.Inheritance.TurnOffInheritanceCompletely();
_con1.Inheritance.TurnOffInheritanceCompletely();
_con2.Inheritance.TurnOffInheritanceCompletely();
_folder2.Inheritance.TurnOffInheritanceCompletely();
_con3.Inheritance.TurnOffInheritanceCompletely();
_con4.Inheritance.TurnOffInheritanceCompletely();
_con5.Inheritance.TurnOffInheritanceCompletely();
connectionTreeModel.AddRootNode(root);
root.AddChildRange(new [] { _folder1, _folder2, _con5 });
_folder1.AddChildRange(new [] { _con1, _con2 });

View File

@@ -114,6 +114,7 @@
<Compile Include="Config\DataProviders\FileBackupCreatorTests.cs" />
<Compile Include="Config\DataProviders\FileDataProviderTests.cs" />
<Compile Include="Config\DataProviders\FileDataProviderWithRollingBackupTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\ValidateXmlSchemas.cs" />
<Compile Include="Config\Serializers\DataTableDeserializerTests.cs" />
<Compile Include="Config\CredentialHarvesterTests.cs" />
<Compile Include="Config\CredentialRecordLoaderTests.cs" />
@@ -121,21 +122,21 @@
<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\ConnectionSerializers\Csv\CsvConnectionsDeserializerMremotengFormatTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Csv\CsvConnectionsSerializerMremotengFormatTests.cs" />
<Compile Include="Config\Serializers\DataTableSerializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\PortScanDeserializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\PuttyConnectionManagerDeserializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDeserializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDeserializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionDeserializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionManager27DeserializerTests.cs" />
<Compile Include="Config\Serializers\MiscSerializers\RemoteDesktopConnectionManagerDeserializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDocumentCompilerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsDocumentEncryptorTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\XmlConnectionsSerializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDocumentCompilerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsDocumentEncryptorTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlConnectionsSerializerTests.cs" />
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialRecordDeserializerTests.cs" />
<Compile Include="Config\Serializers\CredentialSerializers\XmlCredentialSerializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\XmlRootNodeSerializerTests.cs" />
<Compile Include="Config\Serializers\ConnectionSerializers\Xml\XmlRootNodeSerializerTests.cs" />
<Compile Include="Config\Serializers\Versioning\SqlVersion22To23UpgraderTests.cs" />
<Compile Include="Config\Serializers\Versioning\SqlVersion23To24UpgraderTests.cs" />
<Compile Include="Config\Serializers\Versioning\SqlVersion24To25UpgraderTests.cs" />
@@ -145,6 +146,7 @@
<Compile Include="Connection\ConnectionInfoComparerTests.cs" />
<Compile Include="Connection\Protocol\IntegratedProgramTests.cs" />
<Compile Include="Connection\Protocol\ProtocolListTests.cs" />
<Compile Include="Container\RootNodeInfoTests.cs" />
<Compile Include="Credential\CompositeRepositoryUnlockerTests.cs" />
<Compile Include="Credential\CredentialChangedEventArgsTests.cs" />
<Compile Include="Credential\CredentialDeletionMsgBoxConfirmerTests.cs" />
@@ -168,12 +170,14 @@
<Compile Include="Security\PasswordCreation\PasswordLengthConstraintTests.cs" />
<Compile Include="Security\RandomGeneratorTests.cs" />
<Compile Include="Security\SecureStringExtensionsTests.cs" />
<Compile Include="TestHelpers\ConnectionInfoHelpers.cs" />
<Compile Include="TestHelpers\ConnectionTreeModelBuilder.cs" />
<Compile Include="Security\XmlCryptoProviderBuilderTests.cs" />
<Compile Include="TestHelpers\FileTestHelpers.cs" />
<Compile Include="TestHelpers\SerializableConnectionInfoAllPropertiesOfType.cs" />
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
<Compile Include="Tools\FullyObservableCollectionTests.cs" />
<Compile Include="Tools\MaybeTests.cs" />
<Compile Include="Tools\OptionalTests.cs" />
<Compile Include="Tree\ClickHandlers\TreeNodeCompositeClickHandlerTests.cs" />
<Compile Include="Tree\ConnectionTreeDragAndDropHandlerTests.cs" />
<Compile Include="Tree\ConnectionTreeModelTests.cs" />

View File

@@ -4,6 +4,8 @@ using System.Windows.Forms;
using mRemoteNG.Config.Connections;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Csv;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;

View File

@@ -10,7 +10,7 @@ namespace mRemoteNG.Config.Connections
/// The previous <see cref="ConnectionTreeModel"/> that is being
/// unloaded.
/// </summary>
public Maybe<ConnectionTreeModel> PreviousConnectionTreeModel { get; }
public Optional<ConnectionTreeModel> PreviousConnectionTreeModel { get; }
/// <summary>
/// True if the previous <see cref="ConnectionTreeModel"/> was loaded from
@@ -37,7 +37,7 @@ namespace mRemoteNG.Config.Connections
public string NewSourcePath { get; }
public ConnectionsLoadedEventArgs(
Maybe<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
Optional<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
bool previousSourceWasDatabase, bool newSourceIsDatabase,
string newSourcePath)
{

View File

@@ -2,6 +2,7 @@
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Csv;
using mRemoteNG.Security;
using mRemoteNG.Tree;

View File

@@ -5,6 +5,7 @@ using mRemoteNG.Config.Serializers;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using System.IO;
using mRemoteNG.Config.Serializers.Xml;
namespace mRemoteNG.Config.Connections
{

View File

@@ -3,6 +3,7 @@ using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Security;
using mRemoteNG.Security.Factories;
using mRemoteNG.Tree;

View File

@@ -2,7 +2,7 @@
using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers.MiscSerializers;
using mRemoteNG.Config.Serializers.Csv;
using mRemoteNG.Container;
using mRemoteNG.Messages;

View File

@@ -3,6 +3,7 @@ using System.Linq;
using mRemoteNG.App;
using mRemoteNG.Config.DataProviders;
using mRemoteNG.Config.Serializers;
using mRemoteNG.Config.Serializers.Xml;
using mRemoteNG.Container;
using mRemoteNG.Messages;

View File

@@ -11,16 +11,16 @@ using mRemoteNG.Container;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.MiscSerializers
namespace mRemoteNG.Config.Serializers.Csv
{
public class CsvConnectionsDeserializerMremotengFormat : IDeserializer<string, ConnectionTreeModel>
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>();
// used to map a connectioninfo to it's parent's GUID
var parentMapping = new Dictionary<ConnectionInfo, string>();
for (var lineNumber = 0; lineNumber < lines.Length; lineNumber++)
{
@@ -30,39 +30,61 @@ namespace mRemoteNG.Config.Serializers.MiscSerializers
else
{
var connectionInfo = ParseConnectionInfo(csvHeaders, line);
var folder = ParseConnectionFolder(line[csvHeaders.IndexOf("Folder")], root);
folder.AddChild(connectionInfo);
parentMapping.Add(connectionInfo, line[csvHeaders.IndexOf("Parent")]);
}
}
var root = CreateTreeStructure(parentMapping);
var connectionTreeModel = new ConnectionTreeModel();
connectionTreeModel.AddRootNode(root);
return connectionTreeModel;
}
private ContainerInfo ParseConnectionFolder(string folderString, ContainerInfo rootContainer)
private RootNodeInfo CreateTreeStructure(Dictionary<ConnectionInfo, string> parentMapping)
{
var containerNames = folderString.Split('\\');
var parentContainer = rootContainer;
var root = new RootNodeInfo(RootNodeType.Connection);
for (var i = containerNames.Length - 2; i >= 0; i--)
foreach (var node in parentMapping)
{
var containerName = containerNames[i];
var container = parentContainer.Children.OfType<ContainerInfo>().FirstOrDefault(info => info.Name == containerName);
if (container == null)
// no parent mapped, add to root
if (string.IsNullOrEmpty(node.Value))
{
container = new ContainerInfo {Name = containerName};
parentContainer.AddChild(container);
root.AddChild(node.Key);
continue;
}
// search for parent in the list by GUID
var parent = parentMapping
.Keys
.OfType<ContainerInfo>()
.FirstOrDefault(info => info.ConstantID == node.Value);
if (parent != null)
{
parent.AddChild(node.Key);
}
else
{
root.AddChild(node.Key);
}
parentContainer = container;
}
return parentContainer;
return root;
}
private ConnectionInfo ParseConnectionInfo(IList<string> headers, string[] connectionCsv)
{
var connectionRecord = new ConnectionInfo();
var nodeType = headers.Contains("NodeType")
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
: TreeNodeType.Connection;
var nodeId = headers.Contains("Id")
? connectionCsv[headers.IndexOf("Id")]
: Guid.NewGuid().ToString();
var connectionRecord = nodeType == TreeNodeType.Connection
? new ConnectionInfo(nodeId)
: new ContainerInfo(nodeId);
connectionRecord.Name = headers.Contains("Name") ? connectionCsv[headers.IndexOf("Name")] : "";
connectionRecord.Description = headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
@@ -131,21 +153,21 @@ namespace mRemoteNG.Config.Serializers.MiscSerializers
if (headers.Contains("RDPAuthenticationLevel"))
{
RdpAuthenticationLevel value;
RdpProtocol.AuthenticationLevel value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDPAuthenticationLevel")], out value))
connectionRecord.RDPAuthenticationLevel = value;
}
if (headers.Contains("Colors"))
{
RdpColors value;
RdpProtocol.RDPColors value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("Colors")], out value))
connectionRecord.Colors = value;
}
if (headers.Contains("Resolution"))
{
RdpResolutions value;
RdpProtocol.RDPResolutions value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("Resolution")], out value))
connectionRecord.Resolution = value;
}
@@ -222,7 +244,7 @@ namespace mRemoteNG.Config.Serializers.MiscSerializers
if (headers.Contains("RedirectSound"))
{
RdpSounds value;
RdpProtocol.RDPSounds value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RedirectSound")], out value))
connectionRecord.RedirectSound = value;
}
@@ -292,14 +314,14 @@ namespace mRemoteNG.Config.Serializers.MiscSerializers
if (headers.Contains("RDGatewayUsageMethod"))
{
RDGatewayUsageMethod value;
RdpProtocol.RDGatewayUsageMethod value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUsageMethod")], out value))
connectionRecord.RDGatewayUsageMethod = value;
}
if (headers.Contains("RDGatewayUseConnectionCredentials"))
{
RDGatewayUseConnectionCredentials value;
RdpProtocol.RDGatewayUseConnectionCredentials value;
if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUseConnectionCredentials")], out value))
connectionRecord.RDGatewayUseConnectionCredentials = value;
}

View File

@@ -0,0 +1,211 @@
using System;
using System.Linq;
using System.Text;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Credential;
using mRemoteNG.Security;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers.Csv
{
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
{
private readonly SaveFilter _saveFilter;
private readonly ICredentialRepositoryList _credentialRepositoryList;
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
{
saveFilter.ThrowIfNull(nameof(saveFilter));
credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
_saveFilter = saveFilter;
_credentialRepositoryList = credentialRepositoryList;
}
public string Serialize(ConnectionTreeModel connectionTreeModel)
{
connectionTreeModel.ThrowIfNull(nameof(connectionTreeModel));
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public string Serialize(ConnectionInfo serializationTarget)
{
serializationTarget.ThrowIfNull(nameof(serializationTarget));
var sb = new StringBuilder();
WriteCsvHeader(sb);
SerializeNodesRecursive(serializationTarget, sb);
return sb.ToString();
}
private void WriteCsvHeader(StringBuilder sb)
{
sb.Append("Name;Id;Parent;NodeType;Description;Icon;Panel;");
if (_saveFilter.SaveUsername)
sb.Append("Username;");
if (_saveFilter.SavePassword)
sb.Append("Password;");
if (_saveFilter.SaveDomain)
sb.Append("Domain;");
sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
if (_saveFilter.SaveInheritance)
sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
}
private void SerializeNodesRecursive(ConnectionInfo node, StringBuilder sb)
{
var nodeAsContainer = node as ContainerInfo;
if (nodeAsContainer != null)
{
foreach (var child in nodeAsContainer.Children)
{
SerializeNodesRecursive(child, sb);
}
}
// dont serialize the root node
if (node is RootNodeInfo)
return;
SerializeConnectionInfo(node, sb);
}
private void SerializeConnectionInfo(ConnectionInfo con, StringBuilder sb)
{
sb.AppendLine();
sb.Append(FormatForCsv(con.Name))
.Append(FormatForCsv(con.ConstantID))
.Append(FormatForCsv(con.Parent?.ConstantID ?? ""))
.Append(FormatForCsv(con.GetTreeNodeType()))
.Append(FormatForCsv(con.Description))
.Append(FormatForCsv(con.Icon))
.Append(FormatForCsv(con.Panel));
if (_saveFilter.SaveUsername)
sb.Append(FormatForCsv(con.Username));
if (_saveFilter.SavePassword)
sb.Append(FormatForCsv(con.Password));
if (_saveFilter.SaveDomain)
sb.Append(FormatForCsv(con.Domain));
sb.Append(FormatForCsv(con.Hostname))
.Append(FormatForCsv(con.Protocol))
.Append(FormatForCsv(con.PuttySession))
.Append(FormatForCsv(con.Port))
.Append(FormatForCsv(con.UseConsoleSession))
.Append(FormatForCsv(con.UseCredSsp))
.Append(FormatForCsv(con.RenderingEngine))
.Append(FormatForCsv(con.ICAEncryptionStrength))
.Append(FormatForCsv(con.RDPAuthenticationLevel))
.Append(FormatForCsv(con.LoadBalanceInfo))
.Append(FormatForCsv(con.Colors))
.Append(FormatForCsv(con.Resolution))
.Append(FormatForCsv(con.AutomaticResize))
.Append(FormatForCsv(con.DisplayWallpaper))
.Append(FormatForCsv(con.DisplayThemes))
.Append(FormatForCsv(con.EnableFontSmoothing))
.Append(FormatForCsv(con.EnableDesktopComposition))
.Append(FormatForCsv(con.CacheBitmaps))
.Append(FormatForCsv(con.RedirectDiskDrives))
.Append(FormatForCsv(con.RedirectPorts))
.Append(FormatForCsv(con.RedirectPrinters))
.Append(FormatForCsv(con.RedirectSmartCards))
.Append(FormatForCsv(con.RedirectSound))
.Append(FormatForCsv(con.RedirectKeys))
.Append(FormatForCsv(con.PreExtApp))
.Append(FormatForCsv(con.PostExtApp))
.Append(FormatForCsv(con.MacAddress))
.Append(FormatForCsv(con.UserField))
.Append(FormatForCsv(con.ExtApp))
.Append(FormatForCsv(con.VNCCompression))
.Append(FormatForCsv(con.VNCEncoding))
.Append(FormatForCsv(con.VNCAuthMode))
.Append(FormatForCsv(con.VNCProxyType))
.Append(FormatForCsv(con.VNCProxyIP))
.Append(FormatForCsv(con.VNCProxyPort))
.Append(FormatForCsv(con.VNCProxyUsername))
.Append(FormatForCsv(con.VNCProxyPassword))
.Append(FormatForCsv(con.VNCColors))
.Append(FormatForCsv(con.VNCSmartSizeMode))
.Append(FormatForCsv(con.VNCViewOnly))
.Append(FormatForCsv(con.RDGatewayUsageMethod))
.Append(FormatForCsv(con.RDGatewayHostname))
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
.Append(FormatForCsv(con.RDGatewayUsername))
.Append(FormatForCsv(con.RDGatewayPassword))
.Append(FormatForCsv(con.RDGatewayDomain));
if (!_saveFilter.SaveInheritance)
return;
sb.Append(FormatForCsv(con.Inheritance.CacheBitmaps))
.Append(FormatForCsv(con.Inheritance.Colors))
.Append(FormatForCsv(con.Inheritance.Description))
.Append(FormatForCsv(con.Inheritance.DisplayThemes))
.Append(FormatForCsv(con.Inheritance.DisplayWallpaper))
.Append(FormatForCsv(con.Inheritance.EnableFontSmoothing))
.Append(FormatForCsv(con.Inheritance.EnableDesktopComposition))
.Append(FormatForCsv(con.Inheritance.Domain))
.Append(FormatForCsv(con.Inheritance.Icon))
.Append(FormatForCsv(con.Inheritance.Panel))
.Append(FormatForCsv(con.Inheritance.Password))
.Append(FormatForCsv(con.Inheritance.Port))
.Append(FormatForCsv(con.Inheritance.Protocol))
.Append(FormatForCsv(con.Inheritance.PuttySession))
.Append(FormatForCsv(con.Inheritance.RedirectDiskDrives))
.Append(FormatForCsv(con.Inheritance.RedirectKeys))
.Append(FormatForCsv(con.Inheritance.RedirectPorts))
.Append(FormatForCsv(con.Inheritance.RedirectPrinters))
.Append(FormatForCsv(con.Inheritance.RedirectSmartCards))
.Append(FormatForCsv(con.Inheritance.RedirectSound))
.Append(FormatForCsv(con.Inheritance.Resolution))
.Append(FormatForCsv(con.Inheritance.AutomaticResize))
.Append(FormatForCsv(con.Inheritance.UseConsoleSession))
.Append(FormatForCsv(con.Inheritance.UseCredSsp))
.Append(FormatForCsv(con.Inheritance.RenderingEngine))
.Append(FormatForCsv(con.Inheritance.Username))
.Append(FormatForCsv(con.Inheritance.ICAEncryptionStrength))
.Append(FormatForCsv(con.Inheritance.RDPAuthenticationLevel))
.Append(FormatForCsv(con.Inheritance.LoadBalanceInfo))
.Append(FormatForCsv(con.Inheritance.PreExtApp))
.Append(FormatForCsv(con.Inheritance.PostExtApp))
.Append(FormatForCsv(con.Inheritance.MacAddress))
.Append(FormatForCsv(con.Inheritance.UserField))
.Append(FormatForCsv(con.Inheritance.ExtApp))
.Append(FormatForCsv(con.Inheritance.VNCCompression))
.Append(FormatForCsv(con.Inheritance.VNCEncoding))
.Append(FormatForCsv(con.Inheritance.VNCAuthMode))
.Append(FormatForCsv(con.Inheritance.VNCProxyType))
.Append(FormatForCsv(con.Inheritance.VNCProxyIP))
.Append(FormatForCsv(con.Inheritance.VNCProxyPort))
.Append(FormatForCsv(con.Inheritance.VNCProxyUsername))
.Append(FormatForCsv(con.Inheritance.VNCProxyPassword))
.Append(FormatForCsv(con.Inheritance.VNCColors))
.Append(FormatForCsv(con.Inheritance.VNCSmartSizeMode))
.Append(FormatForCsv(con.Inheritance.VNCViewOnly))
.Append(FormatForCsv(con.Inheritance.RDGatewayUsageMethod))
.Append(FormatForCsv(con.Inheritance.RDGatewayHostname))
.Append(FormatForCsv(con.Inheritance.RDGatewayUseConnectionCredentials))
.Append(FormatForCsv(con.Inheritance.RDGatewayUsername))
.Append(FormatForCsv(con.Inheritance.RDGatewayPassword))
.Append(FormatForCsv(con.Inheritance.RDGatewayDomain))
.Append(FormatForCsv(con.Inheritance.RDPAlertIdleTimeout))
.Append(FormatForCsv(con.Inheritance.RDPMinutesToIdleTimeout))
.Append(FormatForCsv(con.Inheritance.SoundQuality));
}
private string FormatForCsv(object value)
{
var cleanedString = value.ToString().Replace(";", "");
return cleanedString + ";";
}
}
}

View File

@@ -5,8 +5,7 @@ using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
// ReSharper disable once InconsistentNaming
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo,XElement>
@@ -43,7 +42,7 @@ namespace mRemoteNG.Config.Serializers
element.Add(new XAttribute("Name", connectionInfo.Name));
element.Add(new XAttribute("Type", connectionInfo.GetTreeNodeType().ToString()));
if (nodeAsContainer != null)
element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString()));
element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString().ToLowerInvariant()));
element.Add(new XAttribute("Descr", connectionInfo.Description));
element.Add(new XAttribute("Icon", connectionInfo.Icon));
element.Add(new XAttribute("Panel", connectionInfo.Panel));
@@ -66,30 +65,30 @@ namespace mRemoteNG.Config.Serializers
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
element.Add(new XAttribute("Port", connectionInfo.Port));
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString()));
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString()));
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout));
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
element.Add(new XAttribute("Colors", connectionInfo.Colors));
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString()));
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString()));
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString()));
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString()));
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString()));
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString()));
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString()));
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString()));
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString()));
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString()));
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString()));
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString()));
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
@@ -113,7 +112,7 @@ namespace mRemoteNG.Config.Serializers
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString()));
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
@@ -136,117 +135,118 @@ namespace mRemoteNG.Config.Serializers
{
if (_saveFilter.SaveInheritance)
{
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString()));
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString()));
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString()));
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString()));
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString()));
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString()));
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString()));
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString()));
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString()));
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString()));
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString()));
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString()));
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString()));
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString()));
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString()));
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString()));
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString()));
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString()));
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString()));
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString()));
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString()));
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString()));
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString()));
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString()));
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString()));
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString()));
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString()));
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString()));
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString()));
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString()));
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString()));
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString()));
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString()));
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString()));
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString()));
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString()));
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString()));
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString()));
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString()));
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString()));
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString()));
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString()));
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString()));
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString()));
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString()));
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString()));
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString()));
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString()));
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString()));
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString()));
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString()));
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString()));
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString()));
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString()));
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
}
else
{
element.Add(new XAttribute("InheritCacheBitmaps", false.ToString()));
element.Add(new XAttribute("InheritColors", false.ToString()));
element.Add(new XAttribute("InheritDescription", false.ToString()));
element.Add(new XAttribute("InheritDisplayThemes", false.ToString()));
element.Add(new XAttribute("InheritDisplayWallpaper", false.ToString()));
element.Add(new XAttribute("InheritEnableFontSmoothing", false.ToString()));
element.Add(new XAttribute("InheritEnableDesktopComposition", false.ToString()));
element.Add(new XAttribute("InheritDomain", false.ToString()));
element.Add(new XAttribute("InheritIcon", false.ToString()));
element.Add(new XAttribute("InheritPanel", false.ToString()));
element.Add(new XAttribute("InheritPassword", false.ToString()));
element.Add(new XAttribute("InheritPort", false.ToString()));
element.Add(new XAttribute("InheritProtocol", false.ToString()));
element.Add(new XAttribute("InheritPuttySession", false.ToString()));
element.Add(new XAttribute("InheritRedirectDiskDrives", false.ToString()));
element.Add(new XAttribute("InheritRedirectKeys", false.ToString()));
element.Add(new XAttribute("InheritRedirectPorts", false.ToString()));
element.Add(new XAttribute("InheritRedirectPrinters", false.ToString()));
element.Add(new XAttribute("InheritRedirectSmartCards", false.ToString()));
element.Add(new XAttribute("InheritRedirectSound", false.ToString()));
element.Add(new XAttribute("InheritSoundQuality", false.ToString()));
element.Add(new XAttribute("InheritResolution", false.ToString()));
element.Add(new XAttribute("InheritAutomaticResize", false.ToString()));
element.Add(new XAttribute("InheritUseConsoleSession", false.ToString()));
element.Add(new XAttribute("InheritUseCredSsp", false.ToString()));
element.Add(new XAttribute("InheritRenderingEngine", false.ToString()));
element.Add(new XAttribute("InheritUsername", false.ToString()));
element.Add(new XAttribute("InheritICAEncryptionStrength", false.ToString()));
element.Add(new XAttribute("InheritRDPAuthenticationLevel", false.ToString()));
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", false.ToString()));
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", false.ToString()));
element.Add(new XAttribute("InheritLoadBalanceInfo", false.ToString()));
element.Add(new XAttribute("InheritPreExtApp", false.ToString()));
element.Add(new XAttribute("InheritPostExtApp", false.ToString()));
element.Add(new XAttribute("InheritMacAddress", false.ToString()));
element.Add(new XAttribute("InheritUserField", false.ToString()));
element.Add(new XAttribute("InheritExtApp", false.ToString()));
element.Add(new XAttribute("InheritVNCCompression", false.ToString()));
element.Add(new XAttribute("InheritVNCEncoding", false.ToString()));
element.Add(new XAttribute("InheritVNCAuthMode", false.ToString()));
element.Add(new XAttribute("InheritVNCProxyType", false.ToString()));
element.Add(new XAttribute("InheritVNCProxyIP", false.ToString()));
element.Add(new XAttribute("InheritVNCProxyPort", false.ToString()));
element.Add(new XAttribute("InheritVNCProxyUsername", false.ToString()));
element.Add(new XAttribute("InheritVNCProxyPassword", false.ToString()));
element.Add(new XAttribute("InheritVNCColors", false.ToString()));
element.Add(new XAttribute("InheritVNCSmartSizeMode", false.ToString()));
element.Add(new XAttribute("InheritVNCViewOnly", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayUsageMethod", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayHostname", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayUsername", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayPassword", false.ToString()));
element.Add(new XAttribute("InheritRDGatewayDomain", false.ToString()));
var falseString = false.ToString().ToLowerInvariant();
element.Add(new XAttribute("InheritCacheBitmaps", falseString));
element.Add(new XAttribute("InheritColors", falseString));
element.Add(new XAttribute("InheritDescription", falseString));
element.Add(new XAttribute("InheritDisplayThemes", falseString));
element.Add(new XAttribute("InheritDisplayWallpaper", falseString));
element.Add(new XAttribute("InheritEnableFontSmoothing", falseString));
element.Add(new XAttribute("InheritEnableDesktopComposition", falseString));
element.Add(new XAttribute("InheritDomain", falseString));
element.Add(new XAttribute("InheritIcon", falseString));
element.Add(new XAttribute("InheritPanel", falseString));
element.Add(new XAttribute("InheritPassword", falseString));
element.Add(new XAttribute("InheritPort", falseString));
element.Add(new XAttribute("InheritProtocol", falseString));
element.Add(new XAttribute("InheritPuttySession", falseString));
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
element.Add(new XAttribute("InheritRedirectKeys", falseString));
element.Add(new XAttribute("InheritRedirectPorts", falseString));
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
element.Add(new XAttribute("InheritRedirectSound", falseString));
element.Add(new XAttribute("InheritSoundQuality", falseString));
element.Add(new XAttribute("InheritResolution", falseString));
element.Add(new XAttribute("InheritAutomaticResize", falseString));
element.Add(new XAttribute("InheritUseConsoleSession", falseString));
element.Add(new XAttribute("InheritUseCredSsp", falseString));
element.Add(new XAttribute("InheritRenderingEngine", falseString));
element.Add(new XAttribute("InheritUsername", falseString));
element.Add(new XAttribute("InheritICAEncryptionStrength", falseString));
element.Add(new XAttribute("InheritRDPAuthenticationLevel", falseString));
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", falseString));
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", falseString));
element.Add(new XAttribute("InheritLoadBalanceInfo", falseString));
element.Add(new XAttribute("InheritPreExtApp", falseString));
element.Add(new XAttribute("InheritPostExtApp", falseString));
element.Add(new XAttribute("InheritMacAddress", falseString));
element.Add(new XAttribute("InheritUserField", falseString));
element.Add(new XAttribute("InheritExtApp", falseString));
element.Add(new XAttribute("InheritVNCCompression", falseString));
element.Add(new XAttribute("InheritVNCEncoding", falseString));
element.Add(new XAttribute("InheritVNCAuthMode", falseString));
element.Add(new XAttribute("InheritVNCProxyType", falseString));
element.Add(new XAttribute("InheritVNCProxyIP", falseString));
element.Add(new XAttribute("InheritVNCProxyPort", falseString));
element.Add(new XAttribute("InheritVNCProxyUsername", falseString));
element.Add(new XAttribute("InheritVNCProxyPassword", falseString));
element.Add(new XAttribute("InheritVNCColors", falseString));
element.Add(new XAttribute("InheritVNCSmartSizeMode", falseString));
element.Add(new XAttribute("InheritVNCViewOnly", falseString));
element.Add(new XAttribute("InheritRDGatewayUsageMethod", falseString));
element.Add(new XAttribute("InheritRDGatewayHostname", falseString));
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", falseString));
element.Add(new XAttribute("InheritRDGatewayUsername", falseString));
element.Add(new XAttribute("InheritRDGatewayPassword", falseString));
element.Add(new XAttribute("InheritRDGatewayDomain", falseString));
}
}
}

View File

@@ -13,13 +13,12 @@ using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Container;
using mRemoteNG.Messages;
using mRemoteNG.Security;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.TaskDialog;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
{
@@ -71,7 +70,8 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.6)
{
if (rootXmlElement?.Attributes["FullFileEncryption"].Value == "True")
var fullFileEncryptionValue = rootXmlElement?.Attributes["FullFileEncryption"].Value ?? "";
if (bool.Parse(fullFileEncryptionValue))
{
var decryptedContent = _decryptor.Decrypt(rootXmlElement.InnerText);
rootXmlElement.InnerXml = decryptedContent;
@@ -143,10 +143,10 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.6)
{
BlockCipherEngines engine;
Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out engine);
Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, true, out engine);
BlockCipherModes mode;
Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out mode);
Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, true, out mode);
int keyDerivationIterations;
int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out keyDerivationIterations);
@@ -186,7 +186,10 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 0.9)
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
if (_confVersion >= 0.8)
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
{
var expandedValue = xmlNode.Attributes?["Expanded"].Value ?? "";
containerInfo.IsExpanded = bool.Parse(expandedValue);
}
parentContainer.AddChild(containerInfo);
AddNodesFromXmlRecursive(xmlNode, containerInfo);
@@ -204,7 +207,9 @@ namespace mRemoteNG.Config.Serializers
private ConnectionInfo GetConnectionInfoFromXml(XmlNode xmlnode)
{
if (xmlnode.Attributes == null) return null;
var connectionInfo = new ConnectionInfo();
var connectionId = xmlnode.Attributes["Id"]?.Value ?? Guid.NewGuid().ToString();
var connectionInfo = new ConnectionInfo(connectionId);
try
{
@@ -219,7 +224,9 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion < 1.1) //1.0 - 0.1
{
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value) ? RdpResolutions.Fullscreen : RdpResolutions.FitToWindow;
connectionInfo.Resolution = Convert.ToBoolean(xmlnode.Attributes["Fullscreen"].Value)
? RdpProtocol.RDPResolutions.Fullscreen
: RdpProtocol.RDPResolutions.FitToWindow;
}
if (_confVersion <= 2.6) // 0.2 - 2.6
@@ -249,7 +256,7 @@ namespace mRemoteNG.Config.Serializers
}
else
{
connectionInfo.Port = (int)RdpProtocol6.Defaults.Port;
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
connectionInfo.Protocol = ProtocolType.RDP;
}
@@ -257,7 +264,9 @@ namespace mRemoteNG.Config.Serializers
{
if (_confVersion < 0.7)
{
connectionInfo.Port = Convert.ToInt32(Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value) ? xmlnode.Attributes["VNCPort"].Value : xmlnode.Attributes["RDPPort"].Value);
connectionInfo.Port = Convert.ToInt32(Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value)
? xmlnode.Attributes["VNCPort"].Value
: xmlnode.Attributes["RDPPort"].Value);
}
connectionInfo.UseConsoleSession = bool.Parse(xmlnode.Attributes["ConnectToConsole"].Value);
@@ -269,7 +278,7 @@ namespace mRemoteNG.Config.Serializers
if (Convert.ToBoolean(xmlnode.Attributes["UseVNC"].Value))
connectionInfo.Port = (int)ProtocolVNC.Defaults.Port;
else
connectionInfo.Port = (int)RdpProtocol6.Defaults.Port;
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
}
connectionInfo.UseConsoleSession = false;
}
@@ -291,7 +300,9 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 0.7)
{
connectionInfo.Protocol = (ProtocolType)MiscTools.StringToEnum(typeof(ProtocolType), xmlnode.Attributes["Protocol"].Value);
ProtocolType protocolType;
Enum.TryParse(xmlnode.Attributes["Protocol"].Value, true, out protocolType);
connectionInfo.Protocol = protocolType;
connectionInfo.Port = Convert.ToInt32(xmlnode.Attributes["Port"].Value);
}
@@ -307,34 +318,34 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.3)
{
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));
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), xmlnode.Attributes["Colors"].Value, true);
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), xmlnode.Attributes["Resolution"].Value, true);
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), xmlnode.Attributes["RedirectSound"].Value, true);
}
else
{
switch (Convert.ToInt32(xmlnode.Attributes["Colors"].Value))
{
case 0:
connectionInfo.Colors = RdpColors.Colors256;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors256;
break;
case 1:
connectionInfo.Colors = RdpColors.Colors16Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors16Bit;
break;
case 2:
connectionInfo.Colors = RdpColors.Colors24Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors24Bit;
break;
case 3:
connectionInfo.Colors = RdpColors.Colors32Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors32Bit;
break;
// ReSharper disable once RedundantCaseLabel
case 4:
default:
connectionInfo.Colors = RdpColors.Colors15Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors15Bit;
break;
}
connectionInfo.RedirectSound = (RdpSounds)Convert.ToInt32(xmlnode.Attributes["RedirectSound"].Value);
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Convert.ToInt32(xmlnode.Attributes["RedirectSound"].Value);
}
if (_confVersion >= 1.3)
@@ -385,7 +396,7 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.6)
{
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)MiscTools.StringToEnum(typeof(IcaProtocol.EncryptionStrength), xmlnode.Attributes["ICAEncryptionStrength"].Value);
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength), xmlnode.Attributes["ICAEncryptionStrength"].Value, true);
connectionInfo.Inheritance.ICAEncryptionStrength = bool.Parse(xmlnode.Attributes["InheritICAEncryptionStrength"].Value);
connectionInfo.PreExtApp = xmlnode.Attributes["PreExtApp"].Value;
connectionInfo.PostExtApp = xmlnode.Attributes["PostExtApp"].Value;
@@ -395,16 +406,16 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.7)
{
connectionInfo.VNCCompression = (ProtocolVNC.Compression)MiscTools.StringToEnum(typeof(ProtocolVNC.Compression), xmlnode.Attributes["VNCCompression"].Value);
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)MiscTools.StringToEnum(typeof(ProtocolVNC.Encoding), Convert.ToString(xmlnode.Attributes["VNCEncoding"].Value));
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)MiscTools.StringToEnum(typeof(ProtocolVNC.AuthMode), xmlnode.Attributes["VNCAuthMode"].Value);
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)MiscTools.StringToEnum(typeof(ProtocolVNC.ProxyType), xmlnode.Attributes["VNCProxyType"].Value);
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), xmlnode.Attributes["VNCCompression"].Value, true);
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), xmlnode.Attributes["VNCEncoding"].Value, true);
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), xmlnode.Attributes["VNCAuthMode"].Value, true);
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), xmlnode.Attributes["VNCProxyType"].Value, true);
connectionInfo.VNCProxyIP = xmlnode.Attributes["VNCProxyIP"].Value;
connectionInfo.VNCProxyPort = Convert.ToInt32(xmlnode.Attributes["VNCProxyPort"].Value);
connectionInfo.VNCProxyUsername = xmlnode.Attributes["VNCProxyUsername"].Value;
connectionInfo.VNCProxyPassword = _decryptor.Decrypt(xmlnode.Attributes["VNCProxyPassword"].Value);
connectionInfo.VNCColors = (ProtocolVNC.Colors)MiscTools.StringToEnum(typeof(ProtocolVNC.Colors), xmlnode.Attributes["VNCColors"].Value);
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)MiscTools.StringToEnum(typeof(ProtocolVNC.SmartSizeMode), xmlnode.Attributes["VNCSmartSizeMode"].Value);
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), xmlnode.Attributes["VNCColors"].Value, true);
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), xmlnode.Attributes["VNCSmartSizeMode"].Value, true);
connectionInfo.VNCViewOnly = bool.Parse(xmlnode.Attributes["VNCViewOnly"].Value);
connectionInfo.Inheritance.VNCCompression = bool.Parse(xmlnode.Attributes["InheritVNCCompression"].Value);
connectionInfo.Inheritance.VNCEncoding = bool.Parse(xmlnode.Attributes["InheritVNCEncoding"].Value);
@@ -421,13 +432,13 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 1.8)
{
connectionInfo.RDPAuthenticationLevel = (RdpAuthenticationLevel)MiscTools.StringToEnum(typeof(RdpAuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value);
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), xmlnode.Attributes["RDPAuthenticationLevel"].Value, true);
connectionInfo.Inheritance.RDPAuthenticationLevel = bool.Parse(xmlnode.Attributes["InheritRDPAuthenticationLevel"].Value);
}
if (_confVersion >= 1.9)
{
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)MiscTools.StringToEnum(typeof(HTTPBase.RenderingEngine), xmlnode.Attributes["RenderingEngine"].Value);
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), xmlnode.Attributes["RenderingEngine"].Value, true);
connectionInfo.MacAddress = xmlnode.Attributes["MacAddress"].Value;
connectionInfo.Inheritance.RenderingEngine = bool.Parse(xmlnode.Attributes["InheritRenderingEngine"].Value);
connectionInfo.Inheritance.MacAddress = bool.Parse(xmlnode.Attributes["InheritMacAddress"].Value);
@@ -448,9 +459,9 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.2)
{
// Get settings
connectionInfo.RDGatewayUsageMethod = (RDGatewayUsageMethod)MiscTools.StringToEnum(typeof(RDGatewayUsageMethod), Convert.ToString(xmlnode.Attributes["RDGatewayUsageMethod"].Value));
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), xmlnode.Attributes["RDGatewayUsageMethod"].Value, true);
connectionInfo.RDGatewayHostname = xmlnode.Attributes["RDGatewayHostname"].Value;
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)MiscTools.StringToEnum(typeof(RDGatewayUseConnectionCredentials), Convert.ToString(xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value));
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), xmlnode.Attributes["RDGatewayUseConnectionCredentials"].Value, true);
connectionInfo.RDGatewayUsername = xmlnode.Attributes["RDGatewayUsername"].Value;
connectionInfo.RDGatewayPassword = _decryptor.Decrypt(Convert.ToString(xmlnode.Attributes["RDGatewayPassword"].Value));
connectionInfo.RDGatewayDomain = xmlnode.Attributes["RDGatewayDomain"].Value;
@@ -491,8 +502,7 @@ namespace mRemoteNG.Config.Serializers
if (_confVersion >= 2.6)
{
connectionInfo.ConstantID = xmlnode.Attributes["Id"]?.Value ?? connectionInfo.ConstantID;
connectionInfo.SoundQuality = (RdpSoundQuality)MiscTools.StringToEnum(typeof(RdpSoundQuality), Convert.ToString(xmlnode.Attributes["SoundQuality"].Value));
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), xmlnode.Attributes["SoundQuality"].Value, true);
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

@@ -8,8 +8,7 @@ using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
public class XmlConnectionsDocumentCompiler
{

View File

@@ -2,8 +2,7 @@
using System.Xml.Linq;
using mRemoteNG.Security;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
public class XmlConnectionsDocumentEncryptor
{

View File

@@ -10,7 +10,7 @@ using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel,string>, ISerializer<ConnectionInfo, string>
{

View File

@@ -2,19 +2,21 @@
using mRemoteNG.Security;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
namespace mRemoteNG.Config.Serializers.Xml
{
public class XmlRootNodeSerializer
public class XmlRootNodeSerializer
{
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool fullFileEncryption = false)
{
var element = new XElement("Connections");
XNamespace xmlNamespace = "http://mremoteng.org";
var element = new XElement(xmlNamespace + "Connections");
element.Add(new XAttribute(XNamespace.Xmlns+"mrng", xmlNamespace));
element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
element.Add(new XAttribute(XName.Get("Export"), "false"));
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString()));
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant()));
element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider));
element.Add(new XAttribute(XName.Get("ConfVersion"), "2.6"));
return element;

View File

@@ -46,14 +46,16 @@ namespace mRemoteNG.Config.Serializers
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
{
var connectionInfo = new ConnectionInfo();
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
var connectionInfo = new ConnectionInfo(connectionId);
PopulateConnectionInfoFromDatarow(row, connectionInfo);
return connectionInfo;
}
private ContainerInfo DeserializeContainerInfo(DataRow row)
{
var containerInfo = new ContainerInfo();
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
var containerInfo = new ContainerInfo(containerId);
PopulateConnectionInfoFromDatarow(row, containerInfo);
return containerInfo;
}
@@ -61,7 +63,6 @@ namespace mRemoteNG.Config.Serializers
private void PopulateConnectionInfoFromDatarow(DataRow dataRow, ConnectionInfo connectionInfo)
{
connectionInfo.Name = (string)dataRow["Name"];
connectionInfo.ConstantID = (string)dataRow["ConstantID"];
// This throws a NPE - Parent is a connectionInfo object which will be null at this point.
// The Parent object is linked properly later in CreateNodeHierarchy()
@@ -85,12 +86,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 = (RdpAuthenticationLevel)Enum.Parse(typeof(RdpAuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
connectionInfo.RDPAlertIdleTimeout = (bool)dataRow["RDPAlertIdleTimeout"];
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
connectionInfo.Colors = (RdpColors)Enum.Parse(typeof(RdpColors) ,(string)dataRow["Colors"]);
connectionInfo.Resolution = (RdpResolutions)Enum.Parse(typeof(RdpResolutions), (string)dataRow["Resolution"]);
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors) ,(string)dataRow["Colors"]);
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), (string)dataRow["Resolution"]);
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
@@ -101,8 +102,8 @@ namespace mRemoteNG.Config.Serializers
connectionInfo.RedirectPorts = (bool)dataRow["RedirectPorts"];
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
connectionInfo.RedirectSound = (RdpSounds)Enum.Parse(typeof(RdpSounds), (string)dataRow["RedirectSound"]);
connectionInfo.SoundQuality = (RdpSoundQuality)Enum.Parse(typeof(RdpSoundQuality), (string)dataRow["SoundQuality"]);
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), (string)dataRow["SoundQuality"]);
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
connectionInfo.PleaseConnect = (bool)dataRow["Connected"];
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
@@ -121,9 +122,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 = (RDGatewayUsageMethod)Enum.Parse(typeof(RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
connectionInfo.RDGatewayPassword = (string)dataRow["RDGatewayPassword"];
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
@@ -187,7 +188,7 @@ namespace mRemoteNG.Config.Serializers
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList, DataTable dataTable)
{
var connectionTreeModel = new ConnectionTreeModel();
var rootNode = new RootNodeInfo(RootNodeType.Connection) {ConstantID = "0"};
var rootNode = new RootNodeInfo(RootNodeType.Connection, "0");
connectionTreeModel.AddRootNode(rootNode);
foreach (DataRow row in dataTable.Rows)

View File

@@ -1,238 +0,0 @@
using System;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Credential;
using mRemoteNG.Security;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Config.Serializers
{
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
{
private string _csv = "";
private ConnectionInfo _serializationTarget;
private readonly SaveFilter _saveFilter;
private readonly ICredentialRepositoryList _credentialRepositoryList;
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
{
if (saveFilter == null)
throw new ArgumentNullException(nameof(saveFilter));
if (credentialRepositoryList == null)
throw new ArgumentNullException(nameof(credentialRepositoryList));
_saveFilter = saveFilter;
_credentialRepositoryList = credentialRepositoryList;
}
public string Serialize(ConnectionTreeModel connectionTreeModel)
{
if (connectionTreeModel == null)
throw new ArgumentNullException(nameof(connectionTreeModel));
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
return Serialize(rootNode);
}
public string Serialize(ConnectionInfo serializationTarget)
{
if (serializationTarget == null)
throw new ArgumentNullException(nameof(serializationTarget));
_csv = "";
_serializationTarget = serializationTarget;
WriteCsvHeader();
SerializeNodesRecursive(serializationTarget);
return _csv;
}
private void WriteCsvHeader()
{
var csvHeader = string.Empty;
csvHeader += "Name;Folder;Description;Icon;Panel;";
if (_saveFilter.SaveUsername)
csvHeader += "Username;";
if (_saveFilter.SavePassword)
csvHeader += "Password;";
if (_saveFilter.SaveDomain)
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;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality";
_csv += csvHeader;
}
private void SerializeNodesRecursive(ConnectionInfo node)
{
var nodeAsContainer = node as ContainerInfo;
if (nodeAsContainer != null)
{
foreach (var child in nodeAsContainer.Children)
{
var info = child as ContainerInfo;
if (info != null)
SerializeNodesRecursive(info);
else
SerializeConnectionInfo(child);
}
}
else
SerializeConnectionInfo(node);
}
private void SerializeConnectionInfo(ConnectionInfo con)
{
var csvLine = Environment.NewLine;
csvLine += CleanStringForCsv(con.Name) + ";" +
CleanStringForCsv(GetNodePath(con)) + ";" +
CleanStringForCsv(con.Description) + ";" +
CleanStringForCsv(con.Icon) + ";" +
CleanStringForCsv(con.Panel) + ";";
if (_saveFilter.SaveUsername)
csvLine += CleanStringForCsv(con.Username) + ";";
if (_saveFilter.SavePassword)
csvLine += CleanStringForCsv(con.Password) + ";";
if (_saveFilter.SaveDomain)
csvLine += CleanStringForCsv(con.Domain) + ";";
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)
{
csvLine += con.Inheritance.CacheBitmaps + ";" +
con.Inheritance.Colors + ";" +
con.Inheritance.Description + ";" +
con.Inheritance.DisplayThemes + ";" +
con.Inheritance.DisplayWallpaper + ";" +
con.Inheritance.EnableFontSmoothing + ";" +
con.Inheritance.EnableDesktopComposition + ";" +
con.Inheritance.Domain + ";" +
con.Inheritance.Icon + ";" +
con.Inheritance.Panel + ";" +
con.Inheritance.Password + ";" +
con.Inheritance.Port + ";" +
con.Inheritance.Protocol + ";" +
con.Inheritance.PuttySession + ";" +
con.Inheritance.RedirectDiskDrives + ";" +
con.Inheritance.RedirectKeys + ";" +
con.Inheritance.RedirectPorts + ";" +
con.Inheritance.RedirectPrinters + ";" +
con.Inheritance.RedirectSmartCards + ";" +
con.Inheritance.RedirectSound + ";" +
con.Inheritance.Resolution + ";" +
con.Inheritance.AutomaticResize + ";" +
con.Inheritance.UseConsoleSession + ";" +
con.Inheritance.UseCredSsp + ";" +
con.Inheritance.RenderingEngine + ";" +
con.Inheritance.Username + ";" +
con.Inheritance.ICAEncryptionStrength + ";" +
con.Inheritance.RDPAuthenticationLevel + ";" +
con.Inheritance.LoadBalanceInfo + ";" +
con.Inheritance.PreExtApp + ";" +
con.Inheritance.PostExtApp + ";" +
con.Inheritance.MacAddress + ";" +
con.Inheritance.UserField + ";" +
con.Inheritance.ExtApp + ";" +
con.Inheritance.VNCCompression + ";" +
con.Inheritance.VNCEncoding + ";" +
con.Inheritance.VNCAuthMode + ";" +
con.Inheritance.VNCProxyType + ";" +
con.Inheritance.VNCProxyIP + ";" +
con.Inheritance.VNCProxyPort + ";" +
con.Inheritance.VNCProxyUsername + ";" +
con.Inheritance.VNCProxyPassword + ";" +
con.Inheritance.VNCColors + ";" +
con.Inheritance.VNCSmartSizeMode + ";" +
con.Inheritance.VNCViewOnly + ";" +
con.Inheritance.RDGatewayUsageMethod + ";" +
con.Inheritance.RDGatewayHostname + ";" +
con.Inheritance.RDGatewayUseConnectionCredentials + ";" +
con.Inheritance.RDGatewayUsername + ";" +
con.Inheritance.RDGatewayPassword + ";" +
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 currentItem = connectionInfo;
while (currentItem != _serializationTarget)
{
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 = RdpColors.Colors256;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors256;
break;
case "15":
connectionInfo.Colors = RdpColors.Colors15Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors15Bit;
break;
case "16":
connectionInfo.Colors = RdpColors.Colors16Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors16Bit;
break;
case "24":
connectionInfo.Colors = RdpColors.Colors24Bit;
connectionInfo.Colors = RdpProtocol.RDPColors.Colors24Bit;
break;
case "32":
connectionInfo.Colors = RdpColors.Colors32Bit;
connectionInfo.Colors = RdpProtocol.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" ? RdpResolutions.Fullscreen : RdpResolutions.FitToWindow;
connectionInfo.Resolution = value == "2" ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.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 = RdpSounds.BringToThisComputer;
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.BringToThisComputer;
break;
case "1":
connectionInfo.RedirectSound = RdpSounds.LeaveAtRemoteComputer;
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.LeaveAtRemoteComputer;
break;
case "2":
connectionInfo.RedirectSound = RdpSounds.DoNotPlay;
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
break;
}
break;

View File

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

View File

@@ -26,29 +26,28 @@ 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 RdpAuthenticationLevel _rdpAuthenticationLevel;
private RdpProtocol.AuthenticationLevel _rdpAuthenticationLevel;
private int _rdpMinutesToIdleTimeout;
private bool _rdpAlertIdleTimeout;
private string _loadBalanceInfo;
private HTTPBase.RenderingEngine _renderingEngine;
private bool _useCredSsp;
private RDGatewayUsageMethod _rdGatewayUsageMethod;
private RdpProtocol.RDGatewayUsageMethod _rdGatewayUsageMethod;
private string _rdGatewayHostname;
private RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private RdpProtocol.RDGatewayUseConnectionCredentials _rdGatewayUseConnectionCredentials;
private string _rdGatewayUsername;
private string _rdGatewayPassword;
private string _rdGatewayDomain;
private RdpResolutions _resolution;
private RdpProtocol.RDPResolutions _resolution;
private bool _automaticResize;
private RdpColors _colors;
private RdpProtocol.RDPColors _colors;
private bool _cacheBitmaps;
private bool _displayWallpaper;
private bool _displayThemes;
@@ -60,8 +59,8 @@ namespace mRemoteNG.Connection
private bool _redirectPrinters;
private bool _redirectPorts;
private bool _redirectSmartCards;
private RdpSounds _redirectSound;
private RdpSoundQuality _soundQuality;
private RdpProtocol.RDPSounds _redirectSound;
private RdpProtocol.RDPSoundQuality _soundQuality;
private string _preExtApp;
private string _postExtApp;
@@ -171,16 +170,6 @@ 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"),
@@ -234,7 +223,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameAuthenticationLevel"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAuthenticationLevel"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpAuthenticationLevel RDPAuthenticationLevel
public RdpProtocol.AuthenticationLevel RDPAuthenticationLevel
{
get { return GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel); }
set { SetField(ref _rdpAuthenticationLevel, value, "RDPAuthenticationLevel"); }
@@ -299,7 +288,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUsageMethod"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsageMethod"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RDGatewayUsageMethod RDGatewayUsageMethod
public RdpProtocol.RDGatewayUsageMethod RDGatewayUsageMethod
{
get { return GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod); }
set { SetField(ref _rdGatewayUsageMethod, value, "RDGatewayUsageMethod"); }
@@ -318,7 +307,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRDGatewayUseConnectionCredentials"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUseConnectionCredentials"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
public RdpProtocol.RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
{
get { return GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials); }
set { SetField(ref _rdGatewayUseConnectionCredentials, value, "RDGatewayUseConnectionCredentials"); }
@@ -358,7 +347,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameResolution"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionResolution"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpResolutions Resolution
public RdpProtocol.RDPResolutions Resolution
{
get { return GetPropertyValue("Resolution", _resolution); }
set { SetField(ref _resolution, value, "Resolution"); }
@@ -378,7 +367,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameColors"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionColors"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpColors Colors
public RdpProtocol.RDPColors Colors
{
get { return GetPropertyValue("Colors", _colors); }
set { SetField(ref _colors, value, "Colors"); }
@@ -490,7 +479,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectSounds"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectSounds"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpSounds RedirectSound
public RdpProtocol.RDPSounds RedirectSound
{
get { return GetPropertyValue("RedirectSound", _redirectSound); }
set { SetField(ref _redirectSound, value, "RedirectSound"); }
@@ -500,7 +489,7 @@ namespace mRemoteNG.Connection
LocalizedAttributes.LocalizedDisplayName("strPropertyNameSoundQuality"),
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionSoundQuality"),
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
public RdpSoundQuality SoundQuality
public RdpProtocol.RDPSoundQuality SoundQuality
{
get { return GetPropertyValue("SoundQuality", _soundQuality); }
set { SetField(ref _soundQuality, value, "SoundQuality"); }
@@ -509,7 +498,7 @@ namespace mRemoteNG.Connection
#region Misc
[Browsable(false)]
public string ConstantID { get; set; }
public string ConstantID { get; /*set;*/ }
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
LocalizedAttributes.LocalizedDisplayName("strPropertyNameExternalToolBefore"),
@@ -669,6 +658,11 @@ namespace mRemoteNG.Connection
#endregion
#endregion
protected AbstractConnectionRecord(string uniqueId)
{
ConstantID = uniqueId.ThrowIfNullOrEmpty(nameof(uniqueId));
}
protected virtual TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
{
return (TPropertyType)GetType().GetProperty(propertyName).GetValue(this, null);

View File

@@ -14,9 +14,7 @@ using mRemoteNG.Connection.Protocol.SSH;
using mRemoteNG.Connection.Protocol.Telnet;
using mRemoteNG.Connection.Protocol.VNC;
using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.Connection
@@ -32,7 +30,7 @@ namespace mRemoteNG.Connection
public ProtocolList OpenConnections { get; protected set; }
[Browsable(false)]
public bool IsContainer { get; set; }
public virtual bool IsContainer { get; set; }
[Browsable(false)]
public bool IsDefault { get; set; }
@@ -52,7 +50,14 @@ namespace mRemoteNG.Connection
#endregion
#region Constructors
public ConnectionInfo()
public ConnectionInfo()
: this(Guid.NewGuid().ToString())
{
}
public ConnectionInfo(string uniqueId)
: base(uniqueId)
{
SetTreeDisplayDefaults();
SetConnectionDefaults();
@@ -65,12 +70,6 @@ namespace mRemoteNG.Connection
SetNonBrowsablePropertiesDefaults();
SetDefaults();
}
public ConnectionInfo(ContainerInfo parent) : this()
{
IsContainer = true;
parent.AddChild(this);
}
#endregion
#region Public Methods
@@ -78,7 +77,6 @@ namespace mRemoteNG.Connection
{
var newConnectionInfo = new ConnectionInfo();
newConnectionInfo.CopyFrom(this);
newConnectionInfo.ConstantID = MiscTools.CreateConstantID();
newConnectionInfo.Inheritance = Inheritance.Clone();
return newConnectionInfo;
}
@@ -128,19 +126,22 @@ namespace mRemoteNG.Connection
return filteredProperties;
}
public virtual IEnumerable<PropertyInfo> GetSerializableProperties()
{
var excludedProperties = new[] { "Parent", "Name", "Hostname", "Port", "Inheritance", "OpenConnections",
"IsContainer", "IsDefault", "PositionID", "ConstantID", "TreeNode", "IsQuickConnect", "PleaseConnect" };
return GetProperties(excludedProperties);
}
public virtual void SetParent(ContainerInfo newParent)
{
RemoveParent();
newParent?.AddChild(this);
if (newParent is RootNodeInfo)
Inheritance.DisableInheritance();
}
public void RemoveParent()
{
if (Parent is RootNodeInfo)
Inheritance.EnableInheritance();
Parent?.RemoveChild(this);
}
@@ -222,7 +223,7 @@ namespace mRemoteNG.Connection
switch (protocol)
{
case ProtocolType.RDP:
return (int)RdpProtocol6.Defaults.Port;
return (int)RdpProtocol.Defaults.Port;
case ProtocolType.VNC:
return (int)ProtocolVNC.Defaults.Port;
case ProtocolType.SSH1:
@@ -269,13 +270,12 @@ namespace mRemoteNG.Connection
private void SetProtocolDefaults()
{
Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), Settings.Default.ConDefaultProtocol);
RdpProtocolVersion = RdpVersionEnum.Rdc8;
ExtApp = Settings.Default.ConDefaultExtApp;
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 = (RdpAuthenticationLevel) Enum.Parse(typeof(RdpAuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel) Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), Settings.Default.ConDefaultRDPAuthenticationLevel);
RDPMinutesToIdleTimeout = Settings.Default.ConDefaultRDPMinutesToIdleTimeout;
RDPAlertIdleTimeout = Settings.Default.ConDefaultRDPAlertIdleTimeout;
LoadBalanceInfo = Settings.Default.ConDefaultLoadBalanceInfo;
@@ -285,9 +285,9 @@ namespace mRemoteNG.Connection
private void SetRdGatewayDefaults()
{
RDGatewayUsageMethod = (RDGatewayUsageMethod) Enum.Parse(typeof(RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod) Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), Settings.Default.ConDefaultRDGatewayUsageMethod);
RDGatewayHostname = Settings.Default.ConDefaultRDGatewayHostname;
RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials) Enum.Parse(typeof(RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials);
RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials) Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), Settings.Default.ConDefaultRDGatewayUseConnectionCredentials);
RDGatewayUsername = Settings.Default.ConDefaultRDGatewayUsername;
RDGatewayPassword = Settings.Default.ConDefaultRDGatewayPassword;
RDGatewayDomain = Settings.Default.ConDefaultRDGatewayDomain;
@@ -295,9 +295,9 @@ namespace mRemoteNG.Connection
private void SetAppearanceDefaults()
{
Resolution = (RdpResolutions) Enum.Parse(typeof(RdpResolutions), Settings.Default.ConDefaultResolution);
Resolution = (RdpProtocol.RDPResolutions) Enum.Parse(typeof(RdpProtocol.RDPResolutions), Settings.Default.ConDefaultResolution);
AutomaticResize = Settings.Default.ConDefaultAutomaticResize;
Colors = (RdpColors) Enum.Parse(typeof(RdpColors), Settings.Default.ConDefaultColors);
Colors = (RdpProtocol.RDPColors) Enum.Parse(typeof(RdpProtocol.RDPColors), Settings.Default.ConDefaultColors);
CacheBitmaps = Settings.Default.ConDefaultCacheBitmaps;
DisplayWallpaper = Settings.Default.ConDefaultDisplayWallpaper;
DisplayThemes = Settings.Default.ConDefaultDisplayThemes;
@@ -312,13 +312,12 @@ namespace mRemoteNG.Connection
RedirectPrinters = Settings.Default.ConDefaultRedirectPrinters;
RedirectPorts = Settings.Default.ConDefaultRedirectPorts;
RedirectSmartCards = Settings.Default.ConDefaultRedirectSmartCards;
RedirectSound = (RdpSounds) Enum.Parse(typeof(RdpSounds), Settings.Default.ConDefaultRedirectSound);
SoundQuality = (RdpSoundQuality)Enum.Parse(typeof(RdpSoundQuality), Settings.Default.ConDefaultSoundQuality);
RedirectSound = (RdpProtocol.RDPSounds) Enum.Parse(typeof(RdpProtocol.RDPSounds), Settings.Default.ConDefaultRedirectSound);
SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), Settings.Default.ConDefaultSoundQuality);
}
private void SetMiscDefaults()
{
ConstantID = MiscTools.CreateConstantID();
PreExtApp = Settings.Default.ConDefaultPreExtApp;
PostExtApp = Settings.Default.ConDefaultPostExtApp;
MacAddress = Settings.Default.ConDefaultMacAddress;

View File

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

View File

@@ -227,7 +227,7 @@ namespace mRemoteNG.Connection
public event EventHandler<ConnectionsLoadedEventArgs> ConnectionsLoaded;
public event EventHandler<ConnectionsSavedEventArgs> ConnectionsSaved;
private void RaiseConnectionsLoadedEvent(Maybe<ConnectionTreeModel> previousTreeModel, ConnectionTreeModel newTreeModel,
private void RaiseConnectionsLoadedEvent(Optional<ConnectionTreeModel> previousTreeModel, ConnectionTreeModel newTreeModel,
bool previousSourceWasDatabase, bool newSourceIsDatabase,
string newSourcePath)
{

View File

@@ -1,35 +1,39 @@
using System;
using System.ComponentModel;
using System.Configuration;
using mRemoteNG.App;
namespace mRemoteNG.Connection
{
public class DefaultConnectionInfo : ConnectionInfo
public class DefaultConnectionInfo : ConnectionInfo
{
public static DefaultConnectionInfo Instance { get; } = new DefaultConnectionInfo();
private readonly string[] _excludedProperties = { "Parent", "Name", "Hostname", "Port", "Inheritance",
"OpenConnections", "IsContainer", "IsDefault", "PositionID", "ConstantID", "TreeNode", "IsQuickConnect", "PleaseConnect" };
private DefaultConnectionInfo()
{
IsDefault = true;
Inheritance = DefaultConnectionInheritance.Instance;
}
public void LoadFrom<TSource>(TSource sourceInstance, Func<string, string> propertyNameMutator = null)
{
if (propertyNameMutator == null) propertyNameMutator = a => a;
var connectionProperties = GetProperties(_excludedProperties);
if (propertyNameMutator == null)
propertyNameMutator = a => a;
var connectionProperties = GetSerializableProperties();
foreach (var property in connectionProperties)
{
try
{
var propertyFromSource = typeof(TSource).GetProperty(propertyNameMutator(property.Name));
if (propertyFromSource == null) continue;
var valueFromSource = propertyFromSource.GetValue(sourceInstance, null);
var typeConverter = TypeDescriptor.GetConverter(property.PropertyType);
if (typeConverter.CanConvertFrom(valueFromSource.GetType()))
property.SetValue(Instance, typeConverter.ConvertFrom(valueFromSource), null);
var expectedPropertyName = propertyNameMutator(property.Name);
var propertyFromSource = typeof(TSource).GetProperty(expectedPropertyName);
if (propertyFromSource == null)
throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found.");
var valueFromSource = propertyFromSource.GetValue(sourceInstance, null);
var value = Convert.ChangeType(valueFromSource, property.PropertyType);
property.SetValue(Instance, value, null);
}
catch (Exception ex)
{
@@ -40,19 +44,25 @@ namespace mRemoteNG.Connection
public void SaveTo<TDestination>(TDestination destinationInstance, Func<string, string> propertyNameMutator = null)
{
if (propertyNameMutator == null) propertyNameMutator = (a) => a;
var inheritanceProperties = GetProperties(_excludedProperties);
foreach (var property in inheritanceProperties)
if (propertyNameMutator == null)
propertyNameMutator = (a) => a;
var connectionProperties = GetSerializableProperties();
foreach (var property in connectionProperties)
{
try
{
var propertyFromDestination = typeof(TDestination).GetProperty(propertyNameMutator(property.Name));
var localValue = property.GetValue(Instance, null);
var typeConverter = TypeDescriptor.GetConverter(property.PropertyType);
if (propertyFromDestination != null && !typeConverter.CanConvertTo(propertyFromDestination.PropertyType)) continue;
if (propertyFromDestination == null) continue;
var convertedValue = typeConverter.ConvertTo(localValue, propertyFromDestination.PropertyType);
propertyFromDestination.SetValue(destinationInstance, convertedValue, null);
var expectedPropertyName = propertyNameMutator(property.Name);
var propertyFromDestination = typeof(TDestination).GetProperty(expectedPropertyName);
if (propertyFromDestination == null)
throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found.");
// ensure value is of correct type
var value = Convert.ChangeType(property.GetValue(Instance, null), propertyFromDestination.PropertyType);
propertyFromDestination.SetValue(destinationInstance, value, null);
}
catch (Exception ex)
{

View File

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

View File

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

View File

@@ -9,19 +9,20 @@ 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(ConnectionInfo connectionInfo, RenderingEngine renderingEngine)
: base(connectionInfo)
{
protected HTTPBase(RenderingEngine RenderingEngine)
{
try
{
if (renderingEngine == RenderingEngine.Gecko)
if (RenderingEngine == RenderingEngine.Gecko)
{
if(!Xpcom.IsInitialized)
Xpcom.Initialize("Firefox");
@@ -57,7 +58,7 @@ namespace mRemoteNG.Connection.Protocol.Http
{
wBrowser = Control;
if (Info.RenderingEngine == RenderingEngine.Gecko)
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
{
var GeckoBrowser = (GeckoWebBrowser) wBrowser;
if (GeckoBrowser != null)
@@ -95,7 +96,7 @@ namespace mRemoteNG.Connection.Protocol.Http
{
try
{
var strHost = Info.Hostname;
var strHost = InterfaceControl.Info.Hostname;
/*
* Commenting out since this codes doesn't actually do anything at this time...
* Possibly related to MR-221 and/or MR-533 ????
@@ -107,7 +108,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 (Info.Port != defaultPort)
if (InterfaceControl.Info.Port != defaultPort)
{
if (strHost.EndsWith("/"))
{
@@ -119,13 +120,13 @@ namespace mRemoteNG.Connection.Protocol.Http
strHost = httpOrS + "://" + strHost;
}
if (Info.RenderingEngine == RenderingEngine.Gecko)
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
{
((GeckoWebBrowser)wBrowser).Navigate(strHost + ":" + Info.Port);
((GeckoWebBrowser)wBrowser).Navigate(strHost + ":" + InterfaceControl.Info.Port);
}
else
{
((WebBrowser)wBrowser).Navigate(strHost + ":" + Info.Port);
((WebBrowser)wBrowser).Navigate(strHost + ":" + InterfaceControl.Info.Port);
}
}
else
@@ -135,7 +136,7 @@ namespace mRemoteNG.Connection.Protocol.Http
strHost = httpOrS + "://" + strHost;
}
if (Info.RenderingEngine == RenderingEngine.Gecko)
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
{
((GeckoWebBrowser)wBrowser).Navigate(strHost);
}
@@ -180,7 +181,7 @@ namespace mRemoteNG.Connection.Protocol.Http
if (tabP == null) return;
string shortTitle;
if (Info.RenderingEngine == RenderingEngine.Gecko)
if (InterfaceControl.Info.RenderingEngine == RenderingEngine.Gecko)
{
if (((GeckoWebBrowser) wBrowser).DocumentTitle.Length >= 15)
{
@@ -228,7 +229,7 @@ namespace mRemoteNG.Connection.Protocol.Http
if (tabP == null) return;
string shortTitle;
if (Info.RenderingEngine == RenderingEngine.Gecko)
if (InterfaceControl.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(ConnectionInfo connectionInfo, RenderingEngine renderingEngine)
: base(connectionInfo, renderingEngine)
public ProtocolHTTPS(RenderingEngine RenderingEngine) : base(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(ConnectionInfo connectionInfo)
: base(connectionInfo)
public IcaProtocol()
{
try
{
@@ -39,6 +39,7 @@ namespace mRemoteNG.Connection.Protocol.ICA
try
{
_icaClient = (AxICAClient)Control;
_info = InterfaceControl.Info;
_icaClient.CreateControl();
while (!_icaClient.Created)
@@ -47,7 +48,7 @@ namespace mRemoteNG.Connection.Protocol.ICA
Application.DoEvents();
}
_icaClient.Address = Info.Hostname;
_icaClient.Address = _info.Hostname;
SetCredentials();
SetResolution();
SetColors();
@@ -77,8 +78,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)
@@ -116,9 +117,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))
{
@@ -186,22 +187,22 @@ namespace mRemoteNG.Connection.Protocol.ICA
return;
}
if (Info.Resolution == RdpResolutions.FitToWindow)
if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.FitToWindow)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0);
}
else if (Info.Resolution == RdpResolutions.SmartSize)
else if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.SmartSize)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0);
}
else if (Info.Resolution == RdpResolutions.Fullscreen)
else if (InterfaceControl.Info.Resolution == RdpProtocol.RDPResolutions.Fullscreen)
{
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, Screen.FromControl(_frmMain).Bounds.Width, Screen.FromControl(_frmMain).Bounds.Height, 0);
_icaClient.FullScreenWindow();
}
else
{
var resolution = Info.Resolution.GetResolutionRectangle();
var resolution = RdpProtocol.GetResolutionRectangle(_info.Resolution);
_icaClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, resolution.Width, resolution.Height, 0);
}
}
@@ -214,15 +215,15 @@ namespace mRemoteNG.Connection.Protocol.ICA
private void SetColors()
{
// ReSharper disable once SwitchStatementMissingSomeCases
switch (Info.Colors)
switch (_info.Colors)
{
case RdpColors.Colors256:
case RdpProtocol.RDPColors.Colors256:
_icaClient.SetProp("DesiredColor", "2");
break;
case RdpColors.Colors15Bit:
case RdpProtocol.RDPColors.Colors15Bit:
_icaClient.SetProp("DesiredColor", "4");
break;
case RdpColors.Colors16Bit:
case RdpProtocol.RDPColors.Colors16Bit:
_icaClient.SetProp("DesiredColor", "4");
break;
default:
@@ -234,7 +235,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;
@@ -274,22 +275,22 @@ namespace mRemoteNG.Connection.Protocol.ICA
#region Private Events & Handlers
private void ICAEvent_OnConnecting(object sender, EventArgs e)
{
RaiseConnectionConnectingEvent(this);
Event_Connecting(this);
}
private void ICAEvent_OnConnected(object sender, EventArgs e)
{
RaiseConnectionConnectedEvent(this);
Event_Connected(this);
}
private void ICAEvent_OnConnectFailed(object sender, EventArgs e)
{
RaiseErrorOccuredEvent(this, e.ToString());
Event_ErrorOccured(this, e.ToString());
}
private void ICAEvent_OnDisconnect(object sender, EventArgs e)
{
RaiseConnectionDisconnectedEvent(this, e.ToString());
Event_Disconnected(this, e.ToString());
if (Settings.Default.ReconnectOnDisconnect)
{
@@ -311,7 +312,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,30 +11,27 @@ namespace mRemoteNG.Connection.Protocol
{
public class IntegratedProgram : ProtocolBase
{
#region Private Fields
private ExternalTool _externalTool;
private IntPtr _handle;
private Process _process;
public IntegratedProgram(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
}
#endregion
#region Public Methods
public override bool Initialize()
{
if (Info == null)
if (InterfaceControl.Info == null)
return base.Initialize();
_externalTool = Runtime.ExternalToolsService.GetExtAppByName(Info.ExtApp);
_externalTool = Runtime.ExternalToolsService.GetExtAppByName(InterfaceControl.Info.ExtApp);
if (_externalTool == null)
{
Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, Info.ExtApp));
Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, InterfaceControl.Info.ExtApp));
return false;
}
_externalTool.ConnectionInfo = Info;
_externalTool.ConnectionInfo = InterfaceControl.Info;
return base.Initialize();
}
@@ -47,7 +44,7 @@ namespace mRemoteNG.Connection.Protocol
if (_externalTool.TryIntegrate == false)
{
_externalTool.Start(Info);
_externalTool.Start(InterfaceControl.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...
@@ -172,7 +169,7 @@ namespace mRemoteNG.Connection.Protocol
#region Private Methods
private void ProcessExited(object sender, EventArgs e)
{
RaiseConnectionClosedEvent(this);
Event_Closed(this);
}
#endregion

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +0,0 @@
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

@@ -1,14 +0,0 @@
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

@@ -1,16 +0,0 @@
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

@@ -1,68 +0,0 @@
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

@@ -1,14 +0,0 @@
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

@@ -1,14 +0,0 @@
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

@@ -1,14 +0,0 @@
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

@@ -1,18 +0,0 @@
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

@@ -1,41 +0,0 @@
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

@@ -1,48 +0,0 @@
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

@@ -0,0 +1,933 @@
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

@@ -1,20 +0,0 @@
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

@@ -1,657 +0,0 @@
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

@@ -1,20 +0,0 @@
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

@@ -1,125 +0,0 @@
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

@@ -1,20 +0,0 @@
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

@@ -1,42 +0,0 @@
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

@@ -1,45 +0,0 @@
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(ConnectionInfo connectionInfo)
: base(connectionInfo)
{
PuttyProtocol = Putty_Protocol.rlogin;
public ProtocolRlogin()
{
this.PuttyProtocol = Putty_Protocol.rlogin;
}
public enum Defaults

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,16 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using mRemoteNG.Connection;
using System.ComponentModel;
using System.Linq;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
namespace mRemoteNG.Container
{
[DefaultProperty("Name")]
[DefaultProperty("Name")]
public class ContainerInfo : ConnectionInfo, INotifyCollectionChanged
{
[Browsable(false)]
@@ -19,13 +18,20 @@ namespace mRemoteNG.Container
[Category(""), Browsable(false), ReadOnly(false), Bindable(false), DefaultValue(""), DesignOnly(false)]
public bool IsExpanded { get; set; }
[Browsable(false)]
public override bool IsContainer { get { return true; } set {} }
public ContainerInfo()
public ContainerInfo(string uniqueId)
: base(uniqueId)
{
SetDefaults();
IsContainer = true;
}
public ContainerInfo()
: this(Guid.NewGuid().ToString())
{
}
public override TreeNodeType GetTreeNodeType()
{
return TreeNodeType.Container;
@@ -57,7 +63,7 @@ namespace mRemoteNG.Container
AddChildAt(newChildItem, newChildIndex);
}
public void AddChildAt(ConnectionInfo newChildItem, int index)
public virtual void AddChildAt(ConnectionInfo newChildItem, int index)
{
if (Children.Contains(newChildItem)) return;
newChildItem.Parent?.RemoveChild(newChildItem);
@@ -75,7 +81,7 @@ namespace mRemoteNG.Container
}
}
public void RemoveChild(ConnectionInfo removalTarget)
public virtual void RemoveChild(ConnectionInfo removalTarget)
{
if (!Children.Contains(removalTarget)) return;
removalTarget.Parent = null;
@@ -178,7 +184,6 @@ namespace mRemoteNG.Container
{
var newContainer = new ContainerInfo();
newContainer.CopyFrom(this);
newContainer.ConstantID = MiscTools.CreateConstantID();
newContainer.OpenConnections = new ProtocolList();
newContainer.Inheritance = Inheritance.Clone();
foreach (var child in Children.ToArray())

View File

@@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// <Assembly: AssemblyVersion("1.0.*")>
[assembly: AssemblyVersion("1.76.0.*")]
[assembly: AssemblyVersion("1.76.4.*")]
[assembly: NeutralResourcesLanguage("en")]

View File

@@ -12,7 +12,7 @@ namespace mRemoteNG {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -2698,5 +2698,29 @@ namespace mRemoteNG {
this["MultiSshToolbarVisible"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool CreateEmptyPanelOnStartUp {
get {
return ((bool)(this["CreateEmptyPanelOnStartUp"]));
}
set {
this["CreateEmptyPanelOnStartUp"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("General")]
public string StartUpPanelName {
get {
return ((string)(this["StartUpPanelName"]));
}
set {
this["StartUpPanelName"] = value;
}
}
}
}

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