mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Merge branch 'develop' into reapply_credential_manager
# Conflicts: # mRemoteV1/App/Export.cs # mRemoteV1/App/Initialization/CredsAndConsSetup.cs # mRemoteV1/App/Runtime.cs # mRemoteV1/Config/Connections/ConnectionsLoadedEventArgs.cs # mRemoteV1/Config/Connections/ConnectionsSavedEventArgs.cs # mRemoteV1/Config/Connections/CsvConnectionsSaver.cs # mRemoteV1/Config/Connections/SaveConnectionsOnEdit.cs # mRemoteV1/Config/CredentialHarvester.cs # mRemoteV1/Config/CredentialRepositoryListLoader.cs # mRemoteV1/Config/CredentialRepositoryListSaver.cs # mRemoteV1/Config/DataProviders/FileDataProvider.cs # mRemoteV1/Config/Import/MRemoteNGCsvImporter.cs # mRemoteV1/Config/Import/MRemoteNGXmlImporter.cs # mRemoteV1/Config/Import/RemoteDesktopConnectionImporter.cs # mRemoteV1/Config/Putty/PuttySessionsRegistryProvider.cs # mRemoteV1/Config/Putty/PuttySessionsXmingProvider.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormat.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsSerializerMremotengFormat.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/MsSql/DataTableDeserializer.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/MsSql/DataTableSerializer.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs # mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializer.cs # mRemoteV1/Config/Serializers/CredentialProviderSerializer/CredentialRepositoryListDeserializer.cs # mRemoteV1/Config/Serializers/MiscSerializers/PuttyConnectionManagerDeserializer.cs # mRemoteV1/Config/Serializers/MiscSerializers/RemoteDesktopConnectionDeserializer.cs # mRemoteV1/Config/Serializers/MiscSerializers/RemoteDesktopConnectionManagerDeserializer.cs # mRemoteV1/Connection/AbstractConnectionRecord.cs # mRemoteV1/Connection/ConnectionInfo.cs # mRemoteV1/Connection/ConnectionInfoInheritance.cs # mRemoteV1/Connection/ConnectionInitiator.cs # mRemoteV1/Connection/ConnectionsService.cs # mRemoteV1/Connection/DefaultConnectionInfo.cs # mRemoteV1/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs # mRemoteV1/Connection/Protocol/ICA/IcaProtocol.cs # mRemoteV1/Connection/Protocol/IntegratedProgram.cs # mRemoteV1/Connection/Protocol/ProtocolBase.cs # mRemoteV1/Connection/Protocol/PuttyBase.cs # mRemoteV1/Connection/Protocol/RDP/RdpProtocol.cs # mRemoteV1/Connection/Protocol/VNC/Connection.Protocol.VNC.cs # mRemoteV1/Connection/PuttySessionInfo.cs # mRemoteV1/Credential/CredentialRecordTypeConverter.cs # mRemoteV1/Credential/CredentialServiceFacade.cs # mRemoteV1/Credential/CredentialServiceFactory.cs # mRemoteV1/Credential/Records/UnavailableCredentialRecord.cs # mRemoteV1/Credential/Repositories/XmlCredentialRepository.cs # mRemoteV1/Credential/Repositories/XmlCredentialRepositoryFactory.cs # mRemoteV1/Properties/Settings.settings # mRemoteV1/Schemas/mremoteng_confcons_v2_7.xsd # mRemoteV1/Tools/CustomCollections/FullyObservableCollection.cs # mRemoteV1/Tools/Extensions.cs # mRemoteV1/Tools/ExternalTool.cs # mRemoteV1/Tools/ExternalToolArgumentParser.cs # mRemoteV1/UI/Controls/Base/NGComboBox.cs # mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs # mRemoteV1/UI/Controls/CredentialRecordListBox.cs # mRemoteV1/UI/Controls/QuickConnectToolStrip.cs # mRemoteV1/UI/Forms/OptionsPages/CredentialsPage.cs # mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs # mRemoteV1/UI/Forms/frmMain.cs # mRemoteV1/UI/Forms/frmOptions.cs # mRemoteV1/UI/Menu/ToolsMenu.cs # mRemoteV1/UI/Window/ConfigWindow.cs # mRemoteV1/UI/Window/ConnectionTreeWindow.Designer.cs # mRemoteV1/UI/Window/ConnectionTreeWindow.cs # mRemoteV1/UI/Window/ConnectionWindow.cs # mRemoteV1/app.config
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -283,9 +283,6 @@ Installer Projects/Installer/Fragments/HelpFilesFragment.wxs
|
||||
InstallerProjects/Installer/Fragments/FilesFragment.wxs
|
||||
InstallerProjects/Installer/Resources/License.rtf
|
||||
|
||||
# user preference: .editorconfig - http://editorconfig.org/
|
||||
.editorconfig
|
||||
|
||||
# gh-pages info
|
||||
runlocal.bat
|
||||
/_site
|
||||
@@ -10,9 +10,12 @@ Features/Enhancements:
|
||||
#951: Added property to Enable/Disable Clipboard Sharing for RDP connections
|
||||
#928: Add context menu items to 'Close all but this' and 'Close all tabs to the right'
|
||||
#765: Port Scan Issues (single port scan option now available)
|
||||
#155: Replace MagicLibrary with DockPanelSuite
|
||||
#154: MR-139: Close Button on Each Tab - new default theme has a close button on each tab
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1248: RemoveMagicLib Bugs - various bugs that cropped up as a result of removing magiclib
|
||||
#1245: Options form takes nearly 3 seconds to appear when Theming is active
|
||||
#1240: Theming problem with NGNumericUpDown
|
||||
#1238: Connection panel not translated until opened for the first time
|
||||
|
||||
@@ -32,7 +32,7 @@ if ($ConfigurationName -eq "Release Portable") {
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip "mRemoteV1\bin\package\*.*"
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip ".\mRemoteV1\bin\package\*.*"
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not zip anything - this isnt a portable release build."
|
||||
|
||||
BIN
Tools/cert/CodeSigning_Cert_mRemoteNG_DigiCert.p12.enc
Normal file
BIN
Tools/cert/CodeSigning_Cert_mRemoteNG_DigiCert.p12.enc
Normal file
Binary file not shown.
@@ -13,7 +13,7 @@ install:
|
||||
- ps: >-
|
||||
date
|
||||
|
||||
C:\projects\mremoteng\mRemoteV1\Resources\CitrixReceiver.exe ENABLE_SSON="No" /silent /noreboot /EnableCEIP=false /AutoUpdateCheck=disabled /EnableTracing=false | out-null
|
||||
mRemoteV1\Resources\CitrixReceiver.exe ENABLE_SSON="No" /silent /noreboot /EnableCEIP=false /AutoUpdateCheck=disabled /EnableTracing=false | out-null
|
||||
|
||||
date
|
||||
before_build:
|
||||
@@ -28,7 +28,7 @@ build:
|
||||
parallel: true
|
||||
verbosity: normal
|
||||
after_build:
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \"mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \".\\mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
|
||||
65
appveyor_publish.yml
Normal file
65
appveyor_publish.yml
Normal file
@@ -0,0 +1,65 @@
|
||||
version: 1.76.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
environment:
|
||||
cert_path: tools\cert\CodeSigning_Cert_mRemoteNG_DigiCert.p12
|
||||
cert_decrypt_pwd:
|
||||
secure: QK1ldldzIUSVA0u+OtbHixPmsXHAO9ksOKcyByq0FHM=
|
||||
cert_pwd:
|
||||
secure: Fni66m2OgoTxjRzahUNUUNHl5gGwTXLvXIMQYiOMqX8=
|
||||
image: Visual Studio 2017
|
||||
configuration:
|
||||
- Release Portable
|
||||
- Release
|
||||
- Release Installer
|
||||
platform: x86
|
||||
shallow_clone: true
|
||||
clone_depth: 1
|
||||
install:
|
||||
- ps: >-
|
||||
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
|
||||
|
||||
date
|
||||
|
||||
mRemoteV1\Resources\CitrixReceiver.exe ENABLE_SSON="No" /silent /noreboot /EnableCEIP=false /AutoUpdateCheck=disabled /EnableTracing=false | out-null
|
||||
|
||||
date
|
||||
before_build:
|
||||
- cmd: >-
|
||||
echo %TIME%
|
||||
|
||||
nuget restore
|
||||
|
||||
echo %TIME%
|
||||
|
||||
appveyor-tools\secure-file -decrypt %cert_path%.enc -secret %cert_decrypt_pwd%
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release Portable" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- configuration: "Release Installer"
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release Installer" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- configuration: Release
|
||||
build_script:
|
||||
- cmd: msbuild mRemoteV1.sln /t:Clean,Build /p:Configuration="Release" /p:Platform=x86 /p:CertPath="%APPVEYOR_BUILD_FOLDER%\%cert_path%" /p:CertPassword=%cert_pwd% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
after_build:
|
||||
- ps: "if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {\n Write-Output \"NOT running via Appveyor - Exiting\"\n Exit\n}\n\n$appvDir = $Env:APPVEYOR_BUILD_FOLDER\n\nWrite-Output \"Appveyor Build Dir: '$($appvDir)'\"\n$ConfigurationName = $Env:CONFIGURATION.Trim()\nWrite-Output \"Config Name (tirmmed): '$($ConfigurationName)'\"\n\n\n$SIGCHECK=\"Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"mRemoteV1\\bin\\package\"\n\n Copy-Item \"mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"*.txt\" -Destination \"mRemoteV1\\bin\\package\"\n\n Write-Output \"Creating portable ZIP file $($PortableZip)\"\n Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip \".\\mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}\n\nWrite-Output \"\"\nWrite-Output \"\"\n\nif ($ConfigurationName -match \"Release\" -And $ConfigurationName -ne \"Release Installer\") {\n Write-Output \"Packaging debug symbols\"\n \n $version = & $SIGCHECK /accepteula -q -n \"mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n if ($ConfigurationName -match \"Portable\") {\n $zipFilePrefix = \"mRemoteNG-Portable-symbols\"\n } else {\n $zipFilePrefix = \"mRemoteNG-symbols\"\n }\n\n $outputZipPath=\"Release\\$zipFilePrefix-$($version).zip\"\n\n Write-Output \"Creating debug symbols ZIP file $($outputZipPath)\"\n Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue\n $SymPath = (Join-Path -Path mRemoteV1\\bin\\$($ConfigurationName) -ChildPath \"*.pdb\")\n if(Test-Path \"$SymPath\") {\n & $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath \"$SymPath\"\n } else {\n Write-Output \"No Debugging Symbols Found...\"\n }\n \n}\nelse {\n Write-Output \"We will not package debug symbols for this configuration $($ConfigurationName)\"\n}\n\nWrite-Output \"\""
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
artifacts:
|
||||
- path: Release\*.msi
|
||||
name: mRemoteNG-installer.msi
|
||||
- path: Release\mRemoteNG-Portable-1.*.zip
|
||||
name: mRemoteNG-portable.zip
|
||||
- path: Release\mRemoteNG-Portable-symbols*.zip
|
||||
name: mRemoteNG-Portable-symbols.zip
|
||||
- path: Release\mRemoteNG-symbols*.zip
|
||||
name: mRemoteNG-symbols.zip
|
||||
@@ -7,7 +7,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WeifenLuo.WinFormsUI.Docking" publicKeyToken="5cded1a1a0a7b481" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.16.0.0" newVersion="2.16.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.6.0" newVersion="3.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut)
|
||||
{
|
||||
var connectionWindow = new ConnectionWindow(new DockContent());
|
||||
var connectionInfo = new ConnectionInfo {ExtApp = extAppName};
|
||||
return new InterfaceControl(connectionWindow, sut, connectionInfo);
|
||||
var connectionInfo = new ConnectionInfo {ExtApp = extAppName, Protocol = ProtocolType.IntApp};
|
||||
return new InterfaceControl(connectionWindow, sut, connectionInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
mRemoteV1/.editorconfig
Normal file
44
mRemoteV1/.editorconfig
Normal file
@@ -0,0 +1,44 @@
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = crlf
|
||||
indent_style = space
|
||||
|
||||
[*.xml]
|
||||
indent_size = 4
|
||||
|
||||
[*.cs]
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8-bom
|
||||
|
||||
# Organize usings
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# this. preferences
|
||||
dotnet_style_qualification_for_field = false:none
|
||||
dotnet_style_qualification_for_property = false:none
|
||||
dotnet_style_qualification_for_method = false:none
|
||||
dotnet_style_qualification_for_event = false:none
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
@@ -1,11 +1,11 @@
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -19,13 +19,38 @@ namespace mRemoteNG.App
|
||||
|
||||
private static void CheckFipsPolicy(MessageCollector messageCollector)
|
||||
{
|
||||
if (Settings.Default.OverrideFIPSCheck)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true);
|
||||
if (!FipsPolicyEnabledForServer2003() && !FipsPolicyEnabledForServer2008AndNewer()) return;
|
||||
var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName,
|
||||
GeneralAppInfo.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName);
|
||||
messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true);
|
||||
MessageBox.Show(FrmMain.Default, errorText);
|
||||
Environment.Exit(1);
|
||||
|
||||
//About to pop up a message, let's not block it...
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName,
|
||||
Language.strCompatibilityProblemDetected, errorText, "",
|
||||
"",
|
||||
Language.strCheckboxDoNotShowThisMessageAgain,
|
||||
ETaskDialogButtons.OkCancel, ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked && ShouldIStayOrShouldIGo == DialogResult.OK)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.ErrorMsg, "User requests that FIPS check be overridden", true);
|
||||
Settings.Default.OverrideFIPSCheck = true;
|
||||
Settings.Default.Save();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShouldIStayOrShouldIGo == DialogResult.Cancel)
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
private static bool FipsPolicyEnabledForServer2003()
|
||||
@@ -39,7 +64,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static bool FipsPolicyEnabledForServer2008AndNewer()
|
||||
{
|
||||
var regKey = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var regKey =
|
||||
Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var fipsPolicy = regKey?.GetValue("Enabled");
|
||||
if (fipsPolicy == null) return false;
|
||||
fipsPolicy = Convert.ToInt32(fipsPolicy);
|
||||
@@ -64,9 +90,14 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
if (proccesses.Length <= 0) return;
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected, Application.ProductName), "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok, ESysIcons.Warning, ESysIcons.Warning);
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected,
|
||||
string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected,
|
||||
Application.ProductName), "",
|
||||
"", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok,
|
||||
ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
Settings.Default.CompatibilityWarnLenovoAutoScrollUtility = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Connections;
|
||||
@@ -17,92 +17,100 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Export
|
||||
{
|
||||
public static class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, IConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
case ExportForm.ExportScope.SelectedConnection:
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Export.ExportToFile() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName,
|
||||
SaveFormat saveFormat,
|
||||
SaveFilter saveFilter,
|
||||
ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString.ConvertToSecureString() ?? new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
case SaveFormat.mRCSV:
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString
|
||||
.ConvertToSecureString() ??
|
||||
new RootNodeInfo(RootNodeType
|
||||
.Connection)
|
||||
.PasswordString
|
||||
.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
case SaveFormat.mRCSV:
|
||||
serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialService.RepositoryList);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
fileDataProvider.Save(serializedData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,10 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName),
|
||||
Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
|
||||
MessageBoxDefaultButton.Button1);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +62,9 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
public static void ImportFromActiveDirectory(string ldapPath,
|
||||
ContainerInfo importDestinationContainer,
|
||||
bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -73,7 +77,9 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts,
|
||||
ProtocolType protocol,
|
||||
ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class ConnectionsFileInfo
|
||||
public static class ConnectionsFileInfo
|
||||
{
|
||||
public static readonly string DefaultConnectionsPath = SettingsFileInfo.SettingsPath;
|
||||
public static readonly string DefaultConnectionsFile = "confCons.xml";
|
||||
|
||||
@@ -9,46 +9,53 @@ using static System.Environment;
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static readonly string ProductName = Application.ProductName;
|
||||
public static readonly string Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;
|
||||
public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
public static string UserAgent
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
Version v;
|
||||
System.Version.TryParse(ApplicationVersion, out v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
public static readonly string Copyright =
|
||||
((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
|
||||
typeof(AssemblyCopyrightAttribute), false))
|
||||
.Copyright;
|
||||
|
||||
public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
|
||||
public static string UserAgent
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
System.Version.TryParse(ApplicationVersion, out var v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,22 @@ namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class SettingsFileInfo
|
||||
{
|
||||
private static readonly string ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
private static readonly string ExePath =
|
||||
Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
|
||||
public static string SettingsPath =>
|
||||
Runtime.IsPortableEdition
|
||||
? ExePath
|
||||
: Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
|
||||
public static string SettingsPath => Runtime.IsPortableEdition ? ExePath : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
public static string LayoutFileName { get; } = "pnlLayout.xml";
|
||||
public static string ExtAppsFilesName { get; } = "extApps.xml";
|
||||
public static string ThemesFileName { get; } = "Themes.xml";
|
||||
public static string ThemeFolder { get; } = SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
public static string InstalledThemeFolder { get; } = ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
|
||||
public static string ThemeFolder { get; } =
|
||||
SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
|
||||
public static string InstalledThemeFolder { get; } =
|
||||
ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
@@ -27,7 +28,9 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static string GetChannelFileName(string channel)
|
||||
{
|
||||
return Runtime.IsPortableEdition ? GetChannelFileNamePortableEdition(channel) : GetChannelFileNameNormalEdition(channel);
|
||||
return Runtime.IsPortableEdition
|
||||
? GetChannelFileNamePortableEdition(channel)
|
||||
: GetChannelFileNameNormalEdition(channel);
|
||||
}
|
||||
|
||||
private static string GetChannelFileNameNormalEdition(string channel)
|
||||
@@ -62,7 +65,8 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static Uri GetUpdateTxtUri(string channel)
|
||||
{
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress), new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress),
|
||||
new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
}
|
||||
|
||||
private static bool IsValidChannel(string s)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
public ConnectionIconLoader(string folderPath)
|
||||
{
|
||||
if(string.IsNullOrEmpty(folderPath))
|
||||
if (string.IsNullOrEmpty(folderPath))
|
||||
throw new ArgumentException($"{nameof(folderPath)} must be a valid folder path.");
|
||||
|
||||
_path = folderPath;
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
connectionsOnEdit.Subscribe(connectionsService);
|
||||
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation && !File.Exists(connectionsService.GetStartupConnectionFileName()))
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation &&
|
||||
!File.Exists(connectionsService.GetStartupConnectionFileName()))
|
||||
connectionsService.NewConnectionsFile(connectionsService.GetStartupConnectionFileName());
|
||||
|
||||
credentialService.LoadRepositoryList();
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class MessageCollectorSetup
|
||||
{
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector, IList<IMessageWriter> messageWriterList)
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector,
|
||||
IList<IMessageWriter> messageWriterList)
|
||||
{
|
||||
messageCollector.CollectionChanged += (o, args) =>
|
||||
{
|
||||
@@ -37,34 +38,37 @@ namespace mRemoteNG.App.Initialization
|
||||
private static IMessageWriter BuildTextLogMessageWriter()
|
||||
{
|
||||
return new MessageTypeFilterDecorator(
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildNotificationPanelMessageWriter()
|
||||
{
|
||||
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new NotificationPanelMessageWriter(Windows.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new
|
||||
NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new
|
||||
NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new
|
||||
NotificationPanelMessageWriter(Windows
|
||||
.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildPopupMessageWriter()
|
||||
{
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
osVersion = Convert.ToString(managementObject.GetPropertyValue("Caption")).Trim();
|
||||
@@ -54,6 +55,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system information from WMI.", ex);
|
||||
}
|
||||
|
||||
var osData = string.Join(" ", osVersion, servicePack);
|
||||
return osData;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
servicePack = $"Service Pack {servicePackNumber}";
|
||||
}
|
||||
|
||||
return servicePack;
|
||||
}
|
||||
|
||||
@@ -73,7 +76,8 @@ namespace mRemoteNG.App.Initialization
|
||||
var architecture = string.Empty;
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
var addressWidth = Convert.ToInt32(managementObject.GetPropertyValue("AddressWidth"));
|
||||
@@ -84,6 +88,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system address width from WMI.", ex);
|
||||
}
|
||||
|
||||
return architecture;
|
||||
}
|
||||
|
||||
@@ -110,7 +115,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
private void LogCultureData()
|
||||
{
|
||||
var data = $"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
var data =
|
||||
$"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, data, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Windows.Forms;
|
||||
using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Config;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public class Logger
|
||||
public class Logger
|
||||
{
|
||||
public static readonly Logger Instance = new Logger();
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace mRemoteNG.App
|
||||
fileAppender.File = path;
|
||||
fileAppender.ActivateOptions();
|
||||
}
|
||||
|
||||
Log = LogManager.GetLogger("Logger");
|
||||
}
|
||||
|
||||
@@ -56,7 +58,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static string GetLogPathNormalEdition()
|
||||
{
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Application.ProductName);
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
Application.ProductName);
|
||||
}
|
||||
|
||||
private static string GetLogPathPortableEdition()
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
#pragma warning disable 649
|
||||
#pragma warning disable 169
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -11,33 +12,41 @@ namespace mRemoteNG.App
|
||||
public static class NativeMethods
|
||||
{
|
||||
#region Functions
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool AppendMenu(IntPtr hMenu, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr CreatePopupMenu();
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle,
|
||||
IntPtr childAfter,
|
||||
string lclassName,
|
||||
string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr GetForegroundWindow();
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool InsertMenu(IntPtr hMenu, int uPosition, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
|
||||
internal static extern bool InsertMenu(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr uIDNewItem,
|
||||
string lpNewItem);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int IsIconic(IntPtr hWnd);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam);
|
||||
|
||||
@@ -54,31 +63,38 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, string lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd, [In] uint msg, [Out] StringBuilder wParam, [In] IntPtr lParam);
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd,
|
||||
[In] uint msg,
|
||||
[Out] StringBuilder wParam,
|
||||
[In] IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu, int uPosition, int uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
|
||||
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr hBitmapUnchecked,
|
||||
IntPtr hBitmapChecked);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr WindowFromPoint(Point point);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
|
||||
internal static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int GetDlgCtrlID(IntPtr hwndCtl);
|
||||
@@ -92,9 +108,11 @@ namespace mRemoteNG.App
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
internal static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Structures
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WINDOWPOS
|
||||
{
|
||||
@@ -130,60 +148,71 @@ namespace mRemoteNG.App
|
||||
public long right;
|
||||
public long bottom;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
public static int MAKELONG(int wLow, int wHigh)
|
||||
{
|
||||
return wLow | wHigh << 16;
|
||||
}
|
||||
|
||||
|
||||
public static int MAKELPARAM(ref int wLow, ref int wHigh)
|
||||
{
|
||||
return MAKELONG(wLow, wHigh);
|
||||
}
|
||||
|
||||
|
||||
public static int LOWORD(int value)
|
||||
{
|
||||
return value & 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
public static int LOWORD(IntPtr value)
|
||||
{
|
||||
return LOWORD(value.ToInt32());
|
||||
}
|
||||
|
||||
|
||||
public static int HIWORD(int value)
|
||||
{
|
||||
return value >> 16;
|
||||
}
|
||||
|
||||
|
||||
public static int HIWORD(IntPtr value)
|
||||
{
|
||||
return HIWORD(value.ToInt32());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
|
||||
public const int TRUE = 1;
|
||||
|
||||
#region GetWindowLong
|
||||
|
||||
public const int GWL_STYLE = (-16);
|
||||
|
||||
#endregion
|
||||
|
||||
#region AppendMenu / ModifyMenu / DeleteMenu / RemoveMenu
|
||||
|
||||
public const int MF_BYCOMMAND = 0x0;
|
||||
public const int MF_BYPOSITION = 0x400;
|
||||
public const int MF_STRING = 0x0;
|
||||
public const int MF_POPUP = 0x10;
|
||||
public const int MF_SEPARATOR = 0x800;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_LBUTTONDOWN / WM_LBUTTONUP
|
||||
|
||||
public const int MK_LBUTTON = 0x1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowWindow
|
||||
|
||||
public const uint SW_HIDE = 0;
|
||||
public const uint SW_SHOWNORMAL = 1;
|
||||
public const uint SW_SHOWMINIMIZED = 2;
|
||||
@@ -195,9 +224,11 @@ namespace mRemoteNG.App
|
||||
public const uint SW_SHOWMINNOACTIVE = 7;
|
||||
public const uint SW_SHOWNA = 8;
|
||||
public const uint SW_RESTORE = 9;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetWindowPos / WM_WINDOWPOSCHANGING / WM_WINDOWPOSCHANGED
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current size (ignores the cx and cy parameters).
|
||||
/// </summary>
|
||||
@@ -269,12 +300,12 @@ namespace mRemoteNG.App
|
||||
public const int SWP_NOCLIENTMOVE = 0x1000;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents generation of the WM_SYNCPAINT message.
|
||||
/// Prevents generation of the WM_SYNCPAINT message.
|
||||
/// </summary>
|
||||
public const int SWP_DEFERERASE = 0x2000;
|
||||
|
||||
/// <summary>
|
||||
/// If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
|
||||
/// If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
|
||||
/// </summary>
|
||||
public const int SWP_ASYNCWINDOWPOS = 0x4000;
|
||||
|
||||
@@ -282,15 +313,19 @@ namespace mRemoteNG.App
|
||||
///
|
||||
/// </summary>
|
||||
public const int SWP_STATECHANGED = 0x8000;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Placement Flags (WPF)
|
||||
|
||||
public const uint WPF_SETMINPOSITION = 0x1;
|
||||
public const uint WPF_RESTORETOMAXIMIZED = 0x2;
|
||||
public const uint WPF_ASYNCWINDOWPLACEMENT = 0x4;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_ACTIVATE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -303,14 +338,16 @@ namespace mRemoteNG.App
|
||||
|
||||
/// <summary>
|
||||
/// Sent to both the window being activated and the window being deactivated.
|
||||
/// If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the
|
||||
/// top-level window being deactivated, then to the window procedure of the top-level window being activated. If the
|
||||
/// If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the
|
||||
/// top-level window being deactivated, then to the window procedure of the top-level window being activated. If the
|
||||
/// windows use different input queues, the message is sent asynchronously, so the window is activated immediately.
|
||||
/// </summary>
|
||||
public const int WA_CLICKACTIVE = 0x2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Messages
|
||||
|
||||
/// <summary>
|
||||
/// Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.
|
||||
/// </summary>
|
||||
@@ -332,7 +369,7 @@ namespace mRemoteNG.App
|
||||
public const int WM_SETTEXT = 0xC;
|
||||
|
||||
/// <summary>
|
||||
/// Copies the text that corresponds to a window into a buffer provided by the caller.
|
||||
/// Copies the text that corresponds to a window into a buffer provided by the caller.
|
||||
/// </summary>
|
||||
public const int WM_GETTEXT = 0xD;
|
||||
|
||||
@@ -347,7 +384,7 @@ namespace mRemoteNG.App
|
||||
public const int WM_ACTIVATEAPP = 0x1C;
|
||||
|
||||
/// <summary>
|
||||
/// Sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured.
|
||||
/// Sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured.
|
||||
/// </summary>
|
||||
public const int WM_SETCURSOR = 0x20;
|
||||
|
||||
@@ -372,12 +409,12 @@ namespace mRemoteNG.App
|
||||
public const int WM_WINDOWPOSCHANGED = 0x47;
|
||||
|
||||
/// <summary>
|
||||
/// Posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.
|
||||
/// Posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.
|
||||
/// </summary>
|
||||
public const int WM_KEYDOWN = 0x100;
|
||||
|
||||
/// <summary>
|
||||
/// Posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus.
|
||||
/// Posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus.
|
||||
/// </summary>
|
||||
public const int WM_KEYUP = 0x101;
|
||||
|
||||
@@ -432,7 +469,7 @@ namespace mRemoteNG.App
|
||||
public const int WM_MBUTTONUP = 0x208;
|
||||
|
||||
/// <summary>
|
||||
/// Posted when the user presses the first or second X button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
|
||||
/// Posted when the user presses the first or second X button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
|
||||
/// </summary>
|
||||
public const int WM_XBUTTONDOWN = 0x20B;
|
||||
|
||||
@@ -447,47 +484,56 @@ namespace mRemoteNG.App
|
||||
public const int WM_PARENTNOTIFY = 0x210;
|
||||
|
||||
/// <summary>
|
||||
/// Sent one time to a window after it enters the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.
|
||||
/// Sent one time to a window after it enters the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.
|
||||
/// </summary>
|
||||
public const int WM_ENTERSIZEMOVE = 0x231;
|
||||
|
||||
/// <summary>
|
||||
/// Sent one time to a window, after it has exited the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.
|
||||
/// Sent one time to a window, after it has exited the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.
|
||||
/// </summary>
|
||||
public const int WM_EXITSIZEMOVE = 0x232;
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the first window in the clipboard viewer chain when the content of the clipboard changes. This enables a clipboard viewer window to display the new content of the clipboard.
|
||||
/// Sent to the first window in the clipboard viewer chain when the content of the clipboard changes. This enables a clipboard viewer window to display the new content of the clipboard.
|
||||
/// </summary>
|
||||
public const int WM_DRAWCLIPBOARD = 0x308;
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the first window in the clipboard viewer chain when a window is being removed from the chain.
|
||||
/// Sent to the first window in the clipboard viewer chain when a window is being removed from the chain.
|
||||
/// </summary>
|
||||
public const int WM_CHANGECBCHAIN = 0x30D;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Styles
|
||||
|
||||
public const int WS_MAXIMIZE = 0x1000000;
|
||||
public const int WS_VISIBLE = 0x10000000;
|
||||
public const int WS_CHILD = 0x40000000;
|
||||
public const int WS_EX_MDICHILD = 0x40;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual Key Codes
|
||||
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_C = 0x67;
|
||||
|
||||
#endregion
|
||||
|
||||
#region EM
|
||||
|
||||
public const uint ECM_FIRST = 0x1500;
|
||||
public const uint EM_SETCUEBANNER = ECM_FIRST + 1;
|
||||
public const uint EM_GETCUEBANNER = ECM_FIRST + 2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region LB
|
||||
|
||||
public const int LB_ERR = -1;
|
||||
public const int LB_SELECTSTRING = 0x18C;
|
||||
|
||||
#endregion
|
||||
|
||||
#region TCM
|
||||
|
||||
@@ -67,9 +67,12 @@ namespace mRemoteNG.App
|
||||
var currentProcess = Process.GetCurrentProcess();
|
||||
foreach (var enumeratedProcess in Process.GetProcessesByName(currentProcess.ProcessName))
|
||||
{
|
||||
if (enumeratedProcess.Id != currentProcess.Id && enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName && enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
if (enumeratedProcess.Id != currentProcess.Id &&
|
||||
enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName &&
|
||||
enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
windowHandle = enumeratedProcess.MainWindowHandle;
|
||||
}
|
||||
|
||||
return windowHandle;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,16 @@ namespace mRemoteNG.App
|
||||
public static MessageCollector MessageCollector { get; } = new MessageCollector();
|
||||
public static NotificationAreaIcon NotificationAreaIcon { get; set; }
|
||||
public static ExternalToolsService ExternalToolsService { get; } = new ExternalToolsService();
|
||||
public static SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static SecureString EncryptionKey { get; set; } =
|
||||
new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static CredentialService CredentialService { get; } = new CredentialServiceFactory().Build();
|
||||
|
||||
public static ConnectionsService ConnectionsService { get; } = new ConnectionsService(PuttySessionsManager.Instance, CredentialService);
|
||||
|
||||
#region Connections Loading/Saving
|
||||
|
||||
public static void LoadConnectionsAsync()
|
||||
{
|
||||
var t = new Thread(LoadConnectionsBGd);
|
||||
@@ -105,8 +110,14 @@ namespace mRemoteNG.App
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain,
|
||||
Language.strCommandOpenConnectionFile,
|
||||
string.Format(Language.strCommandExitProgram,
|
||||
Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed,
|
||||
Language.strLoadFromSqlFailedContent,
|
||||
MiscTools.GetExceptionMessageRecursive(ex), "", "",
|
||||
commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
@@ -121,9 +132,13 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ex is FileNotFoundException && !withDialog)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), ex,
|
||||
MessageClass.InformationMsg);
|
||||
|
||||
string[] commandButtons =
|
||||
{
|
||||
@@ -139,13 +154,13 @@ namespace mRemoteNG.App
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
@@ -166,17 +181,24 @@ namespace mRemoteNG.App
|
||||
Application.Exit();
|
||||
answered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string
|
||||
.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), exc,
|
||||
MessageClass.InformationMsg);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
|
||||
MessageCollector.AddExceptionStackTrace(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoaded,
|
||||
connectionFileName), ex);
|
||||
if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
|
||||
{
|
||||
LoadConnections(withDialog);
|
||||
@@ -184,12 +206,16 @@ namespace mRemoteNG.App
|
||||
else
|
||||
{
|
||||
MessageBox.Show(FrmMain.Default,
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, ConnectionsService.GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine,
|
||||
Application.ProductName,
|
||||
ConnectionsService.GetStartupConnectionFileName(),
|
||||
MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -25,7 +26,10 @@ namespace mRemoteNG.App
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
public static void Cleanup(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -58,9 +62,13 @@ namespace mRemoteNG.App
|
||||
Runtime.ConnectionsService.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
private static void SaveSettings(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip,
|
||||
frmMain);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
|
||||
@@ -37,15 +37,16 @@ namespace mRemoteNG.App
|
||||
|
||||
public void InitializeProgram(MessageCollector messageCollector)
|
||||
{
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " +
|
||||
Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
var startupLogger = new StartupDataLogger(messageCollector);
|
||||
startupLogger.LogStartupData();
|
||||
CompatibilityChecker.CheckCompatibility(messageCollector);
|
||||
ParseCommandLineArgs(messageCollector);
|
||||
IeBrowserEmulation.Register();
|
||||
_connectionIconLoader.GetConnectionIcons();
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a=>"ConDefault"+a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a=>"InhDefault"+a);
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a => "ConDefault" + a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a => "InhDefault" + a);
|
||||
}
|
||||
|
||||
private static void ParseCommandLineArgs(MessageCollector messageCollector)
|
||||
@@ -59,7 +60,8 @@ namespace mRemoteNG.App
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Determining if we need a database syncronizer");
|
||||
if (!Settings.Default.UseSQLServer) return;
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Creating database syncronizer");
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer =
|
||||
new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer.Enable();
|
||||
}
|
||||
|
||||
@@ -74,7 +76,12 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
|
||||
var nextUpdateCheck = Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(TimeSpan.FromDays(Convert.ToDouble(Settings.Default.CheckForUpdatesFrequencyDays))));
|
||||
var nextUpdateCheck =
|
||||
Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(
|
||||
TimeSpan
|
||||
.FromDays(Convert.ToDouble(Settings
|
||||
.Default
|
||||
.CheckForUpdatesFrequencyDays))));
|
||||
if (!Settings.Default.UpdatePending && DateTime.UtcNow < nextUpdateCheck)
|
||||
{
|
||||
return;
|
||||
@@ -100,6 +107,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Error != null)
|
||||
{
|
||||
throw e.Error;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class SupportedCultures : Dictionary<string, string>
|
||||
{
|
||||
{
|
||||
private static SupportedCultures _Instance;
|
||||
|
||||
private static SupportedCultures SingletonInstance
|
||||
@@ -19,7 +19,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
|
||||
private SupportedCultures()
|
||||
private SupportedCultures()
|
||||
{
|
||||
foreach (var CultureName in Settings.Default.SupportedUICultures.Split(','))
|
||||
{
|
||||
@@ -30,7 +30,8 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Print($"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
Debug.Print(
|
||||
$"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,51 +42,52 @@ namespace mRemoteNG.App
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
|
||||
SingletonInstance.Keys.CopyTo(Names, 0);
|
||||
SingletonInstance.Values.CopyTo(NativeNames, 0);
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
public static List<string> CultureNativeNames
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ using System.Security.Cryptography;
|
||||
#if !PORTABLE
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
#else
|
||||
#else
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endif
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
@@ -66,7 +67,12 @@ namespace mRemoteNG.App.Update
|
||||
SetProxySettings(shouldWeUseProxy, proxyAddress, port, useAuthentication, username, password);
|
||||
}
|
||||
|
||||
public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password)
|
||||
public void SetProxySettings(bool useProxy,
|
||||
string address,
|
||||
int port,
|
||||
bool useAuthentication,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
if (useProxy && !string.IsNullOrEmpty(address))
|
||||
{
|
||||
@@ -107,7 +113,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
}
|
||||
|
||||
if (IsGetChangeLogRunning)
|
||||
@@ -131,27 +138,29 @@ namespace mRemoteNG.App.Update
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
}
|
||||
#if !PORTABLE
|
||||
CurrentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
CurrentUpdateInfo.UpdateFilePath =
|
||||
Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
#else
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
FileName = CurrentUpdateInfo.FileName,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
CurrentUpdateInfo.UpdateFilePath = sfd.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, CurrentUpdateInfo.UpdateFilePath);
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress,
|
||||
CurrentUpdateInfo.UpdateFilePath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -191,7 +200,9 @@ namespace mRemoteNG.App.Update
|
||||
}
|
||||
|
||||
private static DownloadStringCompletedEventArgs NewDownloadStringCompletedEventArgs(string result,
|
||||
Exception exception, bool cancelled, object userToken)
|
||||
Exception exception,
|
||||
bool cancelled,
|
||||
object userToken)
|
||||
{
|
||||
var type = typeof(DownloadStringCompletedEventArgs);
|
||||
const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
@@ -201,7 +212,7 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
if (constructor == null)
|
||||
return null;
|
||||
return (DownloadStringCompletedEventArgs) constructor.Invoke(arguments);
|
||||
return (DownloadStringCompletedEventArgs)constructor.Invoke(arguments);
|
||||
}
|
||||
|
||||
private DownloadStringCompletedEventArgs DownloadString(Uri address)
|
||||
@@ -326,11 +337,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,11 +353,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +369,15 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,11 +387,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ namespace mRemoteNG.App.Update
|
||||
public class UpdateFile
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Local
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public Dictionary<string, string> Items { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
public Dictionary<string, string> Items { get; } =
|
||||
new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public UpdateFile(string content)
|
||||
{
|
||||
FromString(content);
|
||||
@@ -24,8 +28,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(content)) return;
|
||||
|
||||
char[] keyValueSeparators = { ':', '=' };
|
||||
char[] commentCharacters = { '#', ';', '\'' };
|
||||
char[] keyValueSeparators = {':', '='};
|
||||
char[] commentCharacters = {'#', ';', '\''};
|
||||
|
||||
// no separators means no valid update data...
|
||||
if (content.Trim().IndexOfAny(keyValueSeparators) == -1) return;
|
||||
@@ -47,7 +51,7 @@ namespace mRemoteNG.App.Update
|
||||
continue;
|
||||
|
||||
// make sure we have valid data in both parts before adding to the collection. If either part is empty, then it's not valid data.
|
||||
if(string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
if (string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
continue;
|
||||
|
||||
Items.Add(parts[0].Trim(), parts[1].Trim());
|
||||
@@ -83,13 +87,14 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
var value = GetString("dURL");
|
||||
var sv = value.Split('/');
|
||||
return sv[sv.Length-1];
|
||||
return sv[sv.Length - 1];
|
||||
}
|
||||
|
||||
public string GetChecksum(string key = "Checksum")
|
||||
{
|
||||
return GetString(key).Replace(" ", "").ToUpperInvariant();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
|
||||
namespace mRemoteNG.App.Update
|
||||
@@ -43,6 +44,7 @@ namespace mRemoteNG.App.Update
|
||||
newInfo.Checksum = updateFile.GetChecksum();
|
||||
newInfo.IsValid = newInfo.CheckIfValid();
|
||||
}
|
||||
|
||||
return newInfo;
|
||||
}
|
||||
|
||||
@@ -50,11 +52,11 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(Version.ToString()))
|
||||
return false;
|
||||
if(string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
if (string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ChangeLogAddress.AbsoluteUri))
|
||||
return false;
|
||||
#if false
|
||||
#if false
|
||||
if (string.IsNullOrEmpty(ImageAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ImageLinkAddress.AbsoluteUri))
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace mRemoteNG.App
|
||||
internal static SSHTransferWindow SshtransferForm { get; private set; } = new SSHTransferWindow();
|
||||
|
||||
|
||||
|
||||
public static void Show(WindowType windowType)
|
||||
{
|
||||
try
|
||||
@@ -55,6 +54,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
}
|
||||
|
||||
break;
|
||||
case WindowType.SSHTransfer:
|
||||
if (SshtransferForm == null || SshtransferForm.IsDisposed)
|
||||
@@ -90,7 +90,8 @@ namespace mRemoteNG.App
|
||||
_ultravncscForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.ComponentsCheck:
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Showing ComponentsCheck window", true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Showing ComponentsCheck window", true);
|
||||
if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
|
||||
_componentscheckForm = new ComponentsCheckWindow();
|
||||
_componentscheckForm.Show(dockPanel);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace mRemoteNG.Config
|
||||
{
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@ namespace mRemoteNG.Config.Connections
|
||||
public bool UsingDatabase { get; }
|
||||
public string ConnectionFileName { get; }
|
||||
|
||||
public ConnectionsSavedEventArgs(IConnectionTreeModel modelThatWasSaved, bool previouslyUsingDatabase, bool usingDatabase, string connectionFileName)
|
||||
public ConnectionsSavedEventArgs(IConnectionTreeModel modelThatWasSaved,
|
||||
bool previouslyUsingDatabase,
|
||||
bool usingDatabase,
|
||||
string connectionFileName)
|
||||
{
|
||||
if (modelThatWasSaved == null)
|
||||
throw new ArgumentNullException(nameof(modelThatWasSaved));
|
||||
|
||||
@@ -3,7 +3,8 @@ using mRemoteNG.Config.DatabaseConnectors;
|
||||
|
||||
namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
public delegate void ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
public delegate void
|
||||
ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
|
||||
public class ConnectionsUpdateAvailableEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
_updateChecker.UpdateCheckStarted += OnUpdateCheckStarted;
|
||||
_updateChecker.UpdateCheckFinished += OnUpdateCheckFinished;
|
||||
_updateChecker.ConnectionsUpdateAvailable += (sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateChecker.ConnectionsUpdateAvailable +=
|
||||
(sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateTimer.Elapsed += (sender, args) => _updateChecker.IsUpdateAvailableAsync();
|
||||
ConnectionsUpdateAvailable += Load;
|
||||
}
|
||||
@@ -81,6 +82,7 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToAlsoFreeManagedObjects) return;
|
||||
|
||||
@@ -48,9 +48,11 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
_sqlConnector.Connect();
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Unable to connect to Sql DB to check for updates." + Environment.NewLine + e.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Unable to connect to Sql DB to check for updates." +
|
||||
Environment.NewLine + e.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,9 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private bool CheckIfIAmTheLastOneUpdated(DateTime lastUpdateInDb)
|
||||
{
|
||||
DateTime lastSqlUpdateWithoutMilliseconds = new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond), LastUpdateTime.Kind);
|
||||
DateTime lastSqlUpdateWithoutMilliseconds =
|
||||
new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond),
|
||||
LastUpdateTime.Kind);
|
||||
return lastUpdateInDb == lastSqlUpdateWithoutMilliseconds;
|
||||
}
|
||||
|
||||
@@ -80,20 +84,25 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Error executing Sql query to get updates from the DB." + Environment.NewLine + ex.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Error executing Sql query to get updates from the DB." +
|
||||
Environment.NewLine + ex.Message, true);
|
||||
}
|
||||
|
||||
_lastDatabaseUpdateTime = lastUpdateInDb;
|
||||
return lastUpdateInDb;
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler UpdateCheckStarted;
|
||||
|
||||
private void RaiseUpdateCheckStartedEvent()
|
||||
{
|
||||
UpdateCheckStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event UpdateCheckFinishedEventHandler UpdateCheckFinished;
|
||||
|
||||
private void RaiseUpdateCheckFinishedEvent(bool updateAvailable)
|
||||
{
|
||||
var args = new ConnectionsUpdateCheckFinishedEventArgs {UpdateAvailable = updateAvailable};
|
||||
@@ -101,6 +110,7 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
|
||||
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
|
||||
|
||||
private void RaiseConnectionsUpdateAvailableEvent()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Remote connection update is available");
|
||||
|
||||
@@ -23,12 +23,15 @@ namespace mRemoteNG.Config.Connections
|
||||
_connectionsService = null;
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender,
|
||||
PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit(propertyChangedEventArgs.PropertyName);
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender,
|
||||
NotifyCollectionChangedEventArgs
|
||||
notifyCollectionChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit();
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
mRCSV,
|
||||
SQL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,20 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsLoader : IConnectionsLoader
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> _localConnectionPropertiesDeserializer;
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>
|
||||
_localConnectionPropertiesDeserializer;
|
||||
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; } =
|
||||
() => MiscTools.PasswordDialog("", false);
|
||||
|
||||
public SqlConnectionsLoader(
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
_localConnectionPropertiesDeserializer = localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_localConnectionPropertiesDeserializer =
|
||||
localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_dataProvider = dataProvider.ThrowIfNull(nameof(dataProvider));
|
||||
}
|
||||
|
||||
@@ -60,7 +63,9 @@ namespace mRemoteNG.Config.Connections
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var cipherText = metaData.Protected;
|
||||
var authenticator = new PasswordAuthenticator(cryptographyProvider, cipherText, AuthenticationRequestor);
|
||||
var authenticated = authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword.ConvertToSecureString());
|
||||
var authenticated =
|
||||
authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword
|
||||
.ConvertToSecureString());
|
||||
|
||||
if (authenticated)
|
||||
return authenticator.LastAuthenticatedPassword;
|
||||
@@ -74,10 +79,10 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
rootNode
|
||||
.GetRecursiveChildList()
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.ForEach(x =>
|
||||
{
|
||||
x.Connection.PleaseConnect = x.LocalProperties.Connected;
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace mRemoteNG.Config.Connections
|
||||
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public SqlConnectionsSaver(
|
||||
SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>
|
||||
localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
{
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
@@ -49,14 +49,15 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (PropertyIsLocalOnly(propertyNameTrigger))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SqlUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,7 +70,8 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (!databaseVersionVerifier.VerifyDatabaseVersion(metaData.ConfVersion))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strErrorConnectionListSaveFailed);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
Language.strErrorConnectionListSaveFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,22 +139,25 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
sqlQuery =
|
||||
new SqlCommand(
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) +
|
||||
")",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateConnectionsTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
|
||||
{
|
||||
var cryptoProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider, rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider,
|
||||
rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var dataTable = serializer.Serialize(rootTreeNode);
|
||||
var dataProvider = new SqlDataProvider(sqlDatabaseConnector);
|
||||
|
||||
@@ -165,14 +170,16 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblUpdate", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) + "\')", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery = new SqlCommand(
|
||||
"INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) +
|
||||
"\')",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private bool SqlUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,4 @@ namespace mRemoteNG.Config.Connections
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,17 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
cryptographyProvider,
|
||||
connectionTreeModel
|
||||
.RootNodes.OfType<RootNodeInfo>()
|
||||
.First().PasswordString
|
||||
.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer =
|
||||
new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
var xml = xmlConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
|
||||
var fileDataProvider = new FileDataProviderWithRollingBackup(_connectionFileName);
|
||||
@@ -51,4 +55,4 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureDeserializer<string, IEnumerable<ICredentialRecord>> _deserializer;
|
||||
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider, ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider,
|
||||
ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureSerializer<IEnumerable<ICredentialRecord>, string> _serializer;
|
||||
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider, ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider,
|
||||
ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -14,12 +14,14 @@ namespace mRemoteNG.Config.DataProviders
|
||||
if (WeDontNeedToBackup(fileName))
|
||||
return;
|
||||
|
||||
var backupFileName = string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
var backupFileName =
|
||||
string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
File.Copy(fileName, backupFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg);
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex,
|
||||
MessageClass.WarningMsg);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace mRemoteNG.Config.DataProviders
|
||||
return;
|
||||
|
||||
var filesToDelete = files
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
|
||||
@@ -19,14 +19,14 @@ namespace mRemoteNG.Config.DataProviders
|
||||
var fileContents = "";
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, $"Could not load file. File does not exist '{FilePath}'");
|
||||
return "";
|
||||
}
|
||||
|
||||
fileContents = File.ReadAllText(FilePath);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(
|
||||
$"Could not load file. File does not exist '{FilePath}'",
|
||||
ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public interface IDataProvider<TFormat>
|
||||
{
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
if (SqlUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +63,6 @@ namespace mRemoteNG.Config.DataProviders
|
||||
private bool SqlUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@
|
||||
CredentialsRejected,
|
||||
UnknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,4 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
return new SqlDatabaseConnector(sqlHost, sqlCatalog, sqlUsername, sqlPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
/// </summary>
|
||||
public class SqlDatabaseConnectionTester
|
||||
{
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string server, string database, string username, string password)
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string server,
|
||||
string database,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
using (var sqlConnector = new SqlDatabaseConnector(server, database, username, password))
|
||||
{
|
||||
@@ -35,4 +38,4 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class SqlDatabaseConnector : IDatabaseConnector
|
||||
{
|
||||
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
|
||||
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
|
||||
private string _sqlConnectionString = "";
|
||||
private readonly string _sqlHost;
|
||||
private readonly string _sqlCatalog;
|
||||
@@ -45,7 +45,8 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
|
||||
private void BuildSqlConnectionStringWithCustomCredentials()
|
||||
{
|
||||
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
|
||||
_sqlConnectionString =
|
||||
$"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionStringWithDefaultCredentials()
|
||||
@@ -77,6 +78,7 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToFreeManagedObjects) return;
|
||||
|
||||
@@ -7,29 +7,29 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string ldapPath, ContainerInfo destinationContainer)
|
||||
{
|
||||
Import(ldapPath, destinationContainer, false);
|
||||
}
|
||||
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
if (importedRootNode == null) return;
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ namespace mRemoteNG.Config.Import
|
||||
}
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {filePath}");
|
||||
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlString = dataProvider.Load();
|
||||
@@ -34,7 +35,7 @@ namespace mRemoteNG.Config.Import
|
||||
};
|
||||
credentialImportForm.ShowDialog();
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(filePath)};
|
||||
rootImportContainer.AddChildRange(serializationResult.ConnectionRecords);
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
|
||||
@@ -10,28 +10,29 @@ using mRemoteNG.Messages;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {fileName}");
|
||||
if (!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {fileName}");
|
||||
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var serializationResult = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(fileName)};
|
||||
rootImportContainer.AddChildRange(serializationResult.ConnectionRecords);
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,18 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
|
||||
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
var connectionTreeModel = deserializer.Deserialize(hosts);
|
||||
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
@@ -27,5 +27,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlContent = dataProvider.Load();
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace mRemoteNG.Config.Import
|
||||
|
||||
destinationContainer.AddChildRange(serializationResult.ConnectionRecords);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var content = dataProvider.Load();
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace mRemoteNG.Config.Import
|
||||
var serializationResult = deserializer.Deserialize(content);
|
||||
|
||||
var importedConnection = serializationResult.ConnectionRecords.FirstOrDefault();
|
||||
|
||||
|
||||
if (importedConnection == null) return;
|
||||
importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
|
||||
destinationContainer.AddChild(importedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var fileContent = dataProvider.Load();
|
||||
|
||||
@@ -17,5 +17,5 @@ namespace mRemoteNG.Config.Import
|
||||
|
||||
destinationContainer.AddChildRange(serializationResult.ConnectionRecords);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,37 +5,42 @@ using System.Web;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System.Text;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public abstract class AbstractPuttySessionsProvider
|
||||
{
|
||||
{
|
||||
public virtual RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo();
|
||||
|
||||
protected virtual List<PuttySessionInfo> Sessions
|
||||
{
|
||||
get { return RootInfo.Children.OfType<PuttySessionInfo>().ToList(); }
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public abstract string[] GetSessionNames(bool raw = false);
|
||||
public abstract PuttySessionInfo GetSession(string sessionName);
|
||||
|
||||
public virtual IEnumerable<PuttySessionInfo> GetSessions()
|
||||
{
|
||||
var sessionNamesFromProvider = GetSessionNames(true);
|
||||
public abstract PuttySessionInfo GetSession(string sessionName);
|
||||
|
||||
public virtual IEnumerable<PuttySessionInfo> GetSessions()
|
||||
{
|
||||
var sessionNamesFromProvider = GetSessionNames(true);
|
||||
foreach (var sessionName in GetSessionNamesToAdd(sessionNamesFromProvider))
|
||||
{
|
||||
var sessionInfo = GetSession(sessionName);
|
||||
AddSession(sessionInfo);
|
||||
}
|
||||
foreach (var session in GetSessionToRemove(sessionNamesFromProvider))
|
||||
{
|
||||
RemoveSession(session);
|
||||
}
|
||||
{
|
||||
var sessionInfo = GetSession(sessionName);
|
||||
AddSession(sessionInfo);
|
||||
}
|
||||
|
||||
foreach (var session in GetSessionToRemove(sessionNamesFromProvider))
|
||||
{
|
||||
RemoveSession(session);
|
||||
}
|
||||
|
||||
RootInfo.SortRecursive();
|
||||
return Sessions;
|
||||
}
|
||||
return Sessions;
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetSessionNamesToAdd(IEnumerable<string> sessionNamesFromProvider)
|
||||
{
|
||||
@@ -47,7 +52,9 @@ namespace mRemoteNG.Config.Putty
|
||||
private IEnumerable<PuttySessionInfo> GetSessionToRemove(IEnumerable<string> sessionNamesFromProvider)
|
||||
{
|
||||
var currentlyKnownSessionNames = Sessions.Select(session => session.Name);
|
||||
var normalizedSessionNames = sessionNamesFromProvider.Select(name => HttpUtility.UrlDecode(name, Encoding.GetEncoding("iso-8859-1")));
|
||||
var normalizedSessionNames =
|
||||
sessionNamesFromProvider.Select(name =>
|
||||
HttpUtility.UrlDecode(name, Encoding.GetEncoding("iso-8859-1")));
|
||||
var sessionNamesToRemove = currentlyKnownSessionNames.Except(normalizedSessionNames);
|
||||
return Sessions.Where(session => sessionNamesToRemove.Contains(session.Name));
|
||||
}
|
||||
@@ -57,29 +64,43 @@ namespace mRemoteNG.Config.Putty
|
||||
if (string.IsNullOrEmpty(sessionInfo?.Name) || Sessions.Any(child => child.Name == sessionInfo.Name))
|
||||
return;
|
||||
RootInfo.AddChild(sessionInfo);
|
||||
RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, sessionInfo));
|
||||
RaisePuttySessionCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||
sessionInfo));
|
||||
}
|
||||
|
||||
protected virtual void RemoveSession(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (!Sessions.Contains(sessionInfo)) return;
|
||||
RootInfo.RemoveChild(sessionInfo);
|
||||
RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, sessionInfo));
|
||||
RaisePuttySessionCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
|
||||
sessionInfo));
|
||||
}
|
||||
|
||||
public virtual void StartWatcher() { }
|
||||
|
||||
public virtual void StopWatcher() { }
|
||||
|
||||
public virtual void StartWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StopWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public delegate void PuttySessionChangedEventHandler(object sender, PuttySessionChangedEventArgs e);
|
||||
|
||||
public delegate void PuttySessionChangedEventHandler(object sender, PuttySessionChangedEventArgs e);
|
||||
|
||||
public event PuttySessionChangedEventHandler PuttySessionChanged;
|
||||
protected virtual void RaiseSessionChangedEvent(PuttySessionChangedEventArgs args)
|
||||
{
|
||||
|
||||
protected virtual void RaiseSessionChangedEvent(PuttySessionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionChanged?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler PuttySessionsCollectionChanged;
|
||||
|
||||
protected void RaisePuttySessionCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionsCollectionChanged?.Invoke(this, args);
|
||||
|
||||
@@ -3,74 +3,80 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsManager
|
||||
{
|
||||
{
|
||||
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();
|
||||
|
||||
private readonly List<AbstractPuttySessionsProvider> _providers = new List<AbstractPuttySessionsProvider>();
|
||||
|
||||
public IEnumerable<AbstractPuttySessionsProvider> Providers
|
||||
{
|
||||
get { return _providers; }
|
||||
}
|
||||
|
||||
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
|
||||
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
|
||||
|
||||
private PuttySessionsManager()
|
||||
{
|
||||
AddProvider(new PuttySessionsRegistryProvider());
|
||||
private PuttySessionsManager()
|
||||
{
|
||||
AddProvider(new PuttySessionsRegistryProvider());
|
||||
AddProvider(new PuttySessionsXmingProvider());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Public Methods
|
||||
public void AddSessions()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
AddSessionsFromProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
public void AddSessions()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
AddSessionsFromProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
|
||||
var rootTreeNode = puttySessionProvider.RootInfo;
|
||||
puttySessionProvider.GetSessions();
|
||||
puttySessionProvider.GetSessions();
|
||||
|
||||
if (!RootPuttySessionsNodes.Contains(rootTreeNode) && rootTreeNode.HasChildren())
|
||||
RootPuttySessionsNodes.Add(rootTreeNode);
|
||||
rootTreeNode.SortRecursive();
|
||||
}
|
||||
|
||||
public void StartWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StartWatcher();
|
||||
provider.PuttySessionChanged += PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StopWatcher();
|
||||
provider.PuttySessionChanged -= PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StartWatcher();
|
||||
provider.PuttySessionChanged += PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StopWatcher();
|
||||
provider.PuttySessionChanged -= PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProvider(AbstractPuttySessionsProvider newProvider)
|
||||
{
|
||||
if (_providers.Contains(newProvider)) return;
|
||||
_providers.Add(newProvider);
|
||||
newProvider.PuttySessionsCollectionChanged += RaisePuttySessionCollectionChangedEvent;
|
||||
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newProvider));
|
||||
RaiseSessionProvidersCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||
newProvider));
|
||||
}
|
||||
|
||||
public void AddProviders(IEnumerable<AbstractPuttySessionsProvider> newProviders)
|
||||
@@ -84,48 +90,58 @@ namespace mRemoteNG.Config.Putty
|
||||
if (!_providers.Contains(providerToRemove)) return;
|
||||
_providers.Remove(providerToRemove);
|
||||
providerToRemove.PuttySessionsCollectionChanged -= RaisePuttySessionCollectionChangedEvent;
|
||||
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, providerToRemove));
|
||||
RaiseSessionProvidersCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
|
||||
providerToRemove));
|
||||
}
|
||||
|
||||
public void PuttySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
AddSessions();
|
||||
}
|
||||
{
|
||||
AddSessions();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
if (!IsProviderEnabled(provider))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sessionNames.AddRange(provider.GetSessionNames(raw));
|
||||
}
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
private bool IsProviderEnabled(AbstractPuttySessionsProvider puttySessionsProvider)
|
||||
{
|
||||
|
||||
private string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
if (!IsProviderEnabled(provider))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sessionNames.AddRange(provider.GetSessionNames(raw));
|
||||
}
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
private bool IsProviderEnabled(AbstractPuttySessionsProvider puttySessionsProvider)
|
||||
{
|
||||
var enabled = true;
|
||||
if (PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.Xming)
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsRegistryProvider)
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsXmingProvider)
|
||||
enabled = false;
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
if (PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.Xming)
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsRegistryProvider)
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsXmingProvider)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Classes
|
||||
|
||||
public class SessionList : StringConverter
|
||||
{
|
||||
public static string[] Names
|
||||
@@ -134,29 +150,32 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
return new StandardValuesCollection(Names);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
{
|
||||
return new StandardValuesCollection(Names);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event NotifyCollectionChangedEventHandler PuttySessionsCollectionChanged;
|
||||
|
||||
protected void RaisePuttySessionCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionsCollectionChanged?.Invoke(sender, args);
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler SessionProvidersCollectionChanged;
|
||||
|
||||
protected void RaiseSessionProvidersCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
SessionProvidersCollectionChanged?.Invoke(this, args);
|
||||
|
||||
@@ -14,30 +14,34 @@ using System.Web;
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
{
|
||||
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
|
||||
private static ManagementEventWatcher _eventWatcher;
|
||||
|
||||
#region Public Methods
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
if (sessionsKey == null) return new string[] {};
|
||||
if (sessionsKey == null) return new string[] { };
|
||||
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var sessionName in sessionsKey.GetSubKeyNames())
|
||||
{
|
||||
sessionNames.Add(raw ? sessionName : HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"), Encoding.GetEncoding("iso-8859-1")));
|
||||
}
|
||||
|
||||
if (raw && !sessionNames.Contains("Default%20Settings"))
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
else if (!raw && !sessionNames.Contains("Default Settings"))
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
foreach (var sessionName in sessionsKey.GetSubKeyNames())
|
||||
{
|
||||
sessionNames.Add(raw
|
||||
? sessionName
|
||||
: HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"),
|
||||
Encoding.GetEncoding("iso-8859-1")));
|
||||
}
|
||||
|
||||
if (raw && !sessionNames.Contains("Default%20Settings"))
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
else if (!raw && !sessionNames.Contains("Default Settings"))
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sessionName))
|
||||
@@ -45,36 +49,36 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
|
||||
if (sessionKey == null) return null;
|
||||
if (sessionKey == null) return null;
|
||||
|
||||
sessionName = HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"), Encoding.GetEncoding("iso-8859-1"));
|
||||
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
// TODO: this should create a temp putty credential
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
|
||||
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
: sessionKey.GetValue("Protocol").ToString();
|
||||
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
int.TryParse(sessionKey.GetValue("SshProt")?.ToString(), out var sshVersion);
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
int.TryParse(sessionKey.GetValue("SshProt")?.ToString(), out var sshVersion);
|
||||
/* Per PUTTY.H in PuTTYNG & PuTTYNG Upstream (PuTTY proper currently)
|
||||
* expect 0 for SSH1, 3 for SSH2 ONLY
|
||||
* 1 for SSH1 with a 2 fallback
|
||||
@@ -83,53 +87,56 @@ namespace mRemoteNG.Config.Putty
|
||||
* default to SSH2 if any other value is received
|
||||
*/
|
||||
sessionInfo.Protocol = sshVersion == 1 || sshVersion == 0 ? ProtocolType.SSH1 : ProtocolType.SSH2;
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
int.TryParse(sessionKey.GetValue("PortNumber")?.ToString(), out var portNumber);
|
||||
if (portNumber == default(int))
|
||||
sessionInfo.SetDefaultPort();
|
||||
else
|
||||
sessionInfo.Port = portNumber;
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null) return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null) return;
|
||||
|
||||
try
|
||||
{
|
||||
var currentUserSid = WindowsIdentity.GetCurrent().User?.Value;
|
||||
var key = string.Join("\\", currentUserSid, PuttySessionsKey).Replace("\\", "\\\\");
|
||||
var query = new WqlEventQuery($"SELECT * FROM RegistryTreeChangeEvent WHERE Hive = \'HKEY_USERS\' AND RootPath = \'{key}\'");
|
||||
_eventWatcher = new ManagementEventWatcher(query);
|
||||
_eventWatcher.EventArrived += OnManagementEventArrived;
|
||||
_eventWatcher.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttySessions.Watcher.StartWatching() failed.", ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
if (_eventWatcher == null) return;
|
||||
_eventWatcher.Stop();
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
var query = new WqlEventQuery(
|
||||
$"SELECT * FROM RegistryTreeChangeEvent WHERE Hive = \'HKEY_USERS\' AND RootPath = \'{key}\'");
|
||||
_eventWatcher = new ManagementEventWatcher(query);
|
||||
_eventWatcher.EventArrived += OnManagementEventArrived;
|
||||
_eventWatcher.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttySessions.Watcher.StartWatching() failed.", ex,
|
||||
MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
if (_eventWatcher == null) return;
|
||||
_eventWatcher.Stop();
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,339 +13,374 @@ using System.Text.RegularExpressions;
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsXmingProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
public override RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo { Name = "Xming Putty Sessions" };
|
||||
{
|
||||
public override RootPuttySessionsNodeInfo RootInfo { get; } =
|
||||
new RootPuttySessionsNodeInfo {Name = "Xming Putty Sessions"};
|
||||
|
||||
private const string RegistrySessionNameFormat = "{0} [registry]";
|
||||
private const string RegistrySessionNamePattern = "(.*)\\ \\[registry\\]";
|
||||
private static readonly PuttySessionsRegistryProvider PuttySessionsRegistryProvider = new PuttySessionsRegistryProvider();
|
||||
|
||||
private static readonly PuttySessionsRegistryProvider PuttySessionsRegistryProvider =
|
||||
new PuttySessionsRegistryProvider();
|
||||
|
||||
private static FileSystemWatcher _eventWatcher;
|
||||
|
||||
#region Public Methods
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return new string[] {};
|
||||
}
|
||||
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return new string[] { };
|
||||
}
|
||||
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
|
||||
{
|
||||
var sessionFileName = Path.GetFileName(sessionName);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
sessionNames.Add(raw ? sessionFileName : System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
|
||||
}
|
||||
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
|
||||
{
|
||||
var sessionFileName = Path.GetFileName(sessionName);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
sessionNames.Add(raw
|
||||
? sessionFileName
|
||||
: System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
|
||||
}
|
||||
|
||||
if (raw)
|
||||
{
|
||||
if (!sessionNames.Contains("Default%20Settings")) // Do not localize
|
||||
{
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sessionNames.Contains("Default Settings"))
|
||||
{
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
}
|
||||
}
|
||||
if (raw)
|
||||
{
|
||||
if (!sessionNames.Contains("Default%20Settings")) // Do not localize
|
||||
{
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sessionNames.Contains("Default Settings"))
|
||||
{
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
}
|
||||
}
|
||||
|
||||
var registrySessionNames = PuttySessionsRegistryProvider.GetSessionNames(raw).Select(sessionName => string.Format(RegistrySessionNameFormat, sessionName)).ToList();
|
||||
var registrySessionNames = PuttySessionsRegistryProvider.GetSessionNames(raw)
|
||||
.Select(sessionName =>
|
||||
string
|
||||
.Format(RegistrySessionNameFormat,
|
||||
sessionName)).ToList();
|
||||
|
||||
sessionNames.AddRange(registrySessionNames);
|
||||
sessionNames.Sort();
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
sessionNames.AddRange(registrySessionNames);
|
||||
sessionNames.Sort();
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
var registrySessionName = GetRegistrySessionName(sessionName);
|
||||
if (!string.IsNullOrEmpty(registrySessionName))
|
||||
{
|
||||
return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(registrySessionName))
|
||||
{
|
||||
return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
|
||||
}
|
||||
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var sessionFile = Path.Combine(sessionsFolderPath, sessionName);
|
||||
if (!File.Exists(sessionFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
|
||||
if (!File.Exists(sessionFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
|
||||
|
||||
var sessionFileReader = new SessionFileReader(sessionFile);
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionFileReader.GetValue("HostName"),
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionFileReader.GetValue("HostName"),
|
||||
// TODO: this should create a temp putty credential
|
||||
Username = sessionFileReader.GetValue("UserName")
|
||||
};
|
||||
var protocol = sessionFileReader.GetValue("Protocol") ?? "ssh";
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
object sshVersionObject = sessionFileReader.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
sessionInfo.Port = Convert.ToInt32(sessionFileReader.GetValue("PortNumber"));
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
};
|
||||
var protocol = sessionFileReader.GetValue("Protocol") ?? "ssh";
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
object sshVersionObject = sessionFileReader.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionInfo.Port = Convert.ToInt32(sessionFileReader.GetValue("PortNumber"));
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, $"XmingPortablePuttySessions.Watcher.StartWatching() failed: '{sessionsFolderPath}' does not exist.", true);
|
||||
return;
|
||||
}
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
$"XmingPortablePuttySessions.Watcher.StartWatching() failed: '{sessionsFolderPath}' does not exist.",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(
|
||||
"XmingPortablePuttySessions.Watcher.StartWatching() failed.",
|
||||
ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StopWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged -= OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eventWatcher.EnableRaisingEvents = false;
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("XmingPortablePuttySessions.Watcher.StartWatching() failed.", ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StopWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged -= OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_eventWatcher.EnableRaisingEvents = false;
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Methods
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath
|
||||
? mRemoteNG.Settings.Default.CustomPuttyPath
|
||||
: App.Info.GeneralAppInfo.PuttyPath;
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
return string.IsNullOrEmpty(puttyPath) ? null : Path.Combine(puttyPath, "putty.conf");
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
{
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
{
|
||||
var puttyConfPath = GetPuttyConfPath();
|
||||
var sessionFileReader = new PuttyConfFileReader(puttyConfPath);
|
||||
var basePath = Environment.ExpandEnvironmentVariables(sessionFileReader.GetValue("sshk&sess"));
|
||||
return Path.Combine(basePath, "sessions");
|
||||
}
|
||||
|
||||
private static string GetRegistrySessionName(string sessionName)
|
||||
{
|
||||
return Path.Combine(basePath, "sessions");
|
||||
}
|
||||
|
||||
private static string GetRegistrySessionName(string sessionName)
|
||||
{
|
||||
var regex = new Regex(RegistrySessionNamePattern);
|
||||
|
||||
var matches = regex.Matches(sessionName);
|
||||
if (matches.Count < 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (matches.Count < 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var groups = matches[0].Groups;
|
||||
return groups.Count < 1 ? string.Empty : groups[1].Value;
|
||||
}
|
||||
|
||||
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (sessionInfo == null)
|
||||
return null;
|
||||
return groups.Count < 1 ? string.Empty : groups[1].Value;
|
||||
}
|
||||
|
||||
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (sessionInfo == null)
|
||||
return null;
|
||||
|
||||
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
|
||||
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
private void OnFileSystemEventArrived(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnRegistrySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
|
||||
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
private void OnFileSystemEventArrived(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnRegistrySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Classes
|
||||
private class PuttyConfFileReader
|
||||
{
|
||||
public PuttyConfFileReader(string puttyConfFile)
|
||||
{
|
||||
_puttyConfFile = puttyConfFile;
|
||||
}
|
||||
|
||||
private string _puttyConfFile;
|
||||
private bool _configurationLoaded;
|
||||
private Dictionary<string, string> _configuration = new Dictionary<string, string>();
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
_configurationLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_puttyConfFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var streamReader = new StreamReader(_puttyConfFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
line = line.Trim();
|
||||
if (line == string.Empty)
|
||||
{
|
||||
continue; // Blank line
|
||||
}
|
||||
if (line.Substring(0, 1) == ";")
|
||||
{
|
||||
continue; // Comment
|
||||
}
|
||||
|
||||
private class PuttyConfFileReader
|
||||
{
|
||||
public PuttyConfFileReader(string puttyConfFile)
|
||||
{
|
||||
_puttyConfFile = puttyConfFile;
|
||||
}
|
||||
|
||||
private string _puttyConfFile;
|
||||
private bool _configurationLoaded;
|
||||
private Dictionary<string, string> _configuration = new Dictionary<string, string>();
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
_configurationLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_puttyConfFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var streamReader = new StreamReader(_puttyConfFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
line = line.Trim();
|
||||
if (line == string.Empty)
|
||||
{
|
||||
continue; // Blank line
|
||||
}
|
||||
|
||||
if (line.Substring(0, 1) == ";")
|
||||
{
|
||||
continue; // Comment
|
||||
}
|
||||
|
||||
var parts = line.Split(new[] {'='}, 2);
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (_configuration.ContainsKey(parts[0]))
|
||||
{
|
||||
continue; // As per http://www.straightrunning.com/XmingNotes/portableputty.php only first entry is used
|
||||
}
|
||||
_configuration.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttyConfFileReader.LoadConfiguration() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_configurationLoaded)
|
||||
{
|
||||
LoadConfiguration();
|
||||
}
|
||||
return !_configuration.ContainsKey(setting) ? string.Empty : _configuration[setting];
|
||||
}
|
||||
}
|
||||
|
||||
private class SessionFileReader
|
||||
{
|
||||
public SessionFileReader(string sessionFile)
|
||||
{
|
||||
_sessionFile = sessionFile;
|
||||
}
|
||||
|
||||
private string _sessionFile;
|
||||
private bool _sessionInfoLoaded;
|
||||
private Dictionary<string, string> _sessionInfo = new Dictionary<string, string>();
|
||||
|
||||
private void LoadSessionInfo()
|
||||
{
|
||||
_sessionInfoLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_sessionFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var streamReader = new StreamReader(_sessionFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_configuration.ContainsKey(parts[0]))
|
||||
{
|
||||
continue; // As per http://www.straightrunning.com/XmingNotes/portableputty.php only first entry is used
|
||||
}
|
||||
|
||||
_configuration.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttyConfFileReader.LoadConfiguration() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_configurationLoaded)
|
||||
{
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
return !_configuration.ContainsKey(setting) ? string.Empty : _configuration[setting];
|
||||
}
|
||||
}
|
||||
|
||||
private class SessionFileReader
|
||||
{
|
||||
public SessionFileReader(string sessionFile)
|
||||
{
|
||||
_sessionFile = sessionFile;
|
||||
}
|
||||
|
||||
private string _sessionFile;
|
||||
private bool _sessionInfoLoaded;
|
||||
private Dictionary<string, string> _sessionInfo = new Dictionary<string, string>();
|
||||
|
||||
private void LoadSessionInfo()
|
||||
{
|
||||
_sessionInfoLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_sessionFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var streamReader = new StreamReader(_sessionFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var parts = line.Split('\\');
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_sessionInfo.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("SessionFileReader.LoadSessionInfo() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_sessionInfoLoaded)
|
||||
{
|
||||
LoadSessionInfo();
|
||||
}
|
||||
return !_sessionInfo.ContainsKey(setting) ? string.Empty : _sessionInfo[setting];
|
||||
}
|
||||
}
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_sessionInfo.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("SessionFileReader.LoadSessionInfo() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_sessionInfoLoaded)
|
||||
{
|
||||
LoadSessionInfo();
|
||||
}
|
||||
|
||||
return !_sessionInfo.ContainsKey(setting) ? string.Empty : _sessionInfo[setting];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public SerializationResult Deserialize(string serializedData)
|
||||
{
|
||||
var lines = serializedData.Split(new []{"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var lines = serializedData.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var csvHeaders = new List<string>();
|
||||
// used to map a connectioninfo to it's parent's GUID
|
||||
var parentMapping = new Dictionary<ConnectionInfo, string>();
|
||||
@@ -72,9 +72,9 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
|
||||
// search for parent in the list by GUID
|
||||
var parent = parentMapping
|
||||
.Keys
|
||||
.OfType<ContainerInfo>()
|
||||
.FirstOrDefault(info => info.ConstantID == node.Value);
|
||||
.Keys
|
||||
.OfType<ContainerInfo>()
|
||||
.FirstOrDefault(info => info.ConstantID == node.Value);
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
private ConnectionInfo ParseConnectionInfo(IList<string> headers, string[] connectionCsv)
|
||||
{
|
||||
var nodeType = headers.Contains("NodeType")
|
||||
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
|
||||
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
|
||||
: TreeNodeType.Connection;
|
||||
|
||||
var nodeId = headers.Contains("Id")
|
||||
@@ -104,7 +104,8 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
: new ContainerInfo(nodeId);
|
||||
|
||||
connectionRecord.Name = headers.Contains("Name") ? connectionCsv[headers.IndexOf("Name")] : "";
|
||||
connectionRecord.Description = headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
|
||||
connectionRecord.Description =
|
||||
headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
|
||||
connectionRecord.Icon = headers.Contains("Icon") ? connectionCsv[headers.IndexOf("Icon")] : "";
|
||||
connectionRecord.Panel = headers.Contains("Panel") ? connectionCsv[headers.IndexOf("Panel")] : "";
|
||||
|
||||
@@ -119,20 +120,40 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
connectionRecord.Domain = headers.Contains("Domain") ? connectionCsv[headers.IndexOf("Domain")] : "";
|
||||
|
||||
connectionRecord.Hostname = headers.Contains("Hostname") ? connectionCsv[headers.IndexOf("Hostname")] : "";
|
||||
connectionRecord.PuttySession = headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
|
||||
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo") ? connectionCsv[headers.IndexOf("LoadBalanceInfo")] : "";
|
||||
connectionRecord.PreExtApp = headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
|
||||
connectionRecord.PostExtApp = headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
|
||||
connectionRecord.MacAddress = headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
|
||||
connectionRecord.UserField = headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
|
||||
connectionRecord.PuttySession =
|
||||
headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
|
||||
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo")
|
||||
? connectionCsv[headers.IndexOf("LoadBalanceInfo")]
|
||||
: "";
|
||||
connectionRecord.PreExtApp =
|
||||
headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
|
||||
connectionRecord.PostExtApp =
|
||||
headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
|
||||
connectionRecord.MacAddress =
|
||||
headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
|
||||
connectionRecord.UserField =
|
||||
headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
|
||||
connectionRecord.ExtApp = headers.Contains("ExtApp") ? connectionCsv[headers.IndexOf("ExtApp")] : "";
|
||||
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername") ? connectionCsv[headers.IndexOf("VNCProxyUsername")] : "";
|
||||
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword") ? connectionCsv[headers.IndexOf("VNCProxyPassword")] : "";
|
||||
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername") ? connectionCsv[headers.IndexOf("RDGatewayUsername")] : "";
|
||||
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword") ? connectionCsv[headers.IndexOf("RDGatewayPassword")] : "";
|
||||
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain") ? connectionCsv[headers.IndexOf("RDGatewayDomain")] : "";
|
||||
connectionRecord.VNCProxyIP = headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
|
||||
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname") ? connectionCsv[headers.IndexOf("RDGatewayHostname")] : "";
|
||||
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername")
|
||||
? connectionCsv[headers.IndexOf("VNCProxyUsername")]
|
||||
: "";
|
||||
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword")
|
||||
? connectionCsv[headers.IndexOf("VNCProxyPassword")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayUsername")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayPassword")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayDomain")]
|
||||
: "";
|
||||
connectionRecord.VNCProxyIP =
|
||||
headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
|
||||
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayHostname")]
|
||||
: "";
|
||||
|
||||
if (headers.Contains("CredentialId"))
|
||||
{
|
||||
@@ -247,6 +268,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out bool value))
|
||||
connectionRecord.RedirectPrinters = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectClipboard"))
|
||||
{
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectClipboard")], out bool value))
|
||||
@@ -332,6 +354,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
}
|
||||
|
||||
#region Inheritance
|
||||
|
||||
if (headers.Contains("InheritCacheBitmaps"))
|
||||
{
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCacheBitmaps")], out bool value))
|
||||
@@ -622,7 +645,8 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
|
||||
if (headers.Contains("InheritRDGatewayUseConnectionCredentials"))
|
||||
{
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out bool value))
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")],
|
||||
out var value))
|
||||
connectionRecord.Inheritance.RDGatewayUseConnectionCredentials = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@ using System.Text;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo, string>
|
||||
{
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter,
|
||||
ICredentialRepositoryList credentialRepositoryList)
|
||||
{
|
||||
saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
|
||||
@@ -106,52 +107,52 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
.Append(FormatForCsv(con.CredentialRecordId));
|
||||
|
||||
sb.Append(FormatForCsv(con.Hostname))
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.Port))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.UseCredSsp))
|
||||
.Append(FormatForCsv(con.RenderingEngine))
|
||||
.Append(FormatForCsv(con.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Colors))
|
||||
.Append(FormatForCsv(con.Resolution))
|
||||
.Append(FormatForCsv(con.AutomaticResize))
|
||||
.Append(FormatForCsv(con.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.DisplayThemes))
|
||||
.Append(FormatForCsv(con.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.RedirectPorts))
|
||||
.Append(FormatForCsv(con.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.RedirectSound))
|
||||
.Append(FormatForCsv(con.RedirectKeys))
|
||||
.Append(FormatForCsv(con.PreExtApp))
|
||||
.Append(FormatForCsv(con.PostExtApp))
|
||||
.Append(FormatForCsv(con.MacAddress))
|
||||
.Append(FormatForCsv(con.UserField))
|
||||
.Append(FormatForCsv(con.ExtApp))
|
||||
.Append(FormatForCsv(con.VNCCompression))
|
||||
.Append(FormatForCsv(con.VNCEncoding))
|
||||
.Append(FormatForCsv(con.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.VNCProxyType))
|
||||
.Append(FormatForCsv(con.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.VNCColors))
|
||||
.Append(FormatForCsv(con.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.RDGatewayDomain));
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.Port))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.UseCredSsp))
|
||||
.Append(FormatForCsv(con.RenderingEngine))
|
||||
.Append(FormatForCsv(con.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Colors))
|
||||
.Append(FormatForCsv(con.Resolution))
|
||||
.Append(FormatForCsv(con.AutomaticResize))
|
||||
.Append(FormatForCsv(con.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.DisplayThemes))
|
||||
.Append(FormatForCsv(con.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.RedirectPorts))
|
||||
.Append(FormatForCsv(con.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.RedirectSound))
|
||||
.Append(FormatForCsv(con.RedirectKeys))
|
||||
.Append(FormatForCsv(con.PreExtApp))
|
||||
.Append(FormatForCsv(con.PostExtApp))
|
||||
.Append(FormatForCsv(con.MacAddress))
|
||||
.Append(FormatForCsv(con.UserField))
|
||||
.Append(FormatForCsv(con.ExtApp))
|
||||
.Append(FormatForCsv(con.VNCCompression))
|
||||
.Append(FormatForCsv(con.VNCEncoding))
|
||||
.Append(FormatForCsv(con.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.VNCProxyType))
|
||||
.Append(FormatForCsv(con.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.VNCColors))
|
||||
.Append(FormatForCsv(con.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.RDGatewayDomain));
|
||||
|
||||
|
||||
if (!_saveFilter.SaveInheritance)
|
||||
|
||||
@@ -51,20 +51,21 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
|
||||
{
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
PopulateConnectionInfoFromDataRow(row, connectionInfo);
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private ContainerInfo DeserializeContainerInfo(DataRow row)
|
||||
{
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerInfo = new ContainerInfo(containerId);
|
||||
PopulateConnectionInfoFromDataRow(row, containerInfo);
|
||||
return containerInfo;
|
||||
@@ -96,14 +97,22 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.Port = (int)dataRow["Port"];
|
||||
connectionInfo.UseConsoleSession = (bool)dataRow["ConnectToConsole"];
|
||||
connectionInfo.UseCredSsp = (bool)dataRow["UseCredSsp"];
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), (string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength), (string)dataRow["ICAEncryptionStrength"]);
|
||||
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine),
|
||||
(string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.ICAEncryptionStrength =
|
||||
(IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength),
|
||||
(string)dataRow["ICAEncryptionStrength"]);
|
||||
connectionInfo.RDPAuthenticationLevel =
|
||||
(RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel),
|
||||
(string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
|
||||
connectionInfo.RDPAlertIdleTimeout = (bool)dataRow["RDPAlertIdleTimeout"];
|
||||
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors) ,(string)dataRow["Colors"]);
|
||||
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), (string)dataRow["Resolution"]);
|
||||
connectionInfo.Colors =
|
||||
(RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), (string)dataRow["Colors"]);
|
||||
connectionInfo.Resolution =
|
||||
(RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions),
|
||||
(string)dataRow["Resolution"]);
|
||||
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
|
||||
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
|
||||
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
|
||||
@@ -115,28 +124,44 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
|
||||
connectionInfo.RedirectClipboard = (bool)dataRow["RedirectClipboard"];
|
||||
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
|
||||
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), (string)dataRow["SoundQuality"]);
|
||||
connectionInfo.RedirectSound =
|
||||
(RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality),
|
||||
(string)dataRow["SoundQuality"]);
|
||||
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
|
||||
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
|
||||
connectionInfo.PostExtApp = (string)dataRow["PostExtApp"];
|
||||
connectionInfo.MacAddress = (string)dataRow["MacAddress"];
|
||||
connectionInfo.UserField = (string)dataRow["UserField"];
|
||||
connectionInfo.ExtApp = (string)dataRow["ExtApp"];
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), (string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding) ,(string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression),
|
||||
(string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding =
|
||||
(ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), (string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCAuthMode =
|
||||
(ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCProxyType =
|
||||
(ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCProxyIP = (string)dataRow["VNCProxyIP"];
|
||||
connectionInfo.VNCProxyPort = (int)dataRow["VNCProxyPort"];
|
||||
connectionInfo.VNCProxyUsername = (string)dataRow["VNCProxyUsername"];
|
||||
connectionInfo.VNCProxyPassword = DecryptValue((string)dataRow["VNCProxyPassword"]);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), (string)dataRow["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCColors =
|
||||
(ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode),
|
||||
(string)dataRow
|
||||
["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCViewOnly = (bool)dataRow["VNCViewOnly"];
|
||||
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
(RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod),
|
||||
(string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUseConnectionCredentials =
|
||||
(RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(
|
||||
typeof(RdpProtocol.
|
||||
RDGatewayUseConnectionCredentials),
|
||||
(string)dataRow
|
||||
["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
|
||||
connectionInfo.RDGatewayPassword = DecryptValue((string)dataRow["RDGatewayPassword"]);
|
||||
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
|
||||
@@ -189,7 +214,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.Inheritance.VNCViewOnly = (bool)dataRow["InheritVNCViewOnly"];
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = (bool)dataRow["InheritRDGatewayUsageMethod"];
|
||||
connectionInfo.Inheritance.RDGatewayHostname = (bool)dataRow["InheritRDGatewayHostname"];
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = (bool)dataRow["InheritRDGatewayUseConnectionCredentials"];
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials =
|
||||
(bool)dataRow["InheritRDGatewayUseConnectionCredentials"];
|
||||
connectionInfo.Inheritance.RDGatewayUsername = (bool)dataRow["InheritRDGatewayUsername"];
|
||||
connectionInfo.Inheritance.RDGatewayPassword = (bool)dataRow["InheritRDGatewayPassword"];
|
||||
connectionInfo.Inheritance.RDGatewayDomain = (bool)dataRow["InheritRDGatewayDomain"];
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Security;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.MsSql
|
||||
{
|
||||
public class DataTableSerializer : ISerializer<ConnectionInfo,DataTable>
|
||||
public class DataTableSerializer : ISerializer<ConnectionInfo, DataTable>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -23,7 +23,9 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public DataTableSerializer(SaveFilter saveFilter, ICryptographyProvider cryptographyProvider, SecureString encryptionKey)
|
||||
public DataTableSerializer(SaveFilter saveFilter,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey)
|
||||
{
|
||||
_saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
@@ -187,7 +189,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
private void SetPrimaryKey(DataTable dataTable)
|
||||
{
|
||||
dataTable.PrimaryKey = new[] { dataTable.Columns["ConstantID"] };
|
||||
dataTable.PrimaryKey = new[] {dataTable.Columns["ConstantID"]};
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo connectionInfo)
|
||||
@@ -255,14 +257,16 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["VNCProxyIP"] = connectionInfo.VNCProxyIP;
|
||||
dataRow["VNCProxyPort"] = connectionInfo.VNCProxyPort;
|
||||
dataRow["VNCProxyUsername"] = connectionInfo.VNCProxyUsername;
|
||||
dataRow["VNCProxyPassword"] = _cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey);
|
||||
dataRow["VNCProxyPassword"] =
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey);
|
||||
dataRow["VNCColors"] = connectionInfo.VNCColors;
|
||||
dataRow["VNCSmartSizeMode"] = connectionInfo.VNCSmartSizeMode;
|
||||
dataRow["VNCViewOnly"] = connectionInfo.VNCViewOnly;
|
||||
dataRow["RDGatewayUsageMethod"] = connectionInfo.RDGatewayUsageMethod;
|
||||
dataRow["RDGatewayHostname"] = connectionInfo.RDGatewayHostname;
|
||||
dataRow["RDGatewayUseConnectionCredentials"] = connectionInfo.RDGatewayUseConnectionCredentials;
|
||||
dataRow["RDGatewayUsername"] = _cryptographyProvider.Encrypt(connectionInfo.RDGatewayUsername, _encryptionKey);
|
||||
dataRow["RDGatewayUsername"] =
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayUsername, _encryptionKey);
|
||||
dataRow["RDGatewayPassword"] = connectionInfo.RDGatewayPassword;
|
||||
dataRow["RDGatewayDomain"] = connectionInfo.RDGatewayDomain;
|
||||
if (_saveFilter.SaveInheritance)
|
||||
@@ -315,7 +319,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["InheritVNCViewOnly"] = connectionInfo.Inheritance.VNCViewOnly;
|
||||
dataRow["InheritRDGatewayUsageMethod"] = connectionInfo.Inheritance.RDGatewayUsageMethod;
|
||||
dataRow["InheritRDGatewayHostname"] = connectionInfo.Inheritance.RDGatewayHostname;
|
||||
dataRow["InheritRDGatewayUseConnectionCredentials"] = connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
|
||||
dataRow["InheritRDGatewayUseConnectionCredentials"] =
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
|
||||
dataRow["InheritRDGatewayUsername"] = connectionInfo.Inheritance.RDGatewayUsername;
|
||||
dataRow["InheritRDGatewayPassword"] = connectionInfo.Inheritance.RDGatewayPassword;
|
||||
dataRow["InheritRDGatewayDomain"] = connectionInfo.Inheritance.RDGatewayDomain;
|
||||
@@ -375,6 +380,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["InheritRDGatewayPassword"] = false;
|
||||
dataRow["InheritRDGatewayDomain"] = false;
|
||||
}
|
||||
|
||||
_dataTable.Rows.Add(dataRow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/// </summary>
|
||||
public bool Expanded { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ using System.Xml.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.MsSql
|
||||
{
|
||||
public class LocalConnectionPropertiesXmlSerializer :
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>,
|
||||
public class LocalConnectionPropertiesXmlSerializer :
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>,
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>
|
||||
{
|
||||
public Version Version { get; } = new Version(1, 0);
|
||||
@@ -17,10 +17,10 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
public string Serialize(IEnumerable<LocalConnectionPropertiesModel> models)
|
||||
{
|
||||
var localConnections = models
|
||||
.Select(m => new XElement("Node",
|
||||
new XAttribute("ConnectionId", m.ConnectionId),
|
||||
new XAttribute("Connected", m.Connected),
|
||||
new XAttribute("Expanded", m.Expanded)));
|
||||
.Select(m => new XElement("Node",
|
||||
new XAttribute("ConnectionId", m.ConnectionId),
|
||||
new XAttribute("Connected", m.Connected),
|
||||
new XAttribute("Expanded", m.Expanded)));
|
||||
|
||||
var root = new XElement("LocalConnections", localConnections);
|
||||
var xdoc = new XDocument(new XDeclaration("1.0", "utf-8", null), root);
|
||||
@@ -34,20 +34,21 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
var xdoc = XDocument.Parse(serializedData);
|
||||
return xdoc
|
||||
.Descendants("Node")
|
||||
.Where(e => e.Attribute("ConnectionId") != null)
|
||||
.Select(e => new LocalConnectionPropertiesModel
|
||||
{
|
||||
ConnectionId = e.Attribute("ConnectionId")?.Value,
|
||||
Connected = bool.Parse(e.Attribute("Connected")?.Value ?? "False"),
|
||||
Expanded = bool.Parse(e.Attribute("Expanded")?.Value ?? "False")
|
||||
});
|
||||
.Descendants("Node")
|
||||
.Where(e => e.Attribute("ConnectionId") != null)
|
||||
.Select(e => new LocalConnectionPropertiesModel
|
||||
{
|
||||
ConnectionId = e.Attribute("ConnectionId")?.Value,
|
||||
Connected = bool.Parse(e.Attribute("Connected")?.Value ?? "False"),
|
||||
Expanded = bool.Parse(e.Attribute("Expanded")?.Value ?? "False")
|
||||
});
|
||||
}
|
||||
|
||||
private static string WriteXmlToString(XNode xmlDocument)
|
||||
{
|
||||
string xmlString;
|
||||
var xmlWriterSettings = new XmlWriterSettings { Indent = true, IndentChars = " ", Encoding = Encoding.UTF8 };
|
||||
var xmlWriterSettings = new XmlWriterSettings
|
||||
{Indent = true, IndentChars = " ", Encoding = Encoding.UTF8};
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var xmlTextWriter = XmlWriter.Create(memoryStream, xmlWriterSettings))
|
||||
{
|
||||
@@ -57,7 +58,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
xmlString = streamReader.ReadToEnd();
|
||||
}
|
||||
|
||||
return xmlString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
public bool Export { get; set; }
|
||||
public Version ConfVersion { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
Name = sqlDataReader["Name"] as string ?? "",
|
||||
Protected = sqlDataReader["Protected"] as string ?? "",
|
||||
Export = (bool)sqlDataReader["Export"],
|
||||
ConfVersion = new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture))
|
||||
ConfVersion =
|
||||
new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture))
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -42,6 +43,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
if (sqlDataReader != null && !sqlDataReader.IsClosed)
|
||||
sqlDataReader.Close();
|
||||
}
|
||||
|
||||
return metaData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Xml.Linq;
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo,XElement>
|
||||
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -16,7 +16,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
public Version Version { get; } = new Version(2, 6);
|
||||
|
||||
public XmlConnectionNodeSerializer26(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
|
||||
public XmlConnectionNodeSerializer26(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
@@ -52,15 +54,16 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
// TODO: remove
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
|
||||
if (_saveFilter.SavePassword && !connectionInfo.Inheritance.Password)
|
||||
element.Add(new XAttribute("Password", _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
element.Add(new XAttribute("Password",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
else
|
||||
element.Add(new XAttribute("Password", ""));
|
||||
|
||||
@@ -68,31 +71,42 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("ConnectToConsole",
|
||||
connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
|
||||
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
|
||||
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
|
||||
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout",
|
||||
connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
|
||||
element.Add(new XAttribute("Colors", connectionInfo.Colors));
|
||||
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("AutomaticResize",
|
||||
connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper",
|
||||
connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing",
|
||||
connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition",
|
||||
connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives",
|
||||
connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard", connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters",
|
||||
connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard",
|
||||
connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards",
|
||||
connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected",
|
||||
(connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
@@ -106,93 +120,163 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("VNCProxyPort", connectionInfo.VNCProxyPort));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
|
||||
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
|
||||
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
|
||||
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials",
|
||||
connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
}
|
||||
|
||||
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
|
||||
{
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritCacheBitmaps",
|
||||
connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors",
|
||||
connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription",
|
||||
connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes",
|
||||
connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper",
|
||||
connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing",
|
||||
connectionInfo
|
||||
.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition",
|
||||
connectionInfo
|
||||
.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain",
|
||||
connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritIcon",
|
||||
connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel",
|
||||
connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword",
|
||||
connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritPort",
|
||||
connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol",
|
||||
connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession",
|
||||
connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys",
|
||||
connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts",
|
||||
connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters",
|
||||
connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound",
|
||||
connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality",
|
||||
connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution",
|
||||
connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize",
|
||||
connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession",
|
||||
connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp",
|
||||
connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine",
|
||||
connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername",
|
||||
connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength",
|
||||
connectionInfo
|
||||
.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo",
|
||||
connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp",
|
||||
connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp",
|
||||
connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress",
|
||||
connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField",
|
||||
connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp",
|
||||
connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression",
|
||||
connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding",
|
||||
connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode",
|
||||
connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType",
|
||||
connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP",
|
||||
connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort",
|
||||
connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername",
|
||||
connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword",
|
||||
connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors",
|
||||
connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode",
|
||||
connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly",
|
||||
connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname",
|
||||
connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUseConnectionCredentials.ToString()
|
||||
.ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername",
|
||||
connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword",
|
||||
connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain",
|
||||
connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,7 +298,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
|
||||
@@ -10,7 +10,7 @@ using mRemoteNG.Tools;
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo,XElement>
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -18,7 +18,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_encryptionKey = encryptionKey.ThrowIfNull(nameof(encryptionKey));
|
||||
@@ -50,31 +52,42 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("ConnectToConsole",
|
||||
connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
|
||||
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
|
||||
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
|
||||
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout",
|
||||
connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
|
||||
element.Add(new XAttribute("Colors", connectionInfo.Colors));
|
||||
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("AutomaticResize",
|
||||
connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper",
|
||||
connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing",
|
||||
connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition",
|
||||
connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives",
|
||||
connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard", connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters",
|
||||
connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard",
|
||||
connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards",
|
||||
connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected",
|
||||
(connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
@@ -88,33 +101,36 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("VNCProxyPort", connectionInfo.VNCProxyPort));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
|
||||
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
|
||||
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
|
||||
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials",
|
||||
connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
}
|
||||
|
||||
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
|
||||
@@ -194,8 +210,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
|
||||
@@ -101,7 +101,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private void ValidateConnectionFileVersion()
|
||||
{
|
||||
if (_xmlDocument.DocumentElement != null && _xmlDocument.DocumentElement.HasAttribute("ConfVersion"))
|
||||
_confVersion = Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."), CultureInfo.InvariantCulture);
|
||||
_confVersion =
|
||||
Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."),
|
||||
CultureInfo.InvariantCulture);
|
||||
else
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strOldConffile);
|
||||
|
||||
@@ -113,19 +115,22 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private void ShowIncompatibleVersionDialogBox()
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
FrmMain.Default,
|
||||
Application.ProductName,
|
||||
"Incompatible connection file format",
|
||||
$"The format of this connection file is not supported. Please upgrade to a newer version of {Application.ProductName}.",
|
||||
string.Format("{1}{0}File Format Version: {2}{0}Highest Supported Version: {3}", Environment.NewLine, ConnectionFileName, _confVersion, MaxSupportedConfVersion),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
ETaskDialogButtons.Ok,
|
||||
ESysIcons.Error,
|
||||
ESysIcons.Error
|
||||
);
|
||||
FrmMain.Default,
|
||||
Application.ProductName,
|
||||
"Incompatible connection file format",
|
||||
$"The format of this connection file is not supported. Please upgrade to a newer version of {Application.ProductName}.",
|
||||
string
|
||||
.Format("{1}{0}File Format Version: {2}{0}Highest Supported Version: {3}",
|
||||
Environment.NewLine,
|
||||
ConnectionFileName, _confVersion, MaxSupportedConfVersion),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
ETaskDialogButtons.Ok,
|
||||
ESysIcons.Error,
|
||||
ESysIcons.Error
|
||||
);
|
||||
}
|
||||
|
||||
private RootNodeInfo InitializeRootNode(XmlElement connectionsRootElement)
|
||||
@@ -179,7 +184,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
break;
|
||||
case TreeNodeType.Container:
|
||||
var containerInfo = new ContainerInfo();
|
||||
|
||||
|
||||
if (_confVersion >= 0.9)
|
||||
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode, credentialMap));
|
||||
if (_confVersion >= 0.8)
|
||||
@@ -208,10 +213,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (xmlnode?.Attributes == null)
|
||||
return null;
|
||||
|
||||
var connectionId = xmlnode.GetAttributeAsString("Id");
|
||||
var connectionId = xmlnode.GetAttributeAsString("Id");
|
||||
if (string.IsNullOrWhiteSpace(connectionId))
|
||||
connectionId = Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -274,7 +279,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
if (_confVersion < 0.7)
|
||||
{
|
||||
connectionInfo.Port = xmlnode.GetAttributeAsBool("UseVNC")
|
||||
connectionInfo.Port = xmlnode.GetAttributeAsBool("UseVNC")
|
||||
? xmlnode.GetAttributeAsInt("VNCPort")
|
||||
: xmlnode.GetAttributeAsInt("RDPPort");
|
||||
}
|
||||
@@ -290,6 +295,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
else
|
||||
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
|
||||
}
|
||||
|
||||
connectionInfo.UseConsoleSession = false;
|
||||
}
|
||||
|
||||
@@ -303,7 +309,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
else
|
||||
{
|
||||
connectionInfo.RedirectDiskDrives = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPorts = false;
|
||||
connectionInfo.RedirectSmartCards = false;
|
||||
}
|
||||
@@ -368,14 +374,17 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.Inheritance.Port = xmlnode.GetAttributeAsBool("InheritPort");
|
||||
connectionInfo.Inheritance.Protocol = xmlnode.GetAttributeAsBool("InheritProtocol");
|
||||
connectionInfo.Inheritance.PuttySession = xmlnode.GetAttributeAsBool("InheritPuttySession");
|
||||
connectionInfo.Inheritance.RedirectDiskDrives = xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
|
||||
connectionInfo.Inheritance.RedirectDiskDrives =
|
||||
xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
|
||||
connectionInfo.Inheritance.RedirectKeys = xmlnode.GetAttributeAsBool("InheritRedirectKeys");
|
||||
connectionInfo.Inheritance.RedirectPorts = xmlnode.GetAttributeAsBool("InheritRedirectPorts");
|
||||
connectionInfo.Inheritance.RedirectPrinters = xmlnode.GetAttributeAsBool("InheritRedirectPrinters");
|
||||
connectionInfo.Inheritance.RedirectSmartCards = xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
|
||||
connectionInfo.Inheritance.RedirectSmartCards =
|
||||
xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
|
||||
connectionInfo.Inheritance.RedirectSound = xmlnode.GetAttributeAsBool("InheritRedirectSound");
|
||||
connectionInfo.Inheritance.Resolution = xmlnode.GetAttributeAsBool("InheritResolution");
|
||||
connectionInfo.Inheritance.UseConsoleSession = xmlnode.GetAttributeAsBool("InheritUseConsoleSession");
|
||||
connectionInfo.Inheritance.UseConsoleSession =
|
||||
xmlnode.GetAttributeAsBool("InheritUseConsoleSession");
|
||||
|
||||
if (!Runtime.UseCredentialManager || _confVersion <= 2.6) // 1.3 - 2.6
|
||||
{
|
||||
@@ -383,6 +392,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.Inheritance.Password = xmlnode.GetAttributeAsBool("InheritPassword");
|
||||
connectionInfo.Inheritance.Username = xmlnode.GetAttributeAsBool("InheritUsername");
|
||||
}
|
||||
|
||||
connectionInfo.Icon = xmlnode.GetAttributeAsString("Icon");
|
||||
connectionInfo.Panel = xmlnode.GetAttributeAsString("Panel");
|
||||
}
|
||||
@@ -401,8 +411,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.6)
|
||||
{
|
||||
connectionInfo.ICAEncryptionStrength = xmlnode.GetAttributeAsEnum<IcaProtocol.EncryptionStrength>("ICAEncryptionStrength");
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength = xmlnode.GetAttributeAsBool("InheritICAEncryptionStrength");
|
||||
connectionInfo.ICAEncryptionStrength =
|
||||
xmlnode.GetAttributeAsEnum<IcaProtocol.EncryptionStrength>("ICAEncryptionStrength");
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength =
|
||||
xmlnode.GetAttributeAsBool("InheritICAEncryptionStrength");
|
||||
connectionInfo.PreExtApp = xmlnode.GetAttributeAsString("PreExtApp");
|
||||
connectionInfo.PostExtApp = xmlnode.GetAttributeAsString("PostExtApp");
|
||||
connectionInfo.Inheritance.PreExtApp = xmlnode.GetAttributeAsBool("InheritPreExtApp");
|
||||
@@ -411,16 +423,19 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.7)
|
||||
{
|
||||
connectionInfo.VNCCompression = xmlnode.GetAttributeAsEnum<ProtocolVNC.Compression>("VNCCompression");
|
||||
connectionInfo.VNCCompression =
|
||||
xmlnode.GetAttributeAsEnum<ProtocolVNC.Compression>("VNCCompression");
|
||||
connectionInfo.VNCEncoding = xmlnode.GetAttributeAsEnum<ProtocolVNC.Encoding>("VNCEncoding");
|
||||
connectionInfo.VNCAuthMode = xmlnode.GetAttributeAsEnum<ProtocolVNC.AuthMode>("VNCAuthMode");
|
||||
connectionInfo.VNCProxyType = xmlnode.GetAttributeAsEnum<ProtocolVNC.ProxyType>("VNCProxyType");
|
||||
connectionInfo.VNCProxyIP = xmlnode.GetAttributeAsString("VNCProxyIP");
|
||||
connectionInfo.VNCProxyPort = xmlnode.GetAttributeAsInt("VNCProxyPort");
|
||||
connectionInfo.VNCProxyUsername = xmlnode.GetAttributeAsString("VNCProxyUsername");
|
||||
connectionInfo.VNCProxyPassword = _decryptor.Decrypt(xmlnode.GetAttributeAsString("VNCProxyPassword"));
|
||||
connectionInfo.VNCProxyPassword =
|
||||
_decryptor.Decrypt(xmlnode.GetAttributeAsString("VNCProxyPassword"));
|
||||
connectionInfo.VNCColors = xmlnode.GetAttributeAsEnum<ProtocolVNC.Colors>("VNCColors");
|
||||
connectionInfo.VNCSmartSizeMode = xmlnode.GetAttributeAsEnum<ProtocolVNC.SmartSizeMode>("VNCSmartSizeMode");
|
||||
connectionInfo.VNCSmartSizeMode =
|
||||
xmlnode.GetAttributeAsEnum<ProtocolVNC.SmartSizeMode>("VNCSmartSizeMode");
|
||||
connectionInfo.VNCViewOnly = xmlnode.GetAttributeAsBool("VNCViewOnly");
|
||||
connectionInfo.Inheritance.VNCCompression = xmlnode.GetAttributeAsBool("InheritVNCCompression");
|
||||
connectionInfo.Inheritance.VNCEncoding = xmlnode.GetAttributeAsBool("InheritVNCEncoding");
|
||||
@@ -437,13 +452,16 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.8)
|
||||
{
|
||||
connectionInfo.RDPAuthenticationLevel = xmlnode.GetAttributeAsEnum<RdpProtocol.AuthenticationLevel>("RDPAuthenticationLevel");
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel = xmlnode.GetAttributeAsBool("InheritRDPAuthenticationLevel");
|
||||
connectionInfo.RDPAuthenticationLevel =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.AuthenticationLevel>("RDPAuthenticationLevel");
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPAuthenticationLevel");
|
||||
}
|
||||
|
||||
if (_confVersion >= 1.9)
|
||||
{
|
||||
connectionInfo.RenderingEngine = xmlnode.GetAttributeAsEnum<HTTPBase.RenderingEngine>("RenderingEngine");
|
||||
connectionInfo.RenderingEngine =
|
||||
xmlnode.GetAttributeAsEnum<HTTPBase.RenderingEngine>("RenderingEngine");
|
||||
connectionInfo.MacAddress = xmlnode.GetAttributeAsString("MacAddress");
|
||||
connectionInfo.Inheritance.RenderingEngine = xmlnode.GetAttributeAsBool("InheritRenderingEngine");
|
||||
connectionInfo.Inheritance.MacAddress = xmlnode.GetAttributeAsBool("InheritMacAddress");
|
||||
@@ -464,19 +482,28 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (_confVersion >= 2.2)
|
||||
{
|
||||
// Get settings
|
||||
connectionInfo.RDGatewayUsageMethod = xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUsageMethod>("RDGatewayUsageMethod");
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUsageMethod>("RDGatewayUsageMethod");
|
||||
connectionInfo.RDGatewayHostname = xmlnode.GetAttributeAsString("RDGatewayHostname");
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUseConnectionCredentials>("RDGatewayUseConnectionCredentials");
|
||||
connectionInfo.RDGatewayUseConnectionCredentials =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(
|
||||
"RDGatewayUseConnectionCredentials");
|
||||
connectionInfo.RDGatewayUsername = xmlnode.GetAttributeAsString("RDGatewayUsername");
|
||||
connectionInfo.RDGatewayPassword = _decryptor.Decrypt(xmlnode.GetAttributeAsString("RDGatewayPassword"));
|
||||
connectionInfo.RDGatewayPassword =
|
||||
_decryptor.Decrypt(xmlnode.GetAttributeAsString("RDGatewayPassword"));
|
||||
connectionInfo.RDGatewayDomain = xmlnode.GetAttributeAsString("RDGatewayDomain");
|
||||
|
||||
// Get inheritance settings
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = xmlnode.GetAttributeAsBool("InheritRDGatewayUsageMethod");
|
||||
connectionInfo.Inheritance.RDGatewayHostname = xmlnode.GetAttributeAsBool("InheritRDGatewayHostname");
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = xmlnode.GetAttributeAsBool("InheritRDGatewayUseConnectionCredentials");
|
||||
connectionInfo.Inheritance.RDGatewayUsername = xmlnode.GetAttributeAsBool("InheritRDGatewayUsername");
|
||||
connectionInfo.Inheritance.RDGatewayPassword = xmlnode.GetAttributeAsBool("InheritRDGatewayPassword");
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUsageMethod");
|
||||
connectionInfo.Inheritance.RDGatewayHostname =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayHostname");
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUseConnectionCredentials");
|
||||
connectionInfo.Inheritance.RDGatewayUsername =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUsername");
|
||||
connectionInfo.Inheritance.RDGatewayPassword =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayPassword");
|
||||
connectionInfo.Inheritance.RDGatewayDomain = xmlnode.GetAttributeAsBool("InheritRDGatewayDomain");
|
||||
}
|
||||
|
||||
@@ -487,8 +514,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.EnableDesktopComposition = xmlnode.GetAttributeAsBool("EnableDesktopComposition");
|
||||
|
||||
// Get inheritance settings
|
||||
connectionInfo.Inheritance.EnableFontSmoothing = xmlnode.GetAttributeAsBool("InheritEnableFontSmoothing");
|
||||
connectionInfo.Inheritance.EnableDesktopComposition = xmlnode.GetAttributeAsBool("InheritEnableDesktopComposition");
|
||||
connectionInfo.Inheritance.EnableFontSmoothing =
|
||||
xmlnode.GetAttributeAsBool("InheritEnableFontSmoothing");
|
||||
connectionInfo.Inheritance.EnableDesktopComposition =
|
||||
xmlnode.GetAttributeAsBool("InheritEnableDesktopComposition");
|
||||
}
|
||||
|
||||
if (_confVersion >= 2.4)
|
||||
@@ -507,14 +536,18 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 2.6)
|
||||
{
|
||||
connectionInfo.SoundQuality = xmlnode.GetAttributeAsEnum<RdpProtocol.RDPSoundQuality>("SoundQuality");
|
||||
connectionInfo.SoundQuality =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDPSoundQuality>("SoundQuality");
|
||||
connectionInfo.Inheritance.SoundQuality = xmlnode.GetAttributeAsBool("InheritSoundQuality");
|
||||
connectionInfo.RDPMinutesToIdleTimeout = xmlnode.GetAttributeAsInt("RDPMinutesToIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = xmlnode.GetAttributeAsBool("InheritRDPMinutesToIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPMinutesToIdleTimeout");
|
||||
connectionInfo.RDPAlertIdleTimeout = xmlnode.GetAttributeAsBool("RDPAlertIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout = xmlnode.GetAttributeAsBool("InheritRDPAlertIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPAlertIdleTimeout");
|
||||
}
|
||||
if(_confVersion >= 2.7)
|
||||
|
||||
if (_confVersion >= 2.7)
|
||||
{
|
||||
connectionInfo.RedirectClipboard = xmlnode.GetAttributeAsBool("RedirectClipboard");
|
||||
connectionInfo.Inheritance.RedirectClipboard = xmlnode.GetAttributeAsBool("InheritRedirectClipboard");
|
||||
@@ -528,7 +561,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strGetConnectionInfoFromXmlFailed, connectionInfo.Name, ConnectionFileName, ex.Message));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
string.Format(Language.strGetConnectionInfoFromXmlFailed,
|
||||
connectionInfo.Name, ConnectionFileName,
|
||||
ex.Message));
|
||||
}
|
||||
|
||||
return connectionInfo;
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private SecureString _encryptionKey;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer;
|
||||
|
||||
public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
@@ -43,7 +44,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var xmlDeclaration = new XDeclaration("1.0", "utf-8", null);
|
||||
var xmlDocument = new XDocument(xmlDeclaration, rootElement);
|
||||
if (fullFileEncryption)
|
||||
xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, _encryptionKey);
|
||||
xmlDocument =
|
||||
new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument,
|
||||
_encryptionKey);
|
||||
return xmlDocument;
|
||||
}
|
||||
|
||||
@@ -55,6 +58,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
newElement = CompileConnectionInfoNode(serializationTarget);
|
||||
parentElement.Add(newElement);
|
||||
}
|
||||
|
||||
var serializationTargetAsContainer = serializationTarget as ContainerInfo;
|
||||
if (serializationTargetAsContainer == null) return;
|
||||
foreach (var child in serializationTargetAsContainer.Children)
|
||||
@@ -79,7 +83,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private XElement CompileRootNode(RootNodeInfo rootNodeInfo, bool fullFileEncryption)
|
||||
{
|
||||
var rootNodeSerializer = new XmlRootNodeSerializer();
|
||||
return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider, _connectionNodeSerializer.Version, fullFileEncryption);
|
||||
return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider,
|
||||
_connectionNodeSerializer.Version, fullFileEncryption);
|
||||
}
|
||||
|
||||
private XElement CompileConnectionInfoNode(ConnectionInfo connectionInfo)
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
public Version Version => _connectionNodeSerializer.Version;
|
||||
public bool UseFullEncryption { get; set; }
|
||||
|
||||
public XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
public XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider;
|
||||
_connectionNodeSerializer = connectionNodeSerializer;
|
||||
@@ -42,7 +43,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var xml = "";
|
||||
try
|
||||
{
|
||||
var documentCompiler = new XmlConnectionsDocumentCompiler(_cryptographyProvider, _connectionNodeSerializer);
|
||||
var documentCompiler =
|
||||
new XmlConnectionsDocumentCompiler(_cryptographyProvider, _connectionNodeSerializer);
|
||||
var xmlDocument = documentCompiler.CompileDocument(serializationTarget, UseFullEncryption);
|
||||
xml = WriteXmlToString(xmlDocument);
|
||||
}
|
||||
@@ -50,13 +52,15 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex);
|
||||
}
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
private static string WriteXmlToString(XNode xmlDocument)
|
||||
{
|
||||
string xmlString;
|
||||
var xmlWriterSettings = new XmlWriterSettings { Indent = true, IndentChars = " ", Encoding = Encoding.UTF8 };
|
||||
var xmlWriterSettings = new XmlWriterSettings
|
||||
{Indent = true, IndentChars = " ", Encoding = Encoding.UTF8};
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var xmlTextWriter = XmlWriter.Create(memoryStream, xmlWriterSettings))
|
||||
{
|
||||
@@ -66,6 +70,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
xmlString = streamReader.ReadToEnd();
|
||||
}
|
||||
|
||||
return xmlString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return defaultValue;
|
||||
|
||||
return bool.TryParse(value, out var valueAsBool)
|
||||
return bool.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
: defaultValue;
|
||||
}
|
||||
@@ -28,8 +28,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return defaultValue;
|
||||
|
||||
return int.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
return int.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
: defaultValue;
|
||||
}
|
||||
|
||||
@@ -45,4 +45,4 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
: defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,27 +7,28 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlRootNodeSerializer
|
||||
{
|
||||
public XElement SerializeRootNodeInfo(
|
||||
RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
Version version,
|
||||
bool fullFileEncryption = false)
|
||||
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
Version version,
|
||||
bool fullFileEncryption = false)
|
||||
{
|
||||
XNamespace xmlNamespace = "http://mremoteng.org";
|
||||
var element = new XElement(xmlNamespace + "Connections");
|
||||
element.Add(new XAttribute(XNamespace.Xmlns+"mrng", xmlNamespace));
|
||||
element.Add(new XAttribute(XNamespace.Xmlns + "mrng", xmlNamespace));
|
||||
element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
|
||||
element.Add(new XAttribute(XName.Get("Export"), "false"));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("Export"), "false"));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
|
||||
element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"),
|
||||
fullFileEncryption.ToString().ToLowerInvariant()));
|
||||
element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider));
|
||||
element.Add(new XAttribute(XName.Get("ConfVersion"), version.ToString(2)));
|
||||
return element;
|
||||
}
|
||||
|
||||
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider)
|
||||
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider)
|
||||
{
|
||||
var attribute = new XAttribute(XName.Get("Protected"), "");
|
||||
var plainText = rootNodeInfo.Password ? "ThisIsProtected" : "ThisIsNotProtected";
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace mRemoteNG.Config.Serializers.CredentialProviderSerializer
|
||||
{
|
||||
var xmlDocument = new XDocument(new XDeclaration("1.0", "utf-8", null));
|
||||
var rootElement = new XElement("CredentialRepositories",
|
||||
from provider in credentialProviderCatalog
|
||||
select new XElement("CredentialRepository",
|
||||
new XAttribute("Id", provider.Config.Id),
|
||||
new XAttribute("TypeName", provider.Config.TypeName),
|
||||
new XAttribute("Title", provider.Config.Title),
|
||||
new XAttribute("Source", provider.Config.Source)
|
||||
)
|
||||
);
|
||||
from provider in credentialProviderCatalog
|
||||
select new XElement("CredentialRepository",
|
||||
new XAttribute("Id", provider.Config.Id),
|
||||
new XAttribute("TypeName", provider.Config.TypeName),
|
||||
new XAttribute("Title", provider.Config.Title),
|
||||
new XAttribute("Source", provider.Config.Source)
|
||||
)
|
||||
);
|
||||
xmlDocument.Add(rootElement);
|
||||
var declaration = xmlDocument.Declaration.ToString();
|
||||
var documentBody = xmlDocument.ToString();
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<ICredentialRecord>> _baseDeserializer;
|
||||
|
||||
public XmlCredentialPasswordDecryptorDecorator(IDeserializer<string, IEnumerable<ICredentialRecord>> baseDeserializer)
|
||||
public XmlCredentialPasswordDecryptorDecorator(
|
||||
IDeserializer<string, IEnumerable<ICredentialRecord>> baseDeserializer)
|
||||
{
|
||||
if (baseDeserializer == null)
|
||||
throw new ArgumentNullException(nameof(baseDeserializer));
|
||||
@@ -39,10 +40,13 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
var decryptedPassword = cryptoProvider.Decrypt(passwordAttribute.Value, key);
|
||||
passwordAttribute.SetValue(decryptedPassword);
|
||||
}
|
||||
|
||||
return xdoc.ToString();
|
||||
}
|
||||
|
||||
private void DecryptAuthHeader(XElement rootElement, ICryptographyProvider cryptographyProvider, SecureString key)
|
||||
private void DecryptAuthHeader(XElement rootElement,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString key)
|
||||
{
|
||||
var authAttribute = rootElement.Attribute("Auth");
|
||||
if (authAttribute == null)
|
||||
|
||||
@@ -12,7 +12,9 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
private readonly ISerializer<IEnumerable<ICredentialRecord>, string> _baseSerializer;
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
|
||||
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider, ISerializer<IEnumerable<ICredentialRecord>, string> baseSerializer)
|
||||
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<IEnumerable<ICredentialRecord>, string>
|
||||
baseSerializer)
|
||||
{
|
||||
if (baseSerializer == null)
|
||||
throw new ArgumentNullException(nameof(baseSerializer));
|
||||
@@ -45,6 +47,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
var encryptedPassword = _cryptographyProvider.Encrypt(passwordAttribute.Value, encryptionKey);
|
||||
passwordAttribute.Value = encryptedPassword;
|
||||
}
|
||||
|
||||
return xdoc.Declaration + Environment.NewLine + xdoc;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,9 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
xdoc.Root?.SetAttributeValue("EncryptionEngine", _cryptographyProvider.CipherEngine);
|
||||
xdoc.Root?.SetAttributeValue("BlockCipherMode", _cryptographyProvider.CipherMode);
|
||||
xdoc.Root?.SetAttributeValue("KdfIterations", _cryptographyProvider.KeyDerivationIterations);
|
||||
xdoc.Root?.SetAttributeValue("Auth", _cryptographyProvider.Encrypt(RandomGenerator.RandomString(20), encryptionKey));
|
||||
xdoc.Root?.SetAttributeValue("Auth",
|
||||
_cryptographyProvider.Encrypt(RandomGenerator.RandomString(20),
|
||||
encryptionKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,14 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
ValidateSchemaVersion(rootElement);
|
||||
|
||||
var credentials = from element in xdoc.Descendants("Credential")
|
||||
select new CredentialRecord(Guid.Parse(element.Attribute("Id")?.Value ?? Guid.NewGuid().ToString()))
|
||||
{
|
||||
Title = element.Attribute("Title")?.Value ?? "",
|
||||
Username = element.Attribute("Username")?.Value ?? "",
|
||||
Password = element.Attribute("Password")?.Value.ConvertToSecureString(),
|
||||
Domain = element.Attribute("Domain")?.Value ?? ""
|
||||
};
|
||||
select new CredentialRecord(Guid.Parse(element.Attribute("Id")?.Value ??
|
||||
Guid.NewGuid().ToString()))
|
||||
{
|
||||
Title = element.Attribute("Title")?.Value ?? "",
|
||||
Username = element.Attribute("Username")?.Value ?? "",
|
||||
Password = element.Attribute("Password")?.Value.ConvertToSecureString(),
|
||||
Domain = element.Attribute("Domain")?.Value ?? ""
|
||||
};
|
||||
return credentials.ToArray();
|
||||
}
|
||||
|
||||
@@ -33,7 +34,8 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
{
|
||||
var docSchemaVersion = rootElement?.Attribute("SchemaVersion")?.Value;
|
||||
if (docSchemaVersion != SchemaVersion)
|
||||
throw new Exception($"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
|
||||
throw new Exception(
|
||||
$"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,18 +14,20 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
public string Serialize(IEnumerable<ICredentialRecord> credentialRecords)
|
||||
{
|
||||
var xdoc = new XDocument(
|
||||
new XElement("Credentials",
|
||||
new XAttribute("SchemaVersion", Version.ToString(2)),
|
||||
from r in credentialRecords
|
||||
select new XElement("Credential",
|
||||
new XAttribute("Id", r.Id),
|
||||
new XAttribute("Title", r.Title),
|
||||
new XAttribute("Username", r.Username),
|
||||
new XAttribute("Domain", r.Domain),
|
||||
new XAttribute("Password", r.Password.ConvertToUnsecureString())
|
||||
)
|
||||
)
|
||||
)
|
||||
new XElement("Credentials",
|
||||
new XAttribute("SchemaVersion", Version.ToString(2)),
|
||||
from r in credentialRecords
|
||||
select new XElement("Credential",
|
||||
new XAttribute("Id", r.Id),
|
||||
new XAttribute("Title", r.Title),
|
||||
new XAttribute("Username", r.Username),
|
||||
new XAttribute("Domain", r.Domain),
|
||||
new XAttribute("Password",
|
||||
r.Password
|
||||
.ConvertToUnsecureString())
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
Declaration = new XDeclaration("1.0", "utf-8", null)
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath);
|
||||
ldapSearcher.Filter = ldapFilter;
|
||||
ldapSearcher.SearchScope = SearchScope.OneLevel;
|
||||
ldapSearcher.PropertiesToLoad.AddRange(new[] { "securityEquals", "cn", "objectClass" });
|
||||
ldapSearcher.PropertiesToLoad.AddRange(new[] {"securityEquals", "cn", "objectClass"});
|
||||
|
||||
var ldapResults = ldapSearcher.FindAll();
|
||||
foreach (SearchResult ldapResult in ldapResults)
|
||||
@@ -65,7 +65,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (directoryEntry.Properties["objectClass"].Contains("organizationalUnit"))
|
||||
{
|
||||
// check/continue here so we don't create empty connection objects
|
||||
if(!_importSubOu) continue;
|
||||
if (!_importSubOu) continue;
|
||||
|
||||
// TODO - this is a circular call. A deserializer should not call an importer
|
||||
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOu);
|
||||
@@ -79,7 +79,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,16 +75,19 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
throw (new FileFormatException($"Unrecognized root node type ({xmlNodeType})."));
|
||||
}
|
||||
|
||||
break;
|
||||
case "container":
|
||||
if (string.Compare(xmlNodeType, "folder", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
throw (new FileFormatException($"Unrecognized root node type ({xmlNodeType})."));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// ReSharper disable once LocalizableElement
|
||||
throw (new ArgumentException("Argument must be either a root or a container node.", nameof(xmlNode)));
|
||||
throw (new ArgumentException("Argument must be either a root or a container node.",
|
||||
nameof(xmlNode)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
foreach (var line in rdcFileContent.Split(Environment.NewLine.ToCharArray()))
|
||||
{
|
||||
var parts = line.Split(new[] { ':' }, 3);
|
||||
var parts = line.Split(new[] {':'}, 3);
|
||||
if (parts.Length < 3)
|
||||
{
|
||||
continue;
|
||||
@@ -90,12 +90,15 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.Colors = RdpProtocol.RDPColors.Colors32Bit;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "bitmapcachepersistenable":
|
||||
connectionInfo.CacheBitmaps = value == "1";
|
||||
break;
|
||||
case "screen mode id":
|
||||
connectionInfo.Resolution = value == "2" ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.RDPResolutions.FitToWindow;
|
||||
connectionInfo.Resolution = value == "2"
|
||||
? RdpProtocol.RDPResolutions.Fullscreen
|
||||
: RdpProtocol.RDPResolutions.FitToWindow;
|
||||
break;
|
||||
case "connect to console":
|
||||
connectionInfo.UseConsoleSession = value == "1";
|
||||
@@ -140,6 +143,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "loadbalanceinfo":
|
||||
connectionInfo.LoadBalanceInfo = value;
|
||||
|
||||
@@ -125,6 +125,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
// Program Version 2.2 wraps all setting inside the Properties tags
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
|
||||
var newContainer = new ContainerInfo();
|
||||
var connectionInfo = ConnectionInfoFromXml(containerPropertiesNode);
|
||||
newContainer.CopyFrom(connectionInfo);
|
||||
@@ -134,8 +135,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
// Program Version 2.7 wraps these properties
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
|
||||
newContainer.Name = containerPropertiesNode?.SelectSingleNode("./name")?.InnerText ?? Language.strNewFolder;
|
||||
newContainer.IsExpanded = bool.Parse(containerPropertiesNode?.SelectSingleNode("./expanded")?.InnerText ?? "false");
|
||||
newContainer.IsExpanded =
|
||||
bool.Parse(containerPropertiesNode?.SelectSingleNode("./expanded")?.InnerText ?? "false");
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
@@ -145,9 +148,11 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
|
||||
var propertiesNode = xmlNode.SelectSingleNode("./properties");
|
||||
if (_schemaVersion == 1) propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
if (_schemaVersion == 1)
|
||||
propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
connectionInfo.Hostname = propertiesNode?.SelectSingleNode("./name")?.InnerText ?? "";
|
||||
connectionInfo.Name = propertiesNode?.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Name =
|
||||
propertiesNode?.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Description = propertiesNode?.SelectSingleNode("./comment")?.InnerText ?? string.Empty;
|
||||
|
||||
var logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
|
||||
@@ -161,7 +166,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
var connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
|
||||
if (connectionSettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
connectionInfo.UseConsoleSession =
|
||||
bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
// ./startProgram
|
||||
// ./workingDir
|
||||
connectionInfo.Port = Convert.ToInt32(connectionSettingsNode.SelectSingleNode("./port")?.InnerText);
|
||||
@@ -175,7 +181,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RdpProtocol.RDGatewayUsageMethod.Always : RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True"
|
||||
? RdpProtocol.RDGatewayUsageMethod.Always
|
||||
: RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName")?.InnerText;
|
||||
connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName")?.InnerText;
|
||||
|
||||
@@ -225,7 +234,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
var colorDepth = remoteDesktopNode.SelectSingleNode("./colorDepth")?.InnerText;
|
||||
if (colorDepth != null)
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), colorDepth);
|
||||
connectionInfo.Colors =
|
||||
(RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), colorDepth);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -274,11 +284,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
// ./redirectClipboard
|
||||
connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectClipboard = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectClipboard")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectDiskDrives =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectClipboard =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectClipboard")?.InnerText ?? "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -354,7 +369,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
try
|
||||
{
|
||||
var plaintextData = ProtectedData.Unprotect(Convert.FromBase64String(ciphertext), new byte[] { }, DataProtectionScope.LocalMachine);
|
||||
var plaintextData = ProtectedData.Unprotect(Convert.FromBase64String(ciphertext), new byte[] { },
|
||||
DataProtectionScope.LocalMachine);
|
||||
return Encoding.Unicode.GetString(plaintextData).ConvertToSecureString();
|
||||
}
|
||||
catch (Exception /*ex*/)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
new SqlVersion23To24Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion24To25Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion25To26Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion26To27Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion26To27Upgrader(_sqlDatabaseConnector),
|
||||
};
|
||||
|
||||
foreach (var upgrader in dbUpgraders)
|
||||
@@ -52,11 +52,16 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
isVerified = true;
|
||||
|
||||
if (isVerified == false)
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strErrorBadDatabaseVersion, databaseVersion, GeneralAppInfo.ProductName));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
string.Format(Language.strErrorBadDatabaseVersion,
|
||||
databaseVersion,
|
||||
GeneralAppInfo.ProductName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strErrorVerifyDatabaseVersionFailed, ex.Message));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
string.Format(Language.strErrorVerifyDatabaseVersionFailed,
|
||||
ex.Message));
|
||||
}
|
||||
|
||||
return isVerified;
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.2 to version 2.3.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.2 to version 2.3.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD EnableFontSmoothing bit NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.3 to version 2.4.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.3 to version 2.4.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD UseCredSsp bit NOT NULL DEFAULT 1,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.4 to version 2.5.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.4 to version 2.5.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD LoadBalanceInfo varchar (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.5 to version 2.6.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.5 to version 2.6.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD RDPMinutesToIdleTimeout int NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.6 to version 2.7.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.6 to version 2.7.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD RedirectClipboard bit NOT NULL DEFAULT 0,
|
||||
@@ -39,4 +40,4 @@ UPDATE tblRoot
|
||||
return new Version(2, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
_rootNodeInfo = rootNodeInfo;
|
||||
}
|
||||
|
||||
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine, BlockCipherModes blockCipherMode, RootNodeInfo rootNodeInfo)
|
||||
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine,
|
||||
BlockCipherModes blockCipherMode,
|
||||
RootNodeInfo rootNodeInfo)
|
||||
{
|
||||
_cryptographyProvider = new CryptoProviderFactory(blockCipherEngine, blockCipherMode).Build();
|
||||
_rootNodeInfo = rootNodeInfo;
|
||||
@@ -37,7 +39,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
public string Decrypt(string plainText)
|
||||
{
|
||||
return plainText == "" ? "" : _cryptographyProvider.Decrypt(plainText, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
return plainText == ""
|
||||
? ""
|
||||
: _cryptographyProvider.Decrypt(plainText, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
}
|
||||
|
||||
public string LegacyFullFileDecrypt(string xml)
|
||||
@@ -50,7 +54,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
try
|
||||
{
|
||||
decryptedContent = _cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
decryptedContent =
|
||||
_cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
notDecr = decryptedContent == xml;
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -62,7 +67,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (Authenticate(xml, _rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
{
|
||||
decryptedContent = _cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
decryptedContent =
|
||||
_cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
notDecr = false;
|
||||
}
|
||||
|
||||
@@ -82,12 +88,17 @@ namespace mRemoteNG.Config.Serializers
|
||||
var connectionsFileIsNotEncrypted = false;
|
||||
try
|
||||
{
|
||||
connectionsFileIsNotEncrypted = _cryptographyProvider.Decrypt(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()) == "ThisIsNotProtected";
|
||||
connectionsFileIsNotEncrypted =
|
||||
_cryptographyProvider.Decrypt(protectedString,
|
||||
_rootNodeInfo.PasswordString.ConvertToSecureString()) ==
|
||||
"ThisIsNotProtected";
|
||||
}
|
||||
catch (EncryptionException)
|
||||
{
|
||||
}
|
||||
return connectionsFileIsNotEncrypted || Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
|
||||
return connectionsFileIsNotEncrypted ||
|
||||
Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
}
|
||||
|
||||
private bool Authenticate(string cipherText, SecureString password)
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
|
||||
#if !PORTABLE
|
||||
var oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProductName + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
var oldPath =
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProductName + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
#endif
|
||||
var newPath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
if (File.Exists(newPath))
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly ISerializer<DockPanel, string> _dockPanelSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public DockPanelLayoutSaver(ISerializer<DockPanel, string> dockPanelSerializer, IDataProvider<string> dataProvider)
|
||||
public DockPanelLayoutSaver(ISerializer<DockPanel, string> dockPanelSerializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
if (dockPanelSerializer == null)
|
||||
throw new ArgumentNullException(nameof(dockPanelSerializer));
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace mRemoteNG.Config.Settings
|
||||
memoryStream.Position = 0;
|
||||
xdoc = XDocument.Load(memoryStream, LoadOptions.SetBaseUri);
|
||||
}
|
||||
|
||||
return $"{xdoc.Declaration}{Environment.NewLine}{xdoc}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
public ExternalAppsLoader(FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
@@ -34,13 +36,15 @@ namespace mRemoteNG.Config.Settings
|
||||
public void LoadExternalAppsFromXML()
|
||||
{
|
||||
#if !PORTABLE
|
||||
var oldPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName);
|
||||
var oldPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName);
|
||||
#endif
|
||||
var newPath = Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.ExtAppsFilesName);
|
||||
var xDom = new XmlDocument();
|
||||
if (File.Exists(newPath))
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}",
|
||||
true);
|
||||
xDom.Load(newPath);
|
||||
}
|
||||
#if !PORTABLE
|
||||
@@ -53,13 +57,15 @@ namespace mRemoteNG.Config.Settings
|
||||
#endif
|
||||
else
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not FIND file!");
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Loading External Apps failed: Could not FIND file!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (xDom.DocumentElement == null)
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not LOAD file!");
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Loading External Apps failed: Could not LOAD file!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +99,9 @@ namespace mRemoteNG.Config.Settings
|
||||
extA.ShowOnToolbar = bool.Parse(xEl.Attributes["ShowOnToolbar"].Value);
|
||||
}
|
||||
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
$"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}",
|
||||
true);
|
||||
Runtime.ExternalToolsService.ExternalTools.Add(extA);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
var xmlTextWriter =
|
||||
new XmlTextWriter(SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.ExtAppsFilesName,
|
||||
Encoding.UTF8)
|
||||
Encoding.UTF8)
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
Indentation = 4
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user