mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Compare commits
285 Commits
v1.76Alpha
...
remove_sta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7445e917d6 | ||
|
|
7a54b98ea2 | ||
|
|
f56b8f8e42 | ||
|
|
8ab221e5a8 | ||
|
|
21e51c8455 | ||
|
|
3234896caf | ||
|
|
b00dd1c5f5 | ||
|
|
992a3f9d1c | ||
|
|
6b280b5aa4 | ||
|
|
e6713520c7 | ||
|
|
4f75b0343e | ||
|
|
097ebccdcd | ||
|
|
954e1de4da | ||
|
|
63dc79699d | ||
|
|
63f342bbdb | ||
|
|
7c9b90ed7d | ||
|
|
00e45b60ad | ||
|
|
d1a7a37909 | ||
|
|
1c12b52ada | ||
|
|
722fe40899 | ||
|
|
b2e7ebf43d | ||
|
|
3ed8e768aa | ||
|
|
d362691389 | ||
|
|
4b7c54d5b5 | ||
|
|
fbd0407863 | ||
|
|
7bab1b4297 | ||
|
|
cfce9e9887 | ||
|
|
9df2a96027 | ||
|
|
d967c719f5 | ||
|
|
ec80a5aa70 | ||
|
|
0c95f178ca | ||
|
|
e0405b15df | ||
|
|
e029f30acf | ||
|
|
44ed836b7c | ||
|
|
00401201d1 | ||
|
|
726491feee | ||
|
|
36a94e1399 | ||
|
|
d9e65719d3 | ||
|
|
20f46bea61 | ||
|
|
a5d22d287c | ||
|
|
793095900b | ||
|
|
ee63292e55 | ||
|
|
9fbcde3ca0 | ||
|
|
9e48c8e359 | ||
|
|
da07f50e49 | ||
|
|
cc872cd2b4 | ||
|
|
a3fa1e541c | ||
|
|
b579e823bd | ||
|
|
fc5b1ec85e | ||
|
|
e0c2037831 | ||
|
|
9f44d6b75b | ||
|
|
b6f2fff42b | ||
|
|
f10e54e47b | ||
|
|
704e0c1dc1 | ||
|
|
067ac8fb56 | ||
|
|
4428089146 | ||
|
|
4dea0d03ed | ||
|
|
44ce674166 | ||
|
|
0c79a9acde | ||
|
|
ebfc2715e7 | ||
|
|
b0dbc9dc18 | ||
|
|
507cdf75a5 | ||
|
|
8f8492b0be | ||
|
|
457e715188 | ||
|
|
3fad827b9f | ||
|
|
8bd571c78d | ||
|
|
1724521ebf | ||
|
|
b0fb3596aa | ||
|
|
38ff8340e4 | ||
|
|
f759ea4bc2 | ||
|
|
fb228d72b1 | ||
|
|
916361a3be | ||
|
|
011d0cad8c | ||
|
|
408c40f699 | ||
|
|
4173f6d775 | ||
|
|
e6f3c22064 | ||
|
|
a013518eac | ||
|
|
9c88cacb3d | ||
|
|
d49bf04b15 | ||
|
|
1dbd5dc5bc | ||
|
|
c103706a54 | ||
|
|
b0a027df52 | ||
|
|
868641378a | ||
|
|
11baae3107 | ||
|
|
7526bb430f | ||
|
|
7dbef77687 | ||
|
|
ed8125042e | ||
|
|
25b2655d0f | ||
|
|
145a264154 | ||
|
|
3e33170ae0 | ||
|
|
d18bf68f0e | ||
|
|
368917e108 | ||
|
|
cdea4c3911 | ||
|
|
b4b9b55bbf | ||
|
|
6092c63df4 | ||
|
|
fda5132184 | ||
|
|
6a9fb25a18 | ||
|
|
18d7344690 | ||
|
|
ba50cf20a0 | ||
|
|
7bd6e126e2 | ||
|
|
f7521c81d5 | ||
|
|
f483a2dc2f | ||
|
|
9769d5af06 | ||
|
|
0a2dc3563e | ||
|
|
e9f0157b2b | ||
|
|
e8e566fcdd | ||
|
|
72b7d22cef | ||
|
|
f79da476fd | ||
|
|
ef31b7844c | ||
|
|
f1ed1bf115 | ||
|
|
23ea028965 | ||
|
|
42046a614f | ||
|
|
36055f56e6 | ||
|
|
b693cb30fc | ||
|
|
20377d4ff5 | ||
|
|
570d732b0e | ||
|
|
d9d2b1de70 | ||
|
|
0a7eaaf36f | ||
|
|
36dd3e496d | ||
|
|
83fd914d7b | ||
|
|
281c6b13fa | ||
|
|
00b7b1221c | ||
|
|
56cbf0ff3f | ||
|
|
f852a4d341 | ||
|
|
7c8c7d482a | ||
|
|
9e95ae2cb0 | ||
|
|
0d2d935f17 | ||
|
|
eeb320a825 | ||
|
|
9452d4dbe3 | ||
|
|
03d2387cdd | ||
|
|
61b325ccb9 | ||
|
|
e57de9a4de | ||
|
|
a259ab9541 | ||
|
|
96946f3a1e | ||
|
|
08569276eb | ||
|
|
edc4be2d44 | ||
|
|
8cd6fb7ae2 | ||
|
|
a5afa90790 | ||
|
|
f634eb8d37 | ||
|
|
694b61a67b | ||
|
|
88f0d00a15 | ||
|
|
e31088fd2e | ||
|
|
1d7bb63710 | ||
|
|
64422c60bb | ||
|
|
a8b082ed4b | ||
|
|
5a5ade0d60 | ||
|
|
7e24e2dcfb | ||
|
|
930579d983 | ||
|
|
af1ed5349f | ||
|
|
9dcf71dc31 | ||
|
|
8bf9af0ed8 | ||
|
|
aecfad5871 | ||
|
|
3edd155898 | ||
|
|
2c419c0b2e | ||
|
|
2fb67e7042 | ||
|
|
e05eb0807e | ||
|
|
1aca1b7ae8 | ||
|
|
82847f07b2 | ||
|
|
29483b2625 | ||
|
|
7fc59e79f3 | ||
|
|
79b3e21148 | ||
|
|
ee91117010 | ||
|
|
0548037ff3 | ||
|
|
46002632bb | ||
|
|
9659ac1611 | ||
|
|
bbc497e68d | ||
|
|
d7ec7574ad | ||
|
|
2f476d9e61 | ||
|
|
c74f37f0de | ||
|
|
d27a62cbfc | ||
|
|
8029e491a3 | ||
|
|
fe56268421 | ||
|
|
2db6fabbe9 | ||
|
|
035e89801a | ||
|
|
a7280da30c | ||
|
|
ac2920820d | ||
|
|
fcecc4b31e | ||
|
|
4abef50ca0 | ||
|
|
5e16445b08 | ||
|
|
be593b8185 | ||
|
|
ca27cb9981 | ||
|
|
5b64e629c9 | ||
|
|
18640826b6 | ||
|
|
e4d3239831 | ||
|
|
e834eadbe1 | ||
|
|
0ec8f66972 | ||
|
|
28b49aab70 | ||
|
|
458c462f49 | ||
|
|
6f6e2a1254 | ||
|
|
f46a3d69e1 | ||
|
|
fa787ed082 | ||
|
|
b5b748f993 | ||
|
|
3bdcf655fd | ||
|
|
284755f298 | ||
|
|
ad5eed96e7 | ||
|
|
431c830ea0 | ||
|
|
da047427a5 | ||
|
|
69da1dca5f | ||
|
|
cc61501f63 | ||
|
|
4ced2d3392 | ||
|
|
7c72bfdf6b | ||
|
|
b8878e1458 | ||
|
|
abd40cec1b | ||
|
|
cc18da4f28 | ||
|
|
1a39039162 | ||
|
|
cf9dd72ea5 | ||
|
|
b7cdf81665 | ||
|
|
8497a05fd1 | ||
|
|
7db4eec45c | ||
|
|
cd822b545a | ||
|
|
e872581d3c | ||
|
|
defe9e094c | ||
|
|
5662735cb8 | ||
|
|
75c866f7c1 | ||
|
|
c3ae438e9c | ||
|
|
314c989dae | ||
|
|
8c350429b7 | ||
|
|
b21f2ffe65 | ||
|
|
66b307bff9 | ||
|
|
c43ef052c6 | ||
|
|
d0a011d8ff | ||
|
|
05c96da98f | ||
|
|
8646dce21b | ||
|
|
de9b78c5fb | ||
|
|
991505b043 | ||
|
|
729166fc30 | ||
|
|
ea53fc190b | ||
|
|
99a3eabbaf | ||
|
|
c57bd386f2 | ||
|
|
f2a52b03df | ||
|
|
860e1ccfaa | ||
|
|
49967b38d4 | ||
|
|
36038fff6d | ||
|
|
c5958954b0 | ||
|
|
d0d63016ca | ||
|
|
35f2484adf | ||
|
|
662b5bde31 | ||
|
|
388a4ed75b | ||
|
|
c2cf496ded | ||
|
|
8a172f02a9 | ||
|
|
f27935ea61 | ||
|
|
5311b522b7 | ||
|
|
ea682e218d | ||
|
|
aa5f7ef2a8 | ||
|
|
043df0aec3 | ||
|
|
63a2e18760 | ||
|
|
c3ced7ed03 | ||
|
|
f597e14b3d | ||
|
|
aff4ba9115 | ||
|
|
554e0805e3 | ||
|
|
f4efa74a23 | ||
|
|
ddc19587fa | ||
|
|
5f1232727e | ||
|
|
9c373e8f0a | ||
|
|
83942d788f | ||
|
|
73d6fec6f3 | ||
|
|
a37b5deaa1 | ||
|
|
3b9de847e7 | ||
|
|
924f1f1e48 | ||
|
|
7bdebbe25b | ||
|
|
8f46c25dc9 | ||
|
|
8bb4a03639 | ||
|
|
7b5bc5e057 | ||
|
|
2c62218fd6 | ||
|
|
35582a5e6a | ||
|
|
20340fd31f | ||
|
|
d6d7664b48 | ||
|
|
3fbad29017 | ||
|
|
e5a34388ae | ||
|
|
7a4b232695 | ||
|
|
ba94e10cfa | ||
|
|
5093035f68 | ||
|
|
8159165968 | ||
|
|
5903481c87 | ||
|
|
e7afe5ea93 | ||
|
|
f00dad3c96 | ||
|
|
db99a32c1d | ||
|
|
c04bb44da3 | ||
|
|
ba11746e6f | ||
|
|
ced33027b8 | ||
|
|
0febc13ec7 | ||
|
|
05e62ff76f | ||
|
|
107067cead | ||
|
|
13f51629af | ||
|
|
8dc3303e0f |
38
.github/ISSUE_TEMPLATE.md
vendored
38
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,16 +1,30 @@
|
||||
<!--
|
||||
Only file GitHub issues for bugs and feature requests. All other topics will be closed.
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
Before opening an issue, please search for a duplicate or closed issue.
|
||||
Please provide as much detail as possible for us to fix your issue.
|
||||
-->
|
||||
## Expected Behavior
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
<!-- Bug -->
|
||||
|Detail|Value|
|
||||
|--:|---|
|
||||
|Operating system | Windows 10 x64 |
|
||||
|mRemoteNG version| 1.75.7008 |
|
||||
## Current Behavior
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
<!-- Feature Request -->
|
||||
<!-- If you file a feature request, please delete the bug section -->
|
||||
## Steps to Reproduce (for bugs)
|
||||
<!--- Provide an unambiguous set of steps to reproduce -->
|
||||
<!--- this bug. Include code to reproduce, if relevant -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* Version used:
|
||||
* Operating System and version (e.g. Windows 10 1709 x64):
|
||||
|
||||
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,4 +1,29 @@
|
||||
<!--
|
||||
Please provide as much detail as possible with what your pull request does.
|
||||
Include a reference to a filed issue if it exists.
|
||||
-->
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Screenshots (if appropriate):
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] My change requires a change to the documentation.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document.
|
||||
|
||||
105
CHANGELOG.TXT
105
CHANGELOG.TXT
@@ -1,3 +1,108 @@
|
||||
1.77.0 (2018-xx-xx):
|
||||
|
||||
Features/Enhancements:
|
||||
----------------------
|
||||
#1072: Russian translation improvements
|
||||
#1016: Chinese (simplified) translation improvements
|
||||
#928: Add context menu items to 'Close all but this' and 'Close all tabs to the right'
|
||||
|
||||
|
||||
1.76.11 (2018-10-18):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1139: Feature "Reconnect to previously opened sessions" not working
|
||||
#1136: Putty window not maximized
|
||||
|
||||
|
||||
1.76.10 (2018-10-07):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1124: Enabling themes causes an exception
|
||||
|
||||
|
||||
1.76.9 (2018-10-07):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1117: Duplicate panel created when "Reconnect on Startup" and "Create Empty Panel" settings enabled
|
||||
#1115: Exception when changing from xml data storage to SQL
|
||||
#1110: Pressing Delete button during connection rename attempts to delete the connection instead of the text
|
||||
#1106: Inheritance does not work when parent has C# default type set
|
||||
#1092: Invalid Cast Exceptions loading default connectioninfo
|
||||
#1091: Minor themeing issues
|
||||
#853: Added some additional safety checks and logging to help address RDP crashes
|
||||
|
||||
|
||||
1.76.8 (2018-08-25):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1088: Delete and Launch buttons are not disabled when last external tool deleted
|
||||
#1087: 'Save connections after every edit' setting not honored
|
||||
#1082: Connections not given GUID if Id is empty in connection xml
|
||||
|
||||
|
||||
1.76.7 (2018-08-22):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1076: Wrong object selected when duplicating connection then switching between properties and inheritance in config window
|
||||
#1068: Fixed some toolbar positioning bugs
|
||||
|
||||
|
||||
1.76.6 (2018-08-03):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1062: Entering correct password when starting app does not load connections file
|
||||
|
||||
1.76.5 (2018-08-02):
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#1057: Hitting F2 with no connection node selected caused unhandled exception
|
||||
#1052: 'Switch to notification panel' feature does not always switch
|
||||
#1051: Tooltips always displayed regardless of 'Show description tooltips in connection tree' setting
|
||||
#1050: Config window retains access to previously selected node after loading new connections file
|
||||
#1045: Config window shows several incorrect properties for HTTPS connections
|
||||
#1040: Canceling "select panel" form does not cancel
|
||||
#1039: Set default theme when themes disabled
|
||||
#1038: Unable to add connection with active filter
|
||||
#1036: Exception when themes are active and options page closed on Connections then reopened
|
||||
#1034: Connection context menu not being translated
|
||||
#1030: Exception thrown if importing from port scan and no tree node is selected
|
||||
#1020: BackupFileKeepCount setting not limiting backup file count
|
||||
#1004: Duplicating root or PuTTy node through hotkey causes unhandled exception
|
||||
#1002: Disabling filtering without clearing keyword leaves filtered state
|
||||
#1001: Connection tree context menu hotkeys stop working and disappear in some cases
|
||||
#999: Some hotkeys stop working if File menu was called when PuTTy Saved Sessions was selected
|
||||
#998: Can sometimes add connection under PuTTY Sessions node
|
||||
#991: Error when deleting host in filtered view
|
||||
#971: Portable Settings now apply to any machine they are used on
|
||||
#961: Connections file overwritten if correct decryption password not provided
|
||||
#893: Removed unneeded files from build/package
|
||||
#868: if statement returned the same value
|
||||
#762: Increased button size to fit locaized text
|
||||
|
||||
|
||||
1.76.4 Alpha 6 (2018-06-03):
|
||||
|
||||
Features/Enhancements:
|
||||
----------------------
|
||||
#948: Fixed issue where many menu item translations were not being used
|
||||
#942: Improved Russian translation of several items
|
||||
#924: Notification for "No Host Specified" when clicking folders in quick-connect menu
|
||||
#902: Menu bar can once again be moved. View -> "Lock toolbar positions" now also locks the menu position
|
||||
Added option for creating an empty panel on startup
|
||||
|
||||
Fixes:
|
||||
------
|
||||
#938: Minor layout improvements on the Port Scan screen
|
||||
#916: Default properties were not being saved
|
||||
|
||||
|
||||
1.76.3 Alpha 5 (2018-03-14):
|
||||
|
||||
Fixes:
|
||||
|
||||
@@ -23,6 +23,9 @@ github.com/DamianBis
|
||||
github.com/pfjason
|
||||
github.com/sirLoaf
|
||||
github.com/Fyers
|
||||
Vladimir Semenov (github.com/sli-pro)
|
||||
Stephan (github.com/st-schuler)
|
||||
Aleksey Reytsman (github.com/areytsman)
|
||||
|
||||
|
||||
Past Contributors
|
||||
@@ -59,6 +62,9 @@ Lukas Plachy (github.com/rheingold)
|
||||
Gyuha Shin
|
||||
Stefan (github.com/polluks)
|
||||
github.com/emazv72
|
||||
Vladimir Semenov (github.com/sli-pro)
|
||||
Marco Sousa (github.com/marcomsousa)
|
||||
github.com/wwj402
|
||||
|
||||
|
||||
Included Source Code
|
||||
|
||||
8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@@ -1,8 +1,8 @@
|
||||
#!groovy
|
||||
node('windows') {
|
||||
def jobDir = pwd()
|
||||
def solutionFilePath = "\"${jobDir}\\mRemoteV1.sln\""
|
||||
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
|
||||
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
|
||||
def msBuild = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
|
||||
def nunitConsolePath = "${jobDir}\\packages\\NUnit.ConsoleRunner.3.7.0\\tools\\nunit3-console.exe"
|
||||
def openCoverPath = "${jobDir}\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe"
|
||||
def reportGeneratorPath = "${jobDir}\\packages\\ReportGenerator.3.0.2\\tools\\ReportGenerator.exe"
|
||||
@@ -24,11 +24,11 @@ node('windows') {
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Normal)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /p:Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /p:Configuration=\"Debug Portable\";Platform=x86 \"${jobDir}\\mRemoteV1.sln\""
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Normal, w/coverage)') {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
node('windows') {
|
||||
def jobDir = pwd()
|
||||
def solutionFilePath = "\"${jobDir}\\mRemoteV1.sln\""
|
||||
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
|
||||
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
|
||||
def nunitTestAdapterPath = "C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\VisualStudio\\14.0\\Extensions"
|
||||
def msBuild = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\msbuild.exe"
|
||||
def nunitConsolePath = "${jobDir}\\packages\\NUnit.ConsoleRunner.3.7.0\\tools\\nunit3-console.exe"
|
||||
def openCoverPath = "${jobDir}\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe"
|
||||
def testResultFilePrefix = "TestResult"
|
||||
def testResultFileNormal = "${testResultFilePrefix}_UnitTests_normal.xml"
|
||||
def testResultFilePortable = "${testResultFilePrefix}_UnitTests_portable.xml"
|
||||
def coverageReport = "code_coverage_report.xml"
|
||||
|
||||
|
||||
stage ('Clean output dir') {
|
||||
@@ -32,24 +36,24 @@ node('windows') {
|
||||
withCredentials([file(credentialsId: '9b674d57-6792-48e3-984a-4d1bab2abb64', variable: 'CODE_SIGNING_CERT')]) {
|
||||
withCredentials([usernamePassword(credentialsId: '05b7449b-05c0-490f-8661-236242526e62', passwordVariable: 'MRNG_CERT_PASSWORD', usernameVariable: 'NO_USERNAME')]) {
|
||||
stage ('Build mRemoteNG (Normal - MSI)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /t:Clean,Build /p:Configuration=\"Release Installer\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /t:Clean,Build /p:Configuration=\"Release Installer\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
archiveArtifacts artifacts: "Release\\*.msi", caseSensitive: false, onlyIfSuccessful: true, fingerprint: true
|
||||
}
|
||||
|
||||
stage ('Build mRemoteNG (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /t:Clean,Build /p:Configuration=\"Release Portable\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
bat "\"${msBuild}\" /nologo /t:Clean,Build /p:Configuration=\"Release Portable\" /p:Platform=x86 /p:CertPath=\"${env.CODE_SIGNING_CERT}\" /p:CertPassword=${env.MRNG_CERT_PASSWORD} \"${jobDir}\\mRemoteV1.sln\""
|
||||
archiveArtifacts artifacts: "Release\\*.zip", caseSensitive: false, onlyIfSuccessful: true, fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Normal - MSI)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && VSTest.Console.exe /logger:trx /TestAdapterPath:${nunitTestAdapterPath} \"${jobDir}\\mRemoteNGTests\\bin\\Release\\mRemoteNGTests.dll\""
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Portable)') {
|
||||
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && VSTest.Console.exe /logger:trx /TestAdapterPath:${nunitTestAdapterPath} \"${jobDir}\\mRemoteNGTests\\bin\\Release Portable\\mRemoteNGTests.dll\""
|
||||
}
|
||||
stage ('Run Unit Tests (Normal - MSI)') {
|
||||
bat "\"${nunitConsolePath}\" \"${jobDir}\\mRemoteNGTests\\bin\\release\\mRemoteNGTests.dll\" --result=${testResultFileNormal} --x86"
|
||||
}
|
||||
|
||||
stage ('Run Unit Tests (Portable)') {
|
||||
bat "\"${nunitConsolePath}\" \"${jobDir}\\mRemoteNGTests\\bin\\release portable\\mRemoteNGTests.dll\" --result=${testResultFilePortable} --x86"
|
||||
}
|
||||
|
||||
stage ('Generate UpdateCheck Files') {
|
||||
bat "powershell -ExecutionPolicy Bypass -File \"${jobDir}\\Tools\\create_upg_chk_files.ps1\" -TagName \"${env.TagName}\" -UpdateChannel \"${env.UpdateChannel}\""
|
||||
@@ -58,11 +62,10 @@ node('windows') {
|
||||
|
||||
stage ('Publish to GitHub') {
|
||||
withCredentials([string(credentialsId: '5443a369-dbe8-42d3-b4e8-04d0b4e9039a', variable: 'GH_AUTH_TOKEN')]) {
|
||||
def zipPath = "${jobDir}\\Release\\*.zip"
|
||||
def msiPath = "${jobDir}\\Release\\*.msi"
|
||||
def releaseFolder = "${jobDir}\\Release"
|
||||
// because batch files suck at handling newline characters, we have to convert to base64 in groovy and back to text in powershell
|
||||
def base64Description = env.ReleaseDescription.bytes.encodeBase64().toString()
|
||||
bat "powershell -ExecutionPolicy Bypass -File \"${jobDir}\\Tools\\publish_to_github.ps1\" -Owner \"mRemoteNG\" -Repository \"mRemoteNG\" -ReleaseTitle \"${env.ReleaseTitle}\" -TagName \"${env.TagName}\" -TargetCommitish \"${env.TargetBranch}\" -Description \"${base64Description}\" -IsDraft ${env.IsDraft} -IsPrerelease ${env.IsPreRelease} -ZipFilePath \"${zipPath}\" -MsiFilePath \"${msiPath}\" -AuthToken \"${env.GH_AUTH_TOKEN}\" -DescriptionIsBase64Encoded"
|
||||
bat "powershell -ExecutionPolicy Bypass -File \"${jobDir}\\Tools\\publish_to_github.ps1\" -Owner \"mRemoteNG\" -Repository \"mRemoteNG\" -ReleaseTitle \"${env.ReleaseTitle}\" -TagName \"${env.TagName}\" -TargetCommitish \"${env.TargetBranch}\" -Description \"${base64Description}\" -IsDraft ${env.IsDraft} -IsPrerelease ${env.IsPreRelease} -ReleaseFolderPath \"${releaseFolder}\" -AuthToken \"${env.GH_AUTH_TOKEN}\" -DescriptionIsBase64Encoded"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
| ---------------|--------------|-----------|
|
||||
| Stable | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/master) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
|
||||
| Beta | | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.75.7012) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76Alpha4) |
|
||||
| Development | [](https://ci.appveyor.com/project/mremoteng/mremoteng/branch/develop) | [](https://github.com/mRemoteNG/mRemoteNG/releases/tag/v1.76Alpha5) |
|
||||
|
||||
mRemoteNG is the next generation of mRemote, a full-featured, multi-tab remote connections manager.
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
License for use and distribution
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright (C) 1999-2016 Igor Pavlov.
|
||||
Copyright (C) 1999-2018 Igor Pavlov.
|
||||
|
||||
7-Zip Extra files are under the GNU LGPL license.
|
||||
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
7-Zip Extra history
|
||||
-------------------
|
||||
|
||||
This file contains only information about changes related to that package exclusively.
|
||||
The full history of changes is listed in history.txt in main 7-Zip program.
|
||||
|
||||
|
||||
18.05 2018-04-30
|
||||
-------------------------
|
||||
- The speed for LZMA/LZMA2 compressing was increased
|
||||
by 8% for fastest/fast compression levels and
|
||||
by 3% for normal/maximum compression levels.
|
||||
|
||||
|
||||
18.03 beta 2018-03-04
|
||||
-------------------------
|
||||
- The speed for single-thread LZMA/LZMA2 decoding
|
||||
was increased by 30% in x64 version and by 3% in x86 version.
|
||||
- 7-Zip now can use multi-threading for 7z/LZMA2 decoding,
|
||||
if there are multiple independent data chunks in LZMA2 stream.
|
||||
|
||||
|
||||
9.35 beta 2014-12-07
|
||||
------------------------------
|
||||
- SFX modules were moved to LZMA SDK package.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
7-Zip Extra 16.02
|
||||
7-Zip Extra 18.05
|
||||
-----------------
|
||||
|
||||
7-Zip Extra is package of extra modules of 7-Zip.
|
||||
|
||||
7-Zip Copyright (C) 1999-2016 Igor Pavlov.
|
||||
7-Zip Copyright (C) 1999-2018 Igor Pavlov.
|
||||
|
||||
7-Zip is free software. Read License.txt for more information about license.
|
||||
|
||||
|
||||
@@ -171,13 +171,27 @@ function Upload-GitHubReleaseAsset {
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
# The OAuth2 token to use for authentication.
|
||||
$AuthToken
|
||||
$AuthToken,
|
||||
|
||||
[string]
|
||||
# A short description label for the asset
|
||||
$Label = ""
|
||||
)
|
||||
|
||||
$UploadUri = $UploadUri -replace "(\{[\w,\?]*\})$"
|
||||
$file = Get-Item -Path $FilePath
|
||||
$files = Get-Item -Path $FilePath
|
||||
|
||||
$req_uploadZipAsset = Invoke-WebRequest -Uri "$($UploadUri)?name=$($file.Name)" -Method Post -Headers @{"Authorization"="token $AuthToken"} -ContentType $ContentType -InFile $file.FullName -ErrorAction Stop
|
||||
$labelParam = ""
|
||||
if ($Label -ne "") {
|
||||
$labelParam = "&label=$Label"
|
||||
}
|
||||
|
||||
# Get-Item could produce an array of files if a wildcard is provided. (C:\*.txt)
|
||||
# Upload each matching item individually
|
||||
foreach ($file in $files) {
|
||||
Write-Output "Uploading asset to GitHub release: '$($file.FullName)'"
|
||||
$req_uploadZipAsset = Invoke-WebRequest -Uri "$($UploadUri)?name=$($file.Name)$labelParam" -Method Post -Headers @{"Authorization"="token $AuthToken"} -ContentType $ContentType -InFile $file.FullName -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,4 +46,5 @@ Format-Table -AutoSize -Wrap -InputObject @{
|
||||
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\sign_binaries.ps1" -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
|
||||
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName -CertificatePath $CertificatePath
|
||||
& "$PSScriptRoot\zip_symbols.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
& "$PSScriptRoot\zip_portable_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName
|
||||
@@ -43,13 +43,8 @@ param (
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
# Path to the zip file to upload with the release
|
||||
$ZipFilePath,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
#Path to the msi file to upload with the release
|
||||
$MsiFilePath,
|
||||
# Path to the folder which contains release assets to upload
|
||||
$ReleaseFolderPath,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
@@ -70,7 +65,17 @@ if ($DescriptionIsBase64Encoded) {
|
||||
. "$PSScriptRoot\github_functions.ps1"
|
||||
|
||||
|
||||
$releaseFolderItems = Get-ChildItem -Path $ReleaseFolderPath
|
||||
$mrngPortablePath = ($releaseFolderItems | ?{$_.Name -match "portable-[\d\.]+\.zip"}).FullName
|
||||
$mrngNormalPath = ($releaseFolderItems | ?{$_.Name -match "installer-[\d\.]+\.msi"}).FullName
|
||||
$mrngPortableSymbolsPath = ($releaseFolderItems | ?{$_.Name -match "mremoteng-portable-symbols-[\d\.]+\.zip"}).FullName
|
||||
$mrngNormalSymbolsPath = ($releaseFolderItems | ?{$_.Name -match "mremoteng-symbols-[\d\.]+\.zip"}).FullName
|
||||
|
||||
|
||||
$release = Publish-GitHubRelease -Owner $Owner -Repository $Repository -ReleaseTitle $ReleaseTitle -TagName $TagName -TargetCommitish $TargetCommitish -Description $Description -IsDraft ([bool]::Parse($IsDraft)) -IsPrerelease ([bool]::Parse($IsPrerelease)) -AuthToken $AuthToken
|
||||
$zipUpload = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $ZipFilePath -ContentType "application/zip" -AuthToken $AuthToken
|
||||
$msiUpload = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $MsiFilePath -ContentType "application/octet-stream" -AuthToken $AuthToken
|
||||
$zipUpload = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $mrngPortablePath -ContentType "application/zip" -AuthToken $AuthToken -Label "Portable Edition (zip)"
|
||||
$msiUpload = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $mrngNormalPath -ContentType "application/octet-stream" -AuthToken $AuthToken -Label "Normal Edition (msi)"
|
||||
|
||||
$portableEditionSymbols = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $mrngPortableSymbolsPath -ContentType "application/zip" -AuthToken $AuthToken -Label "Portable Edition Debug Symbols"
|
||||
$normalEditionSymbols = Upload-GitHubReleaseAsset -UploadUri $release.upload_url -FilePath $mrngNormalSymbolsPath -ContentType "application/zip" -AuthToken $AuthToken -Label "Normal Edition Debug Symbols"
|
||||
Write-Output (Get-GitHubRelease -Owner $Owner -Repository $Repository -ReleaseId $release.id -AuthToken $AuthToken)
|
||||
@@ -15,7 +15,6 @@ if ($ConfigurationName -match "Release") {
|
||||
Write-Output "Removing unnecessary files from Release versions"
|
||||
Remove-Item -Path (Join-Path -Path $TargetDir -ChildPath "app.publish") -Recurse -Force
|
||||
$filesToDelete = Get-ChildItem -Path $TargetDir -Recurse -Include @(
|
||||
"*.pdb",
|
||||
"*.publish",
|
||||
"*.xml",
|
||||
"*.backup",
|
||||
|
||||
@@ -13,13 +13,49 @@ param (
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
$path_packageZipScript = Join-Path -Path $SolutionDir -ChildPath "Tools\build-relport.cmd"
|
||||
|
||||
if(-not [string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "Too early to run via Appveyor - artifacts don't get generated properly. Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
Write-Output "Solution Dir: '$($SolutionDir)'"
|
||||
Write-Output "Target Dir: '$($TargetDir)'"
|
||||
$ConfigurationName = $ConfigurationName.Trim()
|
||||
Write-Output "Config Name (tirmmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
# Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
# Package Zip
|
||||
if ($ConfigurationName -match "Release" -and $ConfigurationName -match "Portable") {
|
||||
if ($ConfigurationName -eq "Release Portable") {
|
||||
Write-Output "Packaging Release Portable ZIP"
|
||||
& $path_packageZipScript
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$PortableZip="$($SolutionDir)Release\mRemoteNG-Portable-$($version).zip"
|
||||
|
||||
$tempFolderPath = Join-Path -Path $SolutionDir -ChildPath "mRemoteV1\bin\package"
|
||||
Remove-Item -Recurse $tempFolderPath -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item $tempFolderPath -ItemType "directory" | Out-Null
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\Resources\PuTTYNG.exe" -Destination $tempFolderPath
|
||||
|
||||
#Write-Output "$($SolutionDir)mRemoteV1\bin\$ConfigurationName"
|
||||
#Write-Output "$($SolutionDir)mRemoteV1\bin\package"
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\bin\$ConfigurationName\*" -Destination $tempFolderPath -Recurse -Force
|
||||
# Delete any PDB files that accidentally get copied into the temp folder
|
||||
Get-ChildItem -Path $tempFolderPath -Filter "*.pdb" | Remove-Item
|
||||
Copy-Item "$($SolutionDir)*.txt" -Destination $tempFolderPath
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip (Join-Path -Path $tempFolderPath -ChildPath "*.*")
|
||||
#& $SEVENZIP a -bt -mx=9 -tzip -y $PortableZip "$($SolutionDir)*.TXT"
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not zip anything - this isnt a portable release build."
|
||||
|
||||
39
Tools/zip_portable_files_appv.ps1
Normal file
39
Tools/zip_portable_files_appv.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
if([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "NOT running via Appveyor - Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
$appvDir = $Env:APPVEYOR_BUILD_FOLDER
|
||||
|
||||
Write-Output "Appveyor Build Dir: '$($appvDir)'"
|
||||
$ConfigurationName = $Env:CONFIGURATION.Trim()
|
||||
Write-Output "Config Name (tirmmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
if ($ConfigurationName -eq "Release Portable") {
|
||||
Write-Output "Packaging Release Portable ZIP"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
$PortableZip="$($SolutionDir)Release\mRemoteNG-Portable-$($version).zip"
|
||||
|
||||
Remove-Item -Recurse "$($SolutionDir)mRemoteV1\bin\package" -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item "$($SolutionDir)mRemoteV1\bin\package" -ItemType "directory" | Out-Null
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\Resources\PuTTYNG.exe" -Destination "$($SolutionDir)mRemoteV1\bin\package"
|
||||
|
||||
Copy-Item "$($SolutionDir)mRemoteV1\bin\$ConfigurationName\*" -Destination "$($SolutionDir)mRemoteV1\bin\package" -Recurse -Force
|
||||
Copy-Item "$($SolutionDir)*.txt" -Destination "$($SolutionDir)mRemoteV1\bin\package"
|
||||
|
||||
Write-Output "Creating portable ZIP file $($PortableZip)"
|
||||
Remove-Item -Force $PortableZip -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $PortableZip "$($SolutionDir)mRemoteV1\bin\package\*.*"
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not zip anything - this isnt a portable release build."
|
||||
}
|
||||
56
Tools/zip_symbols.ps1
Normal file
56
Tools/zip_symbols.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
param (
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$SolutionDir,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$TargetDir,
|
||||
|
||||
[string]
|
||||
[Parameter(Mandatory=$true)]
|
||||
$ConfigurationName
|
||||
)
|
||||
|
||||
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
|
||||
|
||||
if(-not [string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) {
|
||||
Write-Output "Too early to run via Appveyor - artifacts don't get generated properly. Exiting"
|
||||
Exit
|
||||
}
|
||||
|
||||
Write-Output "Solution Dir: '$($SolutionDir)'"
|
||||
Write-Output "Target Dir: '$($TargetDir)'"
|
||||
$ConfigurationName = $ConfigurationName.Trim()
|
||||
Write-Output "Config Name (trimmed): '$($ConfigurationName)'"
|
||||
|
||||
|
||||
# Windows Sysinternals Sigcheck from http://technet.microsoft.com/en-us/sysinternals/bb897441
|
||||
$SIGCHECK="$($SolutionDir)Tools\exes\sigcheck.exe"
|
||||
$SEVENZIP="$($SolutionDir)Tools\7zip\7za.exe"
|
||||
|
||||
# Package Zip
|
||||
if ($ConfigurationName -match "Release") {
|
||||
Write-Output "Packaging debug symbols"
|
||||
|
||||
$version = & $SIGCHECK /accepteula -q -n "$($SolutionDir)mRemoteV1\bin\$($ConfigurationName)\mRemoteNG.exe"
|
||||
|
||||
Write-Output "Version is $($version)"
|
||||
|
||||
if ($ConfigurationName -match "Portable") {
|
||||
$zipFilePrefix = "mRemoteNG-Portable-symbols"
|
||||
} else {
|
||||
$zipFilePrefix = "mRemoteNG-symbols"
|
||||
}
|
||||
|
||||
$outputZipPath="$($SolutionDir)Release\$zipFilePrefix-$($version).zip"
|
||||
|
||||
Write-Output "Creating debug symbols ZIP file $($outputZipPath)"
|
||||
Remove-Item -Force $outputZipPath -ErrorAction SilentlyContinue
|
||||
& $SEVENZIP a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath (Join-Path -Path $TargetDir -ChildPath "*.pdb")
|
||||
}
|
||||
else {
|
||||
Write-Output "We will not package debug symbols - this isnt a release build."
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
12
appveyor.yml
12
appveyor.yml
@@ -1,10 +1,11 @@
|
||||
version: 1.0.{build}
|
||||
version: 1.76.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
image: Visual Studio 2017
|
||||
configuration:
|
||||
- Release
|
||||
- Release Portable
|
||||
- Release Installer
|
||||
platform: x86
|
||||
clone_depth: 1
|
||||
install:
|
||||
@@ -14,7 +15,14 @@ before_build:
|
||||
build:
|
||||
project: mRemoteV1.sln
|
||||
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=\"$($SolutionDir)Tools\\exes\\sigcheck.exe\"\n$SEVENZIP=\"$($SolutionDir)Tools\\7zip\\7za.exe\"\n\nif ($ConfigurationName -eq \"Release Portable\") {\n Write-Output \"Packaging Release Portable ZIP\"\n \n $version = & $SIGCHECK /accepteula -q -n \"$($SolutionDir)mRemoteV1\\bin\\$($ConfigurationName)\\mRemoteNG.exe\"\n\n Write-Output \"Version is $($version)\"\n\n $PortableZip=\"$($SolutionDir)Release\\mRemoteNG-Portable-$($version).zip\"\n\n Remove-Item -Recurse \"$($SolutionDir)mRemoteV1\\bin\\package\" -ErrorAction SilentlyContinue | Out-Null\n New-Item \"$($SolutionDir)mRemoteV1\\bin\\package\" -ItemType \"directory\" | Out-Null\n \n Copy-Item \"$($SolutionDir)mRemoteV1\\Resources\\PuTTYNG.exe\" -Destination \"$($SolutionDir)mRemoteV1\\bin\\package\"\n\n Copy-Item \"$($SolutionDir)mRemoteV1\\bin\\$ConfigurationName\\*\" -Destination \"$($SolutionDir)mRemoteV1\\bin\\package\" -Recurse -Force \n Copy-Item \"$($SolutionDir)*.txt\" -Destination \"$($SolutionDir)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 \"$($SolutionDir)mRemoteV1\\bin\\package\\*.*\"\n}\nelse {\n Write-Output \"We will not zip anything - this isnt a portable release build.\"\n}"
|
||||
test:
|
||||
assemblies:
|
||||
only:
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
- mRemoteNGTests\bin\$(configuration)\mRemoteNGTests.dll
|
||||
artifacts:
|
||||
- path: Release\*.msi
|
||||
name: mRemoteNG-installer.msi
|
||||
- path: Release\*.zip
|
||||
name: mRemoteNG-portable.zip
|
||||
17
mRemoteNGTests/AssemblyTestSetup.cs
Normal file
17
mRemoteNGTests/AssemblyTestSetup.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Windows.Forms;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
// Dont put this in a namespace. Leaving it by itself tells NUnit
|
||||
// to run it on assembly load
|
||||
[SetUpFixture]
|
||||
public class AssemblyTestSetup
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public void AssemblySetup()
|
||||
{
|
||||
// ensure window options set before any test window created
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.Properties;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
@@ -19,7 +22,10 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml
|
||||
|
||||
public void Setup(string confCons, string password)
|
||||
{
|
||||
_xmlConnectionsDeserializer = new XmlConnectionsDeserializer(password.ConvertToSecureString);
|
||||
var connectionsService = new ConnectionsService(PuttySessionsManager.Instance,
|
||||
new Import(Substitute.For<IWin32Window>()),
|
||||
Substitute.For<IWin32Window>());
|
||||
_xmlConnectionsDeserializer = new XmlConnectionsDeserializer(connectionsService, Substitute.For<IWin32Window>(), () => password.ConvertToSecureString());
|
||||
_connectionTreeModel = _xmlConnectionsDeserializer.Deserialize(confCons);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using mRemoteNG.Connection;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers
|
||||
@@ -18,7 +19,7 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
{
|
||||
var model = CreateConnectionTreeModel();
|
||||
var dataTable = CreateDataTable(model.RootNodes[0]);
|
||||
_deserializer = new DataTableDeserializer();
|
||||
_deserializer = new DataTableDeserializer(Substitute.For<IConnectionsService>());
|
||||
var output = _deserializer.Deserialize(dataTable);
|
||||
Assert.That(output.GetRecursiveChildList().Count(), Is.EqualTo(model.GetRecursiveChildList().Count()));
|
||||
}
|
||||
@@ -27,7 +28,7 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
public void WeCanDeserializeASingleEntry()
|
||||
{
|
||||
var dataTable = CreateDataTable(new ConnectionInfo());
|
||||
_deserializer = new DataTableDeserializer();
|
||||
_deserializer = new DataTableDeserializer(Substitute.For<IConnectionsService>());
|
||||
var output = _deserializer.Deserialize(dataTable);
|
||||
Assert.That(output.GetRecursiveChildList().Count(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using NUnit.Framework;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
@@ -74,6 +75,22 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(hasEverythingInheritedProperty, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AlwaysReturnInheritedValueIfRequested()
|
||||
{
|
||||
var expectedSetting = false;
|
||||
|
||||
var container = new ContainerInfo { AutomaticResize = expectedSetting };
|
||||
var con1 = new ConnectionInfo
|
||||
{
|
||||
AutomaticResize = true,
|
||||
Inheritance = {AutomaticResize = true}
|
||||
};
|
||||
container.AddChild(con1);
|
||||
|
||||
Assert.That(con1.AutomaticResize, Is.EqualTo(expectedSetting));
|
||||
}
|
||||
|
||||
private bool AllInheritancePropertiesAreTrue()
|
||||
{
|
||||
var allPropertiesTrue = true;
|
||||
|
||||
@@ -5,6 +5,7 @@ using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.SSH;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -13,11 +14,13 @@ namespace mRemoteNGTests.Connection
|
||||
public class ConnectionInfoTests
|
||||
{
|
||||
private ConnectionInfo _connectionInfo;
|
||||
private IConnectionsService _connectionsService;
|
||||
private const string TestDomain = "somedomain";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_connectionsService = Substitute.For<IConnectionsService>();
|
||||
_connectionInfo = new ConnectionInfo();
|
||||
}
|
||||
|
||||
@@ -43,6 +46,20 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(clonedConnection.Parent, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneAlsoCopiesInheritanceObject()
|
||||
{
|
||||
var clonedConnection = _connectionInfo.Clone();
|
||||
Assert.That(clonedConnection.Inheritance, Is.Not.EqualTo(_connectionInfo.Inheritance));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CloneCorrectlySetsParentOfInheritanceObject()
|
||||
{
|
||||
var clonedConnection = _connectionInfo.Clone();
|
||||
Assert.That(clonedConnection.Inheritance.Parent, Is.EqualTo(clonedConnection));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromCopiesProperties()
|
||||
{
|
||||
@@ -65,7 +82,7 @@ namespace mRemoteNGTests.Connection
|
||||
{
|
||||
var eventWasCalled = false;
|
||||
_connectionInfo.PropertyChanged += (sender, args) => eventWasCalled = true;
|
||||
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
|
||||
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionsService));
|
||||
Assert.That(eventWasCalled);
|
||||
}
|
||||
|
||||
@@ -74,7 +91,7 @@ namespace mRemoteNGTests.Connection
|
||||
{
|
||||
var nameOfModifiedProperty = "";
|
||||
_connectionInfo.PropertyChanged += (sender, args) => nameOfModifiedProperty = args.PropertyName;
|
||||
_connectionInfo.OpenConnections.Add(new ProtocolSSH2());
|
||||
_connectionInfo.OpenConnections.Add(new ProtocolSSH2(_connectionsService));
|
||||
Assert.That(nameOfModifiedProperty, Is.EqualTo("OpenConnections"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,73 +1,62 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInfoTests
|
||||
{
|
||||
private string _testDomain = "somedomain";
|
||||
public class DefaultConnectionInfoTests
|
||||
{
|
||||
private ConnectionInfo _randomizedConnectionInfo;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
DefaultConnectionInfo.Instance.Domain = "";
|
||||
_randomizedConnectionInfo = ConnectionInfoHelpers.GetRandomizedConnectionInfo();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadingDefaultInfoUpdatesAllProperties()
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void LoadingDefaultInfoUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
var connectionInfoSource = new ConnectionInfo { Domain = _testDomain };
|
||||
DefaultConnectionInfo.Instance.LoadFrom(connectionInfoSource);
|
||||
Assert.That(DefaultConnectionInfo.Instance.Domain, Is.EqualTo(_testDomain));
|
||||
DefaultConnectionInfo.Instance.LoadFrom(_randomizedConnectionInfo);
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInfo.Instance);
|
||||
var valueInSource = property.GetValue(_randomizedConnectionInfo);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SavingDefaultConnectionInfoExportsAllProperties()
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void SavingDefaultConnectionInfoExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var saveTarget = new ConnectionInfo();
|
||||
DefaultConnectionInfo.Instance.Domain = _testDomain;
|
||||
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
|
||||
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Domain, Is.EqualTo(_testDomain));
|
||||
var valueInDestination = property.GetValue(saveTarget);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveEnumValuesToString()
|
||||
{
|
||||
const ProtocolType targetProtocol = ProtocolType.RAW;
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.Protocol = targetProtocol;
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void CanSaveDefaultConnectionToModelWithAllStringProperties(PropertyInfo property)
|
||||
{
|
||||
var saveTarget = new SerializableConnectionInfoAllPropertiesOfType<string>();
|
||||
|
||||
// randomize default connnection values to ensure we dont get false passing tests
|
||||
var randomizedValue = property.GetValue(_randomizedConnectionInfo);
|
||||
property.SetValue(DefaultConnectionInfo.Instance, randomizedValue);
|
||||
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Protocol, Is.EqualTo(targetProtocol.ToString()));
|
||||
|
||||
var valueInSource = property.GetValue(DefaultConnectionInfo.Instance).ToString();
|
||||
var valueInDestination = saveTarget.GetType().GetProperty(property.Name).GetValue(saveTarget).ToString();
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveIntegerValuesToString()
|
||||
{
|
||||
const int targetValue = 123;
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.RDPMinutesToIdleTimeout = targetValue;
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.RDPMinutesToIdleTimeout, Is.EqualTo(targetValue.ToString()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSaveStringValuesToString()
|
||||
{
|
||||
const string targetName = "hello";
|
||||
var saveTarget = new AllStringPropertySaveTarget();
|
||||
DefaultConnectionInfo.Instance.Username = targetName;
|
||||
DefaultConnectionInfo.Instance.SaveTo(saveTarget);
|
||||
Assert.That(saveTarget.Username, Is.EqualTo(targetName));
|
||||
}
|
||||
|
||||
|
||||
private class AllStringPropertySaveTarget
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Protocol { get; set; }
|
||||
public string RDPMinutesToIdleTimeout { get; set; }
|
||||
}
|
||||
private static IEnumerable<PropertyInfo> GetConnectionInfoProperties()
|
||||
{
|
||||
return new ConnectionInfo().GetSerializableProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,40 @@
|
||||
using mRemoteNG.Connection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.Connection;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInheritanceTests
|
||||
public class DefaultConnectionInheritanceTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties()
|
||||
{
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
inheritanceSource.TurnOnInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
Assert.That(DefaultConnectionInheritance.Instance.EverythingInherited, Is.True);
|
||||
}
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
|
||||
[Test]
|
||||
public void SavingDefaultInheritanceExportsAllProperties()
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
var valueInSource = property.GetValue(inheritanceSource);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var inheritanceDestination = new ConnectionInfoInheritance(new object(), true);
|
||||
DefaultConnectionInheritance.Instance.AutomaticResize = true;
|
||||
DefaultConnectionInheritance.Instance.SaveTo(inheritanceDestination);
|
||||
Assert.That(inheritanceDestination.AutomaticResize, Is.True);
|
||||
}
|
||||
var saveTarget = new ConnectionInfoInheritance(new object(), true);
|
||||
saveTarget.TurnOffInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
|
||||
DefaultConnectionInheritance.Instance.SaveTo(saveTarget);
|
||||
|
||||
var valueInDestination = property.GetValue(saveTarget);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
|
||||
@@ -38,12 +44,20 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(inheritanceInstance.Domain, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new object());
|
||||
Assert.That(inheritanceInstance.EverythingInherited, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
var valueInDestination = property.GetValue(inheritanceInstance);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object(), true).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,50 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Update;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Credential.Repositories;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tools.CustomCollections;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNGTests.Connection.Protocol
|
||||
{
|
||||
public class IntegratedProgramTests
|
||||
{
|
||||
private readonly ExternalTool _extTool = new ExternalTool
|
||||
{
|
||||
DisplayName = "notepad",
|
||||
FileName = @"%windir%\system32\notepad.exe",
|
||||
Arguments = "",
|
||||
TryIntegrate = true
|
||||
};
|
||||
public class IntegratedProgramTests
|
||||
{
|
||||
private ExternalToolsService _externalToolsService;
|
||||
private IConnectionInitiator _connectionInitiator;
|
||||
|
||||
|
||||
[Test]
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_connectionInitiator = Substitute.For<IConnectionInitiator>();
|
||||
var extTool = new ExternalTool(_connectionInitiator, Substitute.For<IConnectionsService>())
|
||||
{
|
||||
DisplayName = "notepad",
|
||||
FileName = @"%windir%\system32\notepad.exe",
|
||||
Arguments = "",
|
||||
TryIntegrate = true
|
||||
};
|
||||
_externalToolsService = new ExternalToolsService();
|
||||
_externalToolsService.ExternalTools.Add(extTool);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CanStartExternalApp()
|
||||
{
|
||||
SetExternalToolList(_extTool);
|
||||
var sut = new IntegratedProgram();
|
||||
var sut = new IntegratedProgram(_externalToolsService, Substitute.For<IConnectionsService>());
|
||||
sut.InterfaceControl = BuildInterfaceControl("notepad", sut);
|
||||
sut.Initialize();
|
||||
var appStarted = sut.Connect();
|
||||
@@ -34,23 +53,42 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void ConnectingToExternalAppThatDoesntExistDoesNothing()
|
||||
{
|
||||
SetExternalToolList(_extTool);
|
||||
var sut = new IntegratedProgram();
|
||||
var sut = new IntegratedProgram(_externalToolsService, Substitute.For<IConnectionsService>());
|
||||
sut.InterfaceControl = BuildInterfaceControl("doesntExist", sut);
|
||||
var appInitialized = sut.Initialize();
|
||||
Assert.That(appInitialized, Is.False);
|
||||
}
|
||||
|
||||
private void SetExternalToolList(ExternalTool externalTool)
|
||||
{
|
||||
Runtime.ExternalToolsService.ExternalTools = new FullyObservableCollection<ExternalTool> {externalTool};
|
||||
}
|
||||
|
||||
private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut)
|
||||
{
|
||||
var connectionWindow = new ConnectionWindow(new DockContent());
|
||||
var frmMain = new FrmMain();
|
||||
var import = new Import(Substitute.For<IWin32Window>());
|
||||
var connectionsService = new ConnectionsService(PuttySessionsManager.Instance, import, frmMain);
|
||||
var configWindow = new ConfigWindow(new DockContent(), connectionsService);
|
||||
var sshTransferWindow = new SSHTransferWindow();
|
||||
var connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), _connectionInitiator, connectionsService);
|
||||
Func<SecureString> encryptionKeySelectionFunc = () => connectionsService.EncryptionKey;
|
||||
var connectionTree = connectionTreeWindow.ConnectionTree;
|
||||
var export = new Export(new CredentialRepositoryList(), connectionsService, frmMain);
|
||||
var connectionTreeContextMenu = new ConnectionContextMenu(connectionTree, _connectionInitiator, sshTransferWindow, export, _externalToolsService, import, connectionsService);
|
||||
connectionTreeWindow.ConnectionTreeContextMenu = connectionTreeContextMenu;
|
||||
var errorAndInfoWindow = new ErrorAndInfoWindow(new DockContent(), new DockPanel(), connectionTreeWindow);
|
||||
var screenshotManagerWindow = new ScreenshotManagerWindow(new DockContent(), new DockPanel());
|
||||
var shutdown = new Shutdown(new SettingsSaver(new ExternalToolsService()), new ConnectionsService(PuttySessionsManager.Instance, import, frmMain), frmMain);
|
||||
var appUpdater = new AppUpdater(encryptionKeySelectionFunc);
|
||||
Func<UpdateWindow> updateWindowBuilder = () => new UpdateWindow(new DockContent(), shutdown, appUpdater);
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder = () => new NotificationAreaIcon(frmMain, _connectionInitiator, shutdown, connectionsService);
|
||||
Func<ExternalToolsWindow> externalToolsWindowBuilder = () => new ExternalToolsWindow(_connectionInitiator, _externalToolsService, () => connectionTree.SelectedNode, frmMain, connectionsService);
|
||||
Func<PortScanWindow> portScanWindowBuilder = () => new PortScanWindow(connectionTreeWindow, import);
|
||||
Func<ActiveDirectoryImportWindow> activeDirectoryImportWindowBuilder = () => new ActiveDirectoryImportWindow(() => connectionTreeWindow.SelectedNode, import, connectionsService);
|
||||
var databaseConnectorFactory = new DatabaseConnectorFactory(encryptionKeySelectionFunc);
|
||||
var windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow,
|
||||
sshTransferWindow, updateWindowBuilder, notificationAreaIconBuilder, externalToolsWindowBuilder,
|
||||
connectionsService, portScanWindowBuilder, activeDirectoryImportWindowBuilder, appUpdater, databaseConnectorFactory, frmMain);
|
||||
var connectionWindow = new ConnectionWindow(new DockContent(), _connectionInitiator, windows, _externalToolsService, frmMain);
|
||||
var connectionInfo = new ConnectionInfo {ExtApp = extAppName};
|
||||
return new InterfaceControl(connectionWindow, sut, connectionInfo);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.SSH;
|
||||
using mRemoteNG.Connection.Protocol.Telnet;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -20,9 +23,10 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var connectionService = Substitute.For<IConnectionsService>();
|
||||
_protocolList = new ProtocolList();
|
||||
_protocol1 = new ProtocolTelnet();
|
||||
_protocol2 = new ProtocolSSH2();
|
||||
_protocol1 = new ProtocolTelnet(connectionService);
|
||||
_protocol2 = new ProtocolSSH2(connectionService);
|
||||
_protocol3 = new ProtocolVNC();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
@@ -7,6 +10,7 @@ using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -29,20 +33,20 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
_originalModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
new SaveFilter());
|
||||
_serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer);
|
||||
var mockWindow = Substitute.For<IWin32Window>();
|
||||
_deserializer = new XmlConnectionsDeserializer(new ConnectionsService(PuttySessionsManager.Instance, new Import(mockWindow), mockWindow), mockWindow);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_serializer = null;
|
||||
_deserializer = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeThenDeserialize()
|
||||
{
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
@@ -54,7 +58,6 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
{
|
||||
_serializer.UseFullEncryption = true;
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
@@ -66,7 +69,6 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
{
|
||||
var originalConnectionInfo = new ConnectionInfo {Name = "con1", Description = "£°úg¶┬ä" };
|
||||
var serializedContent = _serializer.Serialize(originalConnectionInfo);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var deserializedConnectionInfo = deserializedModel.GetRecursiveChildList().First(node => node.Name == originalConnectionInfo.Name);
|
||||
Assert.That(deserializedConnectionInfo.Description, Is.EqualTo(originalConnectionInfo.Description));
|
||||
@@ -84,13 +86,26 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
new SaveFilter());
|
||||
_serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer);
|
||||
var serializedContent = _serializer.Serialize(_originalModel);
|
||||
_deserializer = new XmlConnectionsDeserializer();
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name);
|
||||
Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GuidCreatedIfNonExistedInXml()
|
||||
{
|
||||
var originalConnectionInfo = new ConnectionInfo { Name = "con1" };
|
||||
var serializedContent = _serializer.Serialize(originalConnectionInfo);
|
||||
|
||||
// remove GUID from connection xml
|
||||
serializedContent = serializedContent.Replace(originalConnectionInfo.ConstantID, "");
|
||||
|
||||
var deserializedModel = _deserializer.Deserialize(serializedContent);
|
||||
var deserializedConnectionInfo = deserializedModel.GetRecursiveChildList().First(node => node.Name == originalConnectionInfo.Name);
|
||||
Assert.That(Guid.TryParse(deserializedConnectionInfo.ConstantID, out var guid));
|
||||
}
|
||||
|
||||
|
||||
private ConnectionTreeModel SetupConnectionTreeModel()
|
||||
{
|
||||
@@ -127,4 +142,4 @@ namespace mRemoteNGTests.IntegrationTests
|
||||
return connectionTreeModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Authentication;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -9,35 +10,31 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
{
|
||||
public class PasswordAuthenticatorTests
|
||||
{
|
||||
private PasswordAuthenticator _authenticator;
|
||||
private ICryptographyProvider _cryptographyProvider;
|
||||
private string _cipherText;
|
||||
private readonly SecureString _correctPassword = "9theCorrectPass#5".ConvertToSecureString();
|
||||
private readonly SecureString _wrongPassword = "wrongPassword".ConvertToSecureString();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var cryptoProvider = new AeadCryptographyProvider {KeyDerivationIterations = 10000};
|
||||
const string cipherText = "MPELiwk7+xeNlruIyt5uxTvVB+/RLVoLdUGnwY4CWCqwKe7T2IBwWo4oaKum5hdv7447g5m2nZsYPrfARSlotQB4r1KZQg==";
|
||||
_authenticator = new PasswordAuthenticator(cryptoProvider, cipherText);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_authenticator = null;
|
||||
_cryptographyProvider = new AeadCryptographyProvider {KeyDerivationIterations = 10000};
|
||||
_cipherText = "MPELiwk7+xeNlruIyt5uxTvVB+/RLVoLdUGnwY4CWCqwKe7T2IBwWo4oaKum5hdv7447g5m2nZsYPrfARSlotQB4r1KZQg==";
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatingWithCorrectPasswordReturnsTrue()
|
||||
{
|
||||
var authenticated = _authenticator.Authenticate(_correctPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => Optional<SecureString>.Empty);
|
||||
var authenticated = authenticator.Authenticate(_correctPassword);
|
||||
Assert.That(authenticated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatingWithWrongPasswordReturnsFalse()
|
||||
{
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => Optional<SecureString>.Empty);
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(!authenticated);
|
||||
}
|
||||
|
||||
@@ -45,12 +42,15 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticationRequestorIsCalledWhenInitialPasswordIsWrong()
|
||||
{
|
||||
var wasCalled = false;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
wasCalled = true;
|
||||
return _correctPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(wasCalled);
|
||||
}
|
||||
|
||||
@@ -58,28 +58,30 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticationRequestorNotCalledWhenInitialPasswordIsCorrect()
|
||||
{
|
||||
var wasCalled = false;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
wasCalled = true;
|
||||
return _correctPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_correctPassword);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_correctPassword);
|
||||
Assert.That(!wasCalled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProvidingCorrectPasswordToTheAuthenticationRequestorReturnsTrue()
|
||||
{
|
||||
_authenticator.AuthenticationRequestor = () => _correctPassword;
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => _correctPassword);
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authenticated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticationFailsWhenAuthenticationRequestorGivenEmptyPassword()
|
||||
{
|
||||
_authenticator.AuthenticationRequestor = () => new SecureString();
|
||||
var authenticated = _authenticator.Authenticate(_wrongPassword);
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, () => new SecureString());
|
||||
var authenticated = authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(!authenticated);
|
||||
}
|
||||
|
||||
@@ -87,27 +89,34 @@ namespace mRemoteNGTests.Security.Authentication
|
||||
public void AuthenticatorRespectsMaxAttempts()
|
||||
{
|
||||
var authAttempts = 0;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
authAttempts++;
|
||||
return _wrongPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == _authenticator.MaxAttempts);
|
||||
}
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor);
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == authenticator.MaxAttempts);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AuthenticatorRespectsMaxAttemptsCustomValue()
|
||||
{
|
||||
const int customMaxAttempts = 5;
|
||||
_authenticator.MaxAttempts = customMaxAttempts;
|
||||
var authAttempts = 0;
|
||||
_authenticator.AuthenticationRequestor = () =>
|
||||
Optional<SecureString> AuthenticationRequestor()
|
||||
{
|
||||
authAttempts++;
|
||||
return _wrongPassword;
|
||||
};
|
||||
_authenticator.Authenticate(_wrongPassword);
|
||||
}
|
||||
|
||||
var authenticator =
|
||||
new PasswordAuthenticator(_cryptographyProvider, _cipherText, AuthenticationRequestor)
|
||||
{
|
||||
MaxAttempts = customMaxAttempts
|
||||
};
|
||||
authenticator.Authenticate(_wrongPassword);
|
||||
Assert.That(authAttempts == customMaxAttempts);
|
||||
}
|
||||
}
|
||||
|
||||
132
mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs
Normal file
132
mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
internal static class ConnectionInfoHelpers
|
||||
{
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="ConnectionInfo"/> object with randomized
|
||||
/// values in all fields.
|
||||
/// </summary>
|
||||
internal static ConnectionInfo GetRandomizedConnectionInfo(bool randomizeInheritance = false)
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo
|
||||
{
|
||||
// string types
|
||||
Name = RandomString(),
|
||||
Hostname = RandomString(),
|
||||
Description = RandomString(),
|
||||
Domain = RandomString(),
|
||||
ExtApp = RandomString(),
|
||||
Icon = RandomString(),
|
||||
LoadBalanceInfo = RandomString(),
|
||||
MacAddress = RandomString(),
|
||||
Panel = RandomString(),
|
||||
Password = RandomString(),
|
||||
PostExtApp = RandomString(),
|
||||
PreExtApp = RandomString(),
|
||||
PuttySession = RandomString(),
|
||||
RDGatewayHostname = RandomString(),
|
||||
RDGatewayUsername = RandomString(),
|
||||
RDGatewayDomain = RandomString(),
|
||||
RDGatewayPassword = RandomString(),
|
||||
UserField = RandomString(),
|
||||
Username = RandomString(),
|
||||
VNCProxyIP = RandomString(),
|
||||
VNCProxyPassword = RandomString(),
|
||||
VNCProxyUsername = RandomString(),
|
||||
|
||||
// bool types
|
||||
AutomaticResize = RandomBool(),
|
||||
CacheBitmaps = RandomBool(),
|
||||
DisplayThemes = RandomBool(),
|
||||
DisplayWallpaper = RandomBool(),
|
||||
EnableDesktopComposition = RandomBool(),
|
||||
EnableFontSmoothing = RandomBool(),
|
||||
IsContainer = RandomBool(),
|
||||
IsDefault = RandomBool(),
|
||||
IsQuickConnect = RandomBool(),
|
||||
PleaseConnect = RandomBool(),
|
||||
RDPAlertIdleTimeout = RandomBool(),
|
||||
RedirectDiskDrives = RandomBool(),
|
||||
RedirectKeys = RandomBool(),
|
||||
RedirectPorts = RandomBool(),
|
||||
RedirectPrinters = RandomBool(),
|
||||
RedirectSmartCards = RandomBool(),
|
||||
UseConsoleSession = RandomBool(),
|
||||
UseCredSsp = RandomBool(),
|
||||
VNCViewOnly = RandomBool(),
|
||||
|
||||
// ints
|
||||
Port = RandomInt(),
|
||||
RDPMinutesToIdleTimeout = RandomInt(),
|
||||
VNCProxyPort = RandomInt(),
|
||||
|
||||
// enums
|
||||
Colors = RandomEnum<RdpProtocol.RDPColors>(),
|
||||
ICAEncryptionStrength = RandomEnum<IcaProtocol.EncryptionStrength> (),
|
||||
Protocol = RandomEnum<ProtocolType>(),
|
||||
RDGatewayUsageMethod = RandomEnum<RdpProtocol.RDGatewayUsageMethod>(),
|
||||
RDGatewayUseConnectionCredentials = RandomEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(),
|
||||
RDPAuthenticationLevel = RandomEnum<RdpProtocol.AuthenticationLevel>(),
|
||||
RedirectSound = RandomEnum<RdpProtocol.RDPSounds>(),
|
||||
RenderingEngine = RandomEnum<HTTPBase.RenderingEngine>(),
|
||||
Resolution = RandomEnum<RdpProtocol.RDPResolutions>(),
|
||||
SoundQuality = RandomEnum<RdpProtocol.RDPSoundQuality>(),
|
||||
VNCAuthMode = RandomEnum<ProtocolVNC.AuthMode>(),
|
||||
VNCColors = RandomEnum<ProtocolVNC.Colors>(),
|
||||
VNCCompression = RandomEnum<ProtocolVNC.Compression>(),
|
||||
VNCEncoding = RandomEnum<ProtocolVNC.Encoding>(),
|
||||
VNCProxyType = RandomEnum<ProtocolVNC.ProxyType>(),
|
||||
VNCSmartSizeMode = RandomEnum<ProtocolVNC.SmartSizeMode>(),
|
||||
};
|
||||
|
||||
if (randomizeInheritance)
|
||||
connectionInfo.Inheritance = GetRandomizedInheritance(connectionInfo);
|
||||
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
internal static ConnectionInfoInheritance GetRandomizedInheritance(ConnectionInfo parent)
|
||||
{
|
||||
var inheritance = new ConnectionInfoInheritance(parent, true);
|
||||
foreach (var property in inheritance.GetProperties())
|
||||
{
|
||||
property.SetValue(inheritance, RandomBool());
|
||||
}
|
||||
return inheritance;
|
||||
}
|
||||
|
||||
internal static string RandomString()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
internal static bool RandomBool()
|
||||
{
|
||||
return _random.Next() % 2 == 0;
|
||||
}
|
||||
|
||||
internal static int RandomInt()
|
||||
{
|
||||
return _random.Next();
|
||||
}
|
||||
|
||||
internal static T RandomEnum<T>() where T : struct, IConvertible
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("T must be an enum");
|
||||
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
return (T)values.GetValue(_random.Next(values.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A ConnectionInfo that has only the serializable properties as string types.
|
||||
/// Only used for testing.
|
||||
/// </summary>
|
||||
internal class SerializableConnectionInfoAllPropertiesOfType<TType>
|
||||
{
|
||||
public TType Description { get; set; }
|
||||
public TType Icon { get; set; }
|
||||
public TType Panel { get; set; }
|
||||
public TType Username { get; set; }
|
||||
public TType Password { get; set; }
|
||||
public TType Domain { get; set; }
|
||||
public TType Protocol { get; set; }
|
||||
public TType ExtApp { get; set; }
|
||||
public TType PuttySession { get; set; }
|
||||
public TType ICAEncryptionStrength { get; set; }
|
||||
public TType UseConsoleSession { get; set; }
|
||||
public TType RDPAuthenticationLevel { get; set; }
|
||||
public TType RDPMinutesToIdleTimeout { get; set; }
|
||||
public TType RDPAlertIdleTimeout { get; set; }
|
||||
public TType LoadBalanceInfo { get; set; }
|
||||
public TType RenderingEngine { get; set; }
|
||||
public TType UseCredSsp { get; set; }
|
||||
public TType RDGatewayUsageMethod { get; set; }
|
||||
public TType RDGatewayHostname { get; set; }
|
||||
public TType RDGatewayUseConnectionCredentials { get; set; }
|
||||
public TType RDGatewayUsername { get; set; }
|
||||
public TType RDGatewayPassword { get; set; }
|
||||
public TType RDGatewayDomain { get; set; }
|
||||
public TType Resolution { get; set; }
|
||||
public TType AutomaticResize { get; set; }
|
||||
public TType Colors { get; set; }
|
||||
public TType CacheBitmaps { get; set; }
|
||||
public TType DisplayWallpaper { get; set; }
|
||||
public TType DisplayThemes { get; set; }
|
||||
public TType EnableFontSmoothing { get; set; }
|
||||
public TType EnableDesktopComposition { get; set; }
|
||||
public TType RedirectKeys { get; set; }
|
||||
public TType RedirectDiskDrives { get; set; }
|
||||
public TType RedirectPrinters { get; set; }
|
||||
public TType RedirectClipboard { get; set; }
|
||||
public TType RedirectPorts { get; set; }
|
||||
public TType RedirectSmartCards { get; set; }
|
||||
public TType RedirectSound { get; set; }
|
||||
public TType SoundQuality { get; set; }
|
||||
public TType PreExtApp { get; set; }
|
||||
public TType PostExtApp { get; set; }
|
||||
public TType MacAddress { get; set; }
|
||||
public TType UserField { get; set; }
|
||||
public TType VNCCompression { get; set; }
|
||||
public TType VNCEncoding { get; set; }
|
||||
public TType VNCAuthMode { get; set; }
|
||||
public TType VNCProxyType { get; set; }
|
||||
public TType VNCProxyIP { get; set; }
|
||||
public TType VNCProxyPort { get; set; }
|
||||
public TType VNCProxyUsername { get; set; }
|
||||
public TType VNCProxyPassword { get; set; }
|
||||
public TType VNCColors { get; set; }
|
||||
public TType VNCSmartSizeMode { get; set; }
|
||||
public TType VNCViewOnly { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -34,7 +35,7 @@ namespace mRemoteNGTests.Tools
|
||||
MacAddress = TestString,
|
||||
UserField = TestString
|
||||
};
|
||||
_argumentParser = new ExternalToolArgumentParser(connectionInfo);
|
||||
_argumentParser = new ExternalToolArgumentParser(connectionInfo, Substitute.For<IConnectionsService>());
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
@@ -52,7 +53,7 @@ namespace mRemoteNGTests.Tools
|
||||
[Test]
|
||||
public void NullConnectionInfoResultsInEmptyVariables()
|
||||
{
|
||||
var parser = new ExternalToolArgumentParser(null);
|
||||
var parser = new ExternalToolArgumentParser(null, Substitute.For<IConnectionsService>());
|
||||
var parsedText = parser.ParseArguments("test %USERNAME% test");
|
||||
Assert.That(parsedText, Is.EqualTo("test test"));
|
||||
}
|
||||
|
||||
50
mRemoteNGTests/Tools/Registry/WindowsRegistryTests.cs
Normal file
50
mRemoteNGTests/Tools/Registry/WindowsRegistryTests.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Tools.WindowsRegistry;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tools.Registry
|
||||
{
|
||||
public class WindowsRegistryTests
|
||||
{
|
||||
private WindowsRegistry _registry;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_registry = new WindowsRegistry();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanGetSubkeyNames()
|
||||
{
|
||||
var subKeyNames = _registry.GetSubKeyNames(RegistryHive.CurrentUser, "Software");
|
||||
Assert.That(subKeyNames, Does.Contain("Microsoft"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSubkeyNamesThrowsIfGivenNullKeyPath()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _registry.GetSubKeyNames(RegistryHive.CurrentUser, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanGetKeyValue()
|
||||
{
|
||||
var keyValue = _registry.GetKeyValue(RegistryHive.ClassesRoot, @".dll\PersistentHandler", "");
|
||||
Assert.That(keyValue.FirstOrDefault(), Is.EqualTo("{098f2470-bae0-11cd-b579-08002b30bfeb}"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetKeyValueThrowsIfGivenNullKeyPath()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _registry.GetKeyValue(RegistryHive.CurrentUser, null, ""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetKeyValueThrowsIfGivenNullPropertyName()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _registry.GetKeyValue(RegistryHive.CurrentUser, "", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tree
|
||||
{
|
||||
public class NodeSearcherTests
|
||||
public class NodeSearcherTests
|
||||
{
|
||||
private NodeSearcher _nodeSearcher;
|
||||
private ContainerInfo _folder1;
|
||||
@@ -104,6 +104,14 @@ namespace mRemoteNGTests.Tree
|
||||
_con4 = new ConnectionInfo { Name = "con4", Description="description6", Hostname="hostname6" };
|
||||
_con5 = new ConnectionInfo { Name = "con5", Description="description7", Hostname="hostname7" };
|
||||
|
||||
_folder1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_folder2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con3.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con4.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con5.Inheritance.TurnOffInheritanceCompletely();
|
||||
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
root.AddChildRange(new [] { _folder1, _folder2, _con5 });
|
||||
_folder1.AddChildRange(new [] { _con1, _con2 });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -46,5 +47,13 @@ namespace mRemoteNGTests.Tree
|
||||
_rootNodeInfo.PasswordString = password;
|
||||
Assert.That(_rootNodeInfo.PasswordString, Is.EqualTo(password));
|
||||
}
|
||||
|
||||
[TestCase(RootNodeType.Connection, TreeNodeType.Root)]
|
||||
[TestCase(RootNodeType.PuttySessions, TreeNodeType.PuttyRoot)]
|
||||
public void RootNodeHasCorrectTreeNodeType(RootNodeType rootNodeType, TreeNodeType expectedTreeNodeType)
|
||||
{
|
||||
var rootNode = new RootNodeInfo(rootNodeType);
|
||||
Assert.That(rootNode.GetTreeNodeType(), Is.EqualTo(expectedTreeNodeType));
|
||||
}
|
||||
}
|
||||
}
|
||||
202
mRemoteNGTests/UI/Controls/ConnectionTreeTests.cs
Normal file
202
mRemoteNGTests/UI/Controls/ConnectionTreeTests.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public class ConnectionTreeTests
|
||||
{
|
||||
private ConnectionTreeSearchTextFilter _filter;
|
||||
private ConnectionTree _connectionTree;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_filter = new ConnectionTreeSearchTextFilter();
|
||||
_connectionTree = new ConnectionTree
|
||||
{
|
||||
UseFiltering = true
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void FilteringIsRetainedAndUpdatedWhenNodeDeleted()
|
||||
{
|
||||
// root
|
||||
// |- folder1
|
||||
// | |- con1
|
||||
// | |- dontshowme
|
||||
// |- folder2
|
||||
// |- con2
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var folder1 = new ContainerInfo {Name = "folder1"};
|
||||
var folder2 = new ContainerInfo {Name = "folder2"};
|
||||
var con1 = new ConnectionInfo {Name = "con1"};
|
||||
var con2 = new ConnectionInfo {Name = "con2"};
|
||||
var conDontShow = new ConnectionInfo {Name = "dontshowme" };
|
||||
root.AddChildRange(new []{folder1, folder2});
|
||||
folder1.AddChildRange(new []{con1, conDontShow});
|
||||
folder2.AddChild(con2);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
// ensure all folders expanded
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
// apply filtering on the tree
|
||||
_filter.FilterText = "con";
|
||||
_connectionTree.ModelFilter = _filter;
|
||||
|
||||
connectionTreeModel.DeleteNode(con1);
|
||||
|
||||
Assert.That(_connectionTree.IsFiltering, Is.True);
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Not.Contain(con1));
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Not.Contain(conDontShow));
|
||||
Assert.That(_connectionTree.FilteredObjects, Does.Contain(con2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotAddConnectionToPuttySessionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddConnection();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotAddFolderToPuttySessionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.AddFolder();
|
||||
|
||||
Assert.That(puttyRoot.Children, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicateRootConnectionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = root;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicateRootPuttyNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = puttyRoot;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CannotDuplicatePuttyConnectionNode()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
var puttyConnection = new PuttySessionInfo();
|
||||
puttyRoot.AddChild(puttyConnection);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.ExpandAll();
|
||||
|
||||
_connectionTree.SelectedObject = puttyConnection;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(puttyRoot.Children, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void DuplicatingWithNoNodeSelectedDoesNothing()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions);
|
||||
connectionTreeModel.AddRootNode(puttyRoot);
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
_connectionTree.SelectedObject = null;
|
||||
_connectionTree.DuplicateSelectedNode();
|
||||
|
||||
Assert.That(connectionTreeModel.RootNodes, Has.One.Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void ExpandingAllItemsUpdatesColumnWidthAppropriately()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
ContainerInfo parent = root;
|
||||
foreach (var i in Enumerable.Repeat("", 8))
|
||||
{
|
||||
var newContainer = new ContainerInfo {IsExpanded = false};
|
||||
parent.AddChild(newContainer);
|
||||
parent = newContainer;
|
||||
}
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
|
||||
var widthBefore = _connectionTree.Columns[0].Width;
|
||||
_connectionTree.ExpandAll();
|
||||
var widthAfter = _connectionTree.Columns[0].Width;
|
||||
|
||||
Assert.That(widthAfter, Is.GreaterThan(widthBefore));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void RenamingNodeWithNothingSelectedDoesNothing()
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
|
||||
_connectionTree.ConnectionTreeModel = connectionTreeModel;
|
||||
_connectionTree.SelectedObject = null;
|
||||
|
||||
Assert.DoesNotThrow(() => _connectionTree.RenameSelectedNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
49
mRemoteNGTests/UI/Controls/ExternalToolsToolStripTests.cs
Normal file
49
mRemoteNGTests/UI/Controls/ExternalToolsToolStripTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public class ExternalToolsToolStripTests
|
||||
{
|
||||
private ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_externalToolsToolStrip = new ExternalToolsToolStrip();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_externalToolsToolStrip.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SettingExternalToolsServiceToNullThrowsException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => _externalToolsToolStrip.ExternalToolsService = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddExternalToolsToToolBarCreatesControlsForAllExternalTools()
|
||||
{
|
||||
var externaltoolsService = new ExternalToolsService();
|
||||
externaltoolsService.ExternalTools.Add(BuildExternalTool());
|
||||
externaltoolsService.ExternalTools.Add(BuildExternalTool());
|
||||
|
||||
_externalToolsToolStrip.ExternalToolsService = externaltoolsService;
|
||||
_externalToolsToolStrip.AddExternalToolsToToolBar();
|
||||
Assert.That(_externalToolsToolStrip.Items.Count, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
private ExternalTool BuildExternalTool()
|
||||
{
|
||||
return new ExternalTool(Substitute.For<IConnectionInitiator>(), Substitute.For<IConnectionsService>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
public TextBoxExtensionsTestForm()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace mRemoteNGTests.UI.Controls
|
||||
{
|
||||
const string text = "Type Here";
|
||||
var textBox = new TextBoxTester(_textBoxExtensionsTestForm.textBox1.Name);
|
||||
Assert.That(textBox.Properties.SetCueBannerText(text), Is.True);
|
||||
var textWasSet = textBox.Properties.SetCueBannerText(text);
|
||||
Assert.That(textWasSet, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
16
mRemoteNGTests/UI/Forms/FrmMainTests.cs
Normal file
16
mRemoteNGTests/UI/Forms/FrmMainTests.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Threading;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Forms
|
||||
{
|
||||
public class FrmMainTests
|
||||
{
|
||||
[Test]
|
||||
[Apartment(ApartmentState.STA)]
|
||||
public void CanCreateFrmMain()
|
||||
{
|
||||
var frmMain = new FrmMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,24 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Update;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Forms
|
||||
{
|
||||
public class OptionsFormSetupAndTeardown
|
||||
public class OptionsFormSetupAndTeardown
|
||||
{
|
||||
protected frmOptions _optionsForm;
|
||||
|
||||
@@ -15,7 +30,16 @@ namespace mRemoteNGTests.UI.Forms
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_optionsForm = new frmOptions();
|
||||
var frmMain = new FrmMain();
|
||||
var connectionInitiator = Substitute.For<IConnectionInitiator>();
|
||||
var import = new Import(Substitute.For<IWin32Window>());
|
||||
var shutdown = new Shutdown(new SettingsSaver(new ExternalToolsService()), new ConnectionsService(PuttySessionsManager.Instance, import, frmMain), frmMain);
|
||||
var connectionsService = new ConnectionsService(PuttySessionsManager.Instance, import, frmMain);
|
||||
Func<NotificationAreaIcon> notificationIconBuilder = () => new NotificationAreaIcon(frmMain, connectionInitiator, shutdown, connectionsService);
|
||||
Func<SecureString> encryptionKeySelectionFunc = () => connectionsService.EncryptionKey;
|
||||
var databaseConnectorFactory = new DatabaseConnectorFactory(encryptionKeySelectionFunc);
|
||||
var appUpdater = new AppUpdater(encryptionKeySelectionFunc);
|
||||
_optionsForm = new frmOptions(connectionInitiator, type => {}, notificationIconBuilder, connectionsService, appUpdater, databaseConnectorFactory, frmMain);
|
||||
_optionsForm.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowGeneralTests
|
||||
{
|
||||
private ConfigWindow _configWindow;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_configWindow = new ConfigWindow(new DockContent(), Substitute.For<IConnectionsService>())
|
||||
{
|
||||
PropertiesVisible = true
|
||||
};
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(ConnectionInfoGeneralTestCases))]
|
||||
public void PropertyGridShowCorrectPropertiesForConnectionInfo(ConnectionInfo connectionInfo, IEnumerable<string> expectedVisibleProperties)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = connectionInfo;
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyGridShowCorrectPropertiesForRootConnectionInfo()
|
||||
{
|
||||
var expectedVisibleProperties = new[]
|
||||
{
|
||||
nameof(RootNodeInfo.Name),
|
||||
nameof(RootNodeInfo.Password),
|
||||
};
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyGridShowCorrectPropertiesForRootPuttyInfo()
|
||||
{
|
||||
var expectedVisibleProperties = new[]
|
||||
{
|
||||
nameof(RootNodeInfo.Name),
|
||||
};
|
||||
|
||||
_configWindow.SelectedTreeNode = new RootPuttySessionsNodeInfo();
|
||||
Assert.That(_configWindow.VisibleObjectProperties, Is.EquivalentTo(expectedVisibleProperties));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ConnectionInfoGeneralTestCases()
|
||||
{
|
||||
var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType<ProtocolType>();
|
||||
var testCases = new List<TestCaseData>();
|
||||
|
||||
foreach (var protocol in protocolTypes)
|
||||
{
|
||||
var expectedPropertyListConnection = BuildExpectedConnectionInfoPropertyList(protocol, false);
|
||||
var connectionInfo = ConstructConnectionInfo(protocol, false);
|
||||
var testCaseConnection = new TestCaseData(connectionInfo, expectedPropertyListConnection)
|
||||
.SetName(protocol + ", ConnectionInfo");
|
||||
testCases.Add(testCaseConnection);
|
||||
|
||||
var expectedPropertyListContainer = BuildExpectedConnectionInfoPropertyList(protocol, true);
|
||||
var containerInfo = ConstructConnectionInfo(protocol, true);
|
||||
var testCaseContainer = new TestCaseData(containerInfo, expectedPropertyListContainer)
|
||||
.SetName(protocol + ", ContainerInfo");
|
||||
testCases.Add(testCaseContainer);
|
||||
}
|
||||
|
||||
return testCases;
|
||||
}
|
||||
|
||||
internal static ConnectionInfo ConstructConnectionInfo(ProtocolType protocol, bool isContainer)
|
||||
{
|
||||
// build connection info. set certain connection properties so
|
||||
// that toggled properties are hidden in the property grid. We
|
||||
// will test those separately in the special protocol tests.
|
||||
var node = isContainer
|
||||
? new ContainerInfo()
|
||||
: new ConnectionInfo();
|
||||
|
||||
node.Protocol = protocol;
|
||||
node.Resolution = RdpProtocol.RDPResolutions.Res800x600;
|
||||
node.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
node.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.Yes;
|
||||
node.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
|
||||
node.VNCAuthMode = ProtocolVNC.AuthMode.AuthVNC;
|
||||
node.VNCProxyType = ProtocolVNC.ProxyType.ProxyNone;
|
||||
node.Inheritance.TurnOffInheritanceCompletely();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
internal static List<string> BuildExpectedConnectionInfoPropertyList(ProtocolType protocol, bool isContainer)
|
||||
{
|
||||
var expectedProperties = new List<string>
|
||||
{
|
||||
nameof(ConnectionInfo.Name),
|
||||
nameof(ConnectionInfo.Description),
|
||||
nameof(ConnectionInfo.Icon),
|
||||
nameof(ConnectionInfo.Panel),
|
||||
nameof(ConnectionInfo.Protocol),
|
||||
nameof(ConnectionInfo.PreExtApp),
|
||||
nameof(ConnectionInfo.PostExtApp),
|
||||
nameof(ConnectionInfo.MacAddress),
|
||||
nameof(ConnectionInfo.UserField),
|
||||
};
|
||||
|
||||
if (!isContainer)
|
||||
{
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Hostname),
|
||||
});
|
||||
}
|
||||
|
||||
switch (protocol)
|
||||
{
|
||||
case ProtocolType.RDP:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.UseConsoleSession),
|
||||
nameof(ConnectionInfo.RDPAuthenticationLevel),
|
||||
nameof(ConnectionInfo.RDPMinutesToIdleTimeout),
|
||||
nameof(ConnectionInfo.LoadBalanceInfo),
|
||||
nameof(ConnectionInfo.UseCredSsp),
|
||||
nameof(ConnectionInfo.RDGatewayUsageMethod),
|
||||
nameof(ConnectionInfo.Resolution),
|
||||
nameof(ConnectionInfo.Colors),
|
||||
nameof(ConnectionInfo.CacheBitmaps),
|
||||
nameof(ConnectionInfo.DisplayWallpaper),
|
||||
nameof(ConnectionInfo.DisplayThemes),
|
||||
nameof(ConnectionInfo.EnableFontSmoothing),
|
||||
nameof(ConnectionInfo.EnableDesktopComposition),
|
||||
nameof(ConnectionInfo.RedirectKeys),
|
||||
nameof(ConnectionInfo.RedirectDiskDrives),
|
||||
nameof(ConnectionInfo.RedirectPrinters),
|
||||
nameof(ConnectionInfo.RedirectClipboard),
|
||||
nameof(ConnectionInfo.RedirectPorts),
|
||||
nameof(ConnectionInfo.RedirectSmartCards),
|
||||
nameof(ConnectionInfo.RedirectSound),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.VNC:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.VNCSmartSizeMode),
|
||||
nameof(ConnectionInfo.VNCViewOnly),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.SSH1:
|
||||
case ProtocolType.SSH2:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.PuttySession)
|
||||
});
|
||||
break;
|
||||
case ProtocolType.Telnet:
|
||||
case ProtocolType.Rlogin:
|
||||
case ProtocolType.RAW:
|
||||
expectedProperties.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.PuttySession),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.HTTP:
|
||||
case ProtocolType.HTTPS:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.RenderingEngine),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.ICA:
|
||||
expectedProperties.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.ICAEncryptionStrength),
|
||||
nameof(ConnectionInfo.Resolution),
|
||||
nameof(ConnectionInfo.Colors),
|
||||
nameof(ConnectionInfo.CacheBitmaps),
|
||||
});
|
||||
break;
|
||||
case ProtocolType.IntApp:
|
||||
expectedProperties.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Password),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
nameof(ConnectionInfo.Port),
|
||||
nameof(ConnectionInfo.ExtApp),
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(protocol), protocol, null);
|
||||
}
|
||||
|
||||
return expectedProperties;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowRdpSpecialTests : ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected override ProtocolType Protocol => ProtocolType.RDP;
|
||||
|
||||
[Test]
|
||||
public void PropertyShownWhenActive_RdpMinutesToIdleTimeout()
|
||||
{
|
||||
ConnectionInfo.RDPMinutesToIdleTimeout = 1;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.RDPAlertIdleTimeout));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDGatewayUsageMethod.Always)]
|
||||
[TestCase(RdpProtocol.RDGatewayUsageMethod.Detect)]
|
||||
public void RdGatewayPropertiesShown_WhenRdGatewayUsageMethodIsNotNever(RdpProtocol.RDGatewayUsageMethod gatewayUsageMethod)
|
||||
{
|
||||
ConnectionInfo.RDGatewayUsageMethod = gatewayUsageMethod;
|
||||
ConnectionInfo.RDGatewayUseConnectionCredentials = RdpProtocol.RDGatewayUseConnectionCredentials.Yes;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayHostname),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUseConnectionCredentials)
|
||||
});
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDGatewayUseConnectionCredentials.No)]
|
||||
[TestCase(RdpProtocol.RDGatewayUseConnectionCredentials.SmartCard)]
|
||||
public void RdGatewayPropertiesShown_WhenRDGatewayUseConnectionCredentialsIsNotYes(RdpProtocol.RDGatewayUseConnectionCredentials useConnectionCredentials)
|
||||
{
|
||||
ConnectionInfo.RDGatewayUsageMethod = RdpProtocol.RDGatewayUsageMethod.Always;
|
||||
ConnectionInfo.RDGatewayUseConnectionCredentials = useConnectionCredentials;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayHostname),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUsername),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayPassword),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayDomain),
|
||||
nameof(mRemoteNG.Connection.ConnectionInfo.RDGatewayUseConnectionCredentials)
|
||||
});
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SoundQualityPropertyShown_WhenRdpSoundsSetToBringToThisComputer()
|
||||
{
|
||||
ConnectionInfo.RedirectSound = RdpProtocol.RDPSounds.BringToThisComputer;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.SoundQuality));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
|
||||
[TestCase(RdpProtocol.RDPResolutions.FitToWindow)]
|
||||
[TestCase(RdpProtocol.RDPResolutions.Fullscreen)]
|
||||
public void AutomaticResizePropertyShown_WhenResolutionIsDynamic(RdpProtocol.RDPResolutions resolution)
|
||||
{
|
||||
ConnectionInfo.Resolution = resolution;
|
||||
ExpectedPropertyList.Add(nameof(mRemoteNG.Connection.ConnectionInfo.AutomaticResize));
|
||||
|
||||
RunVerification();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public abstract class ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected abstract ProtocolType Protocol { get; }
|
||||
protected bool TestAgainstContainerInfo { get; set; } = false;
|
||||
protected ConfigWindow ConfigWindow;
|
||||
protected ConnectionInfo ConnectionInfo;
|
||||
protected List<string> ExpectedPropertyList;
|
||||
|
||||
[SetUp]
|
||||
public virtual void Setup()
|
||||
{
|
||||
ConnectionInfo = ConfigWindowGeneralTests.ConstructConnectionInfo(Protocol, TestAgainstContainerInfo);
|
||||
ExpectedPropertyList = ConfigWindowGeneralTests.BuildExpectedConnectionInfoPropertyList(Protocol, TestAgainstContainerInfo);
|
||||
|
||||
ConfigWindow = new ConfigWindow(new DockContent(), Substitute.For<IConnectionsService>())
|
||||
{
|
||||
PropertiesVisible = true,
|
||||
};
|
||||
}
|
||||
|
||||
public void RunVerification()
|
||||
{
|
||||
ConfigWindow.SelectedTreeNode = ConnectionInfo;
|
||||
Assert.That(
|
||||
ConfigWindow.VisibleObjectProperties,
|
||||
Is.EquivalentTo(ExpectedPropertyList));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
{
|
||||
public class ConfigWindowVncSpecialTests : ConfigWindowSpecialTestsBase
|
||||
{
|
||||
protected override ProtocolType Protocol => ProtocolType.VNC;
|
||||
|
||||
[Test]
|
||||
public void UserDomainPropertiesShown_WhenAuthModeIsWindows()
|
||||
{
|
||||
ConnectionInfo.VNCAuthMode = ProtocolVNC.AuthMode.AuthWin;
|
||||
ExpectedPropertyList.AddRange(new []
|
||||
{
|
||||
nameof(ConnectionInfo.Username),
|
||||
nameof(ConnectionInfo.Domain),
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxyHTTP)]
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxySocks5)]
|
||||
[TestCase(ProtocolVNC.ProxyType.ProxyUltra)]
|
||||
public void ProxyPropertiesShown_WhenProxyModeIsNotNone(ProtocolVNC.ProxyType proxyType)
|
||||
{
|
||||
ConnectionInfo.VNCProxyType = proxyType;
|
||||
ExpectedPropertyList.AddRange(new[]
|
||||
{
|
||||
nameof(ConnectionInfo.VNCProxyIP),
|
||||
nameof(ConnectionInfo.VNCProxyPort),
|
||||
nameof(ConnectionInfo.VNCProxyUsername),
|
||||
nameof(ConnectionInfo.VNCProxyPassword),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,38 @@
|
||||
using System.Threading;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Credential.Repositories;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.UI.Window
|
||||
{
|
||||
public class ConnectionTreeWindowTests
|
||||
public class ConnectionTreeWindowTests
|
||||
{
|
||||
private ConnectionTreeWindow _connectionTreeWindow;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent());
|
||||
var connectionInitiator = Substitute.For<IConnectionInitiator>();
|
||||
var connectionTree = new ConnectionTree();
|
||||
var sshTransferWindow = new SSHTransferWindow();
|
||||
var externalToolsService = new ExternalToolsService();
|
||||
var import = new Import(Substitute.For<IWin32Window>());
|
||||
var connectionsService = new ConnectionsService(PuttySessionsManager.Instance, import, connectionTree);
|
||||
var export = new Export(new CredentialRepositoryList(), connectionsService, connectionTree);
|
||||
var connectionContextMenu = new ConnectionContextMenu(connectionTree, connectionInitiator, sshTransferWindow, export, externalToolsService, import, connectionsService);
|
||||
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), connectionInitiator, connectionsService) {ConnectionTreeContextMenu = connectionContextMenu};
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="App\UpdaterTests.cs" />
|
||||
<Compile Include="AssemblyTestSetup.cs" />
|
||||
<Compile Include="BinaryFileTests.cs" />
|
||||
<Compile Include="Config\Connections\Multiuser\ConnectionsUpdateAvailableEventArgsTests.cs" />
|
||||
<Compile Include="Config\DataProviders\FileBackupCreatorTests.cs" />
|
||||
@@ -170,12 +171,15 @@
|
||||
<Compile Include="Security\PasswordCreation\PasswordLengthConstraintTests.cs" />
|
||||
<Compile Include="Security\RandomGeneratorTests.cs" />
|
||||
<Compile Include="Security\SecureStringExtensionsTests.cs" />
|
||||
<Compile Include="TestHelpers\ConnectionInfoHelpers.cs" />
|
||||
<Compile Include="TestHelpers\ConnectionTreeModelBuilder.cs" />
|
||||
<Compile Include="Security\XmlCryptoProviderBuilderTests.cs" />
|
||||
<Compile Include="TestHelpers\FileTestHelpers.cs" />
|
||||
<Compile Include="TestHelpers\SerializableConnectionInfoAllPropertiesOfType.cs" />
|
||||
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
|
||||
<Compile Include="Tools\FullyObservableCollectionTests.cs" />
|
||||
<Compile Include="Tools\OptionalTests.cs" />
|
||||
<Compile Include="Tools\Registry\WindowsRegistryTests.cs" />
|
||||
<Compile Include="Tree\ClickHandlers\TreeNodeCompositeClickHandlerTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeDragAndDropHandlerTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeModelTests.cs" />
|
||||
@@ -205,6 +209,8 @@
|
||||
<Compile Include="Tree\RootNodeInfoTests.cs" />
|
||||
<Compile Include="Tree\ClickHandlers\SwitchToConnectionClickHandlerTests.cs" />
|
||||
<Compile Include="Tree\SelectedConnectionDeletionConfirmerTests.cs" />
|
||||
<Compile Include="UI\Controls\ExternalToolsToolStripTests.cs" />
|
||||
<Compile Include="UI\Controls\ConnectionTreeTests.cs" />
|
||||
<Compile Include="UI\Controls\PageSequenceTests.cs" />
|
||||
<Compile Include="UI\Controls\SecureTextBoxTestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -226,9 +232,14 @@
|
||||
<DependentUpon>TextBoxExtensionsTestForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\TextBoxExtensionsTests.cs" />
|
||||
<Compile Include="UI\Forms\FrmMainTests.cs" />
|
||||
<Compile Include="UI\Forms\OptionsFormSetupAndTeardown.cs" />
|
||||
<Compile Include="UI\Forms\PasswordFormTests.cs" />
|
||||
<Compile Include="UI\WindowListTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowGeneralTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowRdpSpecialTests.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowSpecialTestsBase.cs" />
|
||||
<Compile Include="UI\Window\ConfigWindowTests\ConfigWindowVncSpecialTests.cs" />
|
||||
<Compile Include="UI\Window\ConnectionTreeWindowTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -33,16 +33,19 @@ Global
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|Any CPU.ActiveCfg = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|Any CPU.Build.0 = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug Portable|x86.Build.0 = Debug Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Debug|x86.Build.0 = Debug|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Installer|x86.Build.0 = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|Any CPU.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|x86.ActiveCfg = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release Portable|x86.Build.0 = Release Portable|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
@@ -50,24 +53,26 @@ Global
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|x86.ActiveCfg = Release|x86
|
||||
{4934A491-40BC-4E5B-9166-EA1169A220F6}.Release|x86.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|Any CPU.ActiveCfg = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|Any CPU.Build.0 = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug Portable|x86.Build.0 = Debug Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Debug|x86.Build.0 = Debug|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Installer|x86.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|Any CPU.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|x86.ActiveCfg = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release Portable|x86.Build.0 = Release Portable|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|Any CPU.Build.0 = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|x86.ActiveCfg = Release|x86
|
||||
{1453B37F-8621-499E-B0B2-6091F76DC0BB}.Release|x86.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|Any CPU.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug Portable|x86.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Debug|x86.ActiveCfg = Debug|x86
|
||||
@@ -77,7 +82,6 @@ Global
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Installer|x86.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|Any CPU.Build.0 = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release Portable|x86.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{5423D985-CB48-4344-B47F-E8C6D60C8B04}.Release|Any CPU.Build.0 = Release|x86
|
||||
@@ -86,8 +90,8 @@ Global
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug Portable|x86.ActiveCfg = Debug Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.ActiveCfg = Release Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.Build.0 = Release Portable|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.ActiveCfg = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|Any CPU.Build.0 = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|x86.ActiveCfg = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Installer|x86.Build.0 = Release|x86
|
||||
{F0168B9F-6815-40DF-BA53-46CEE7683B68}.Release Portable|Any CPU.ActiveCfg = Release Portable|x86
|
||||
|
||||
@@ -6,25 +6,35 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class CompatibilityChecker
|
||||
public class CompatibilityChecker
|
||||
{
|
||||
public static void CheckCompatibility(MessageCollector messageCollector)
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public CompatibilityChecker(MessageCollector messageCollector, IWin32Window dialogWindowParent)
|
||||
{
|
||||
CheckFipsPolicy(messageCollector);
|
||||
CheckLenovoAutoScrollUtility(messageCollector);
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
}
|
||||
|
||||
private static void CheckFipsPolicy(MessageCollector messageCollector)
|
||||
public void CheckCompatibility()
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true);
|
||||
CheckFipsPolicy();
|
||||
CheckLenovoAutoScrollUtility();
|
||||
}
|
||||
|
||||
private void CheckFipsPolicy()
|
||||
{
|
||||
_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);
|
||||
messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true);
|
||||
MessageBox.Show(FrmMain.Default, errorText);
|
||||
_messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true);
|
||||
MessageBox.Show(_dialogWindowParent, errorText);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
@@ -46,9 +56,9 @@ namespace mRemoteNG.App
|
||||
return (int)fipsPolicy != 0;
|
||||
}
|
||||
|
||||
private static void CheckLenovoAutoScrollUtility(MessageCollector messageCollector)
|
||||
private void CheckLenovoAutoScrollUtility()
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "Checking Lenovo AutoScroll Utility...", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, "Checking Lenovo AutoScroll Utility...", true);
|
||||
|
||||
if (!Settings.Default.CompatibilityWarnLenovoAutoScrollUtility)
|
||||
return;
|
||||
@@ -60,7 +70,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
messageCollector.AddExceptionMessage("Error in CheckLenovoAutoScrollUtility", ex);
|
||||
_messageCollector.AddExceptionMessage("Error in CheckLenovoAutoScrollUtility", ex);
|
||||
}
|
||||
|
||||
if (proccesses.Length <= 0) return;
|
||||
|
||||
@@ -8,8 +8,10 @@ using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Forms;
|
||||
@@ -17,9 +19,20 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Export
|
||||
public class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public Export(ICredentialRepositoryList credentialRepositoryList, IConnectionsService connectionsService, IWin32Window dialogWindowParent)
|
||||
{
|
||||
_credentialRepositoryList = credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
}
|
||||
|
||||
public void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -36,7 +49,7 @@ namespace mRemoteNG.App
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
if (exportForm.ShowDialog(_dialogWindowParent) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
@@ -69,7 +82,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
|
||||
private void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -79,14 +92,14 @@ namespace mRemoteNG.App
|
||||
case SaveFormat.mRXML:
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString.ConvertToSecureString() ?? new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
case SaveFormat.mRCSV:
|
||||
serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
|
||||
serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, _credentialRepositoryList);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
@@ -101,7 +114,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
_connectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,26 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Import;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Import
|
||||
public class Import
|
||||
{
|
||||
public static void ImportFromFile(ContainerInfo importDestinationContainer)
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public Import(IWin32Window dialogWindowParent)
|
||||
{
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
}
|
||||
|
||||
// TODO - this is only a property to break up a circular dependency. move this to ctor when able
|
||||
public IConnectionsService ConnectionsService { get; set; }
|
||||
|
||||
public void ImportFromFile(ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -50,7 +61,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
ConnectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -59,12 +70,12 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
public void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveDirectoryImporter.Import(ldapPath, importDestinationContainer, importSubOu);
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
ConnectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -72,13 +83,13 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
|
||||
public void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var importer = new PortScanImporter(protocol);
|
||||
importer.Import(hosts, importDestinationContainer);
|
||||
Runtime.ConnectionsService.SaveConnectionsAsync();
|
||||
ConnectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -86,14 +97,14 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static IConnectionImporter<string> BuildConnectionImporterFromFileExtension(string fileName)
|
||||
private IConnectionImporter<string> BuildConnectionImporterFromFileExtension(string fileName)
|
||||
{
|
||||
// TODO: Use the file contents to determine the file type instead of trusting the extension
|
||||
var extension = Path.GetExtension(fileName) ?? "";
|
||||
switch (extension.ToLowerInvariant())
|
||||
{
|
||||
case ".xml":
|
||||
return new MRemoteNGXmlImporter();
|
||||
return new MRemoteNGXmlImporter(ConnectionsService, _dialogWindowParent);
|
||||
case ".csv":
|
||||
return new MRemoteNGCsvImporter();
|
||||
case ".rdp":
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
using System.IO;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using System.IO;
|
||||
|
||||
namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class CredsAndConsSetup
|
||||
{
|
||||
public void LoadCredsAndCons()
|
||||
public class CredsAndConsSetup
|
||||
{
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public CredsAndConsSetup(IConnectionsService connectionsService)
|
||||
{
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
public void LoadCredsAndCons()
|
||||
{
|
||||
new SaveConnectionsOnEdit(Runtime.ConnectionsService);
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation && !File.Exists(_connectionsService.GetStartupConnectionFileName()))
|
||||
_connectionsService.NewConnectionsFile(_connectionsService.GetStartupConnectionFileName());
|
||||
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation && !File.Exists(Runtime.ConnectionsService.GetStartupConnectionFileName()))
|
||||
Runtime.ConnectionsService.NewConnectionsFile(Runtime.ConnectionsService.GetStartupConnectionFileName());
|
||||
|
||||
Runtime.LoadConnections();
|
||||
_connectionsService.LoadConnections();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@ using System.Linq;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Messages.MessageWriters;
|
||||
using mRemoteNG.Messages.WriterDecorators;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
|
||||
namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class MessageCollectorSetup
|
||||
public class MessageCollectorSetup
|
||||
{
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector, IList<IMessageWriter> messageWriterList)
|
||||
{
|
||||
@@ -19,13 +22,13 @@ namespace mRemoteNG.App.Initialization
|
||||
};
|
||||
}
|
||||
|
||||
public static void BuildMessageWritersFromSettings(IList<IMessageWriter> messageWriterList)
|
||||
public static void BuildMessageWritersFromSettings(IList<IMessageWriter> messageWriterList, FrmMain frmMain, ErrorAndInfoWindow errorAndInfoWindow)
|
||||
{
|
||||
#if DEBUG
|
||||
messageWriterList.Add(BuildDebugConsoleWriter());
|
||||
#endif
|
||||
messageWriterList.Add(BuildTextLogMessageWriter());
|
||||
messageWriterList.Add(BuildNotificationPanelMessageWriter());
|
||||
messageWriterList.Add(BuildNotificationPanelMessageWriter(frmMain, errorAndInfoWindow));
|
||||
messageWriterList.Add(BuildPopupMessageWriter());
|
||||
}
|
||||
|
||||
@@ -42,16 +45,17 @@ namespace mRemoteNG.App.Initialization
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildNotificationPanelMessageWriter()
|
||||
private static IMessageWriter BuildNotificationPanelMessageWriter(FrmMain frmMain, ErrorAndInfoWindow errorAndInfoWindow)
|
||||
{
|
||||
|
||||
return new OnlyLogMessageFilter(
|
||||
errorAndInfoWindow.ThrowIfNull(nameof(errorAndInfoWindow));
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
frmMain,
|
||||
errorAndInfoWindow,
|
||||
new NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new NotificationPanelMessageWriter(Windows.ErrorsForm)
|
||||
new NotificationPanelMessageWriter(errorAndInfoWindow)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace mRemoteNG.App
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(FrmMain.Default);
|
||||
var frmMain = new FrmMain();
|
||||
Application.Run(frmMain);
|
||||
}
|
||||
|
||||
public static void CloseSingletonInstanceMutex()
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.Connections.Multiuser;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Credential.Repositories;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Runtime
|
||||
public class Runtime
|
||||
{
|
||||
public static bool IsPortableEdition
|
||||
{
|
||||
@@ -34,171 +19,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static WindowList WindowList { get; set; }
|
||||
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 ICredentialRepositoryList CredentialProviderCatalog { get; } = new CredentialRepositoryList();
|
||||
public static ConnectionsService ConnectionsService { get; } = new ConnectionsService(PuttySessionsManager.Instance);
|
||||
|
||||
#region Connections Loading/Saving
|
||||
public static void LoadConnectionsAsync()
|
||||
{
|
||||
_withDialog = false;
|
||||
|
||||
var t = new Thread(LoadConnectionsBGd);
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private static bool _withDialog;
|
||||
private static void LoadConnectionsBGd()
|
||||
{
|
||||
LoadConnections(_withDialog);
|
||||
}
|
||||
|
||||
public static void LoadConnections(bool withDialog = false)
|
||||
{
|
||||
var connectionFileName = "";
|
||||
|
||||
try
|
||||
{
|
||||
// disable sql update checking while we are loading updates
|
||||
ConnectionsService.RemoteConnectionsSyncronizer?.Disable();
|
||||
|
||||
if (!Settings.Default.UseSQLServer)
|
||||
{
|
||||
if (withDialog)
|
||||
{
|
||||
var loadDialog = DialogFactory.BuildLoadConnectionsDialog();
|
||||
if (loadDialog.ShowDialog() != DialogResult.OK) return;
|
||||
connectionFileName = loadDialog.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionFileName = ConnectionsService.GetStartupConnectionFileName();
|
||||
}
|
||||
|
||||
var backupFileCreator = new FileBackupCreator();
|
||||
backupFileCreator.CreateBackupFile(connectionFileName);
|
||||
|
||||
var backupPruner = new FileBackupPruner();
|
||||
backupPruner.PruneBackupFiles(connectionFileName);
|
||||
}
|
||||
|
||||
ConnectionsService.LoadConnections(Settings.Default.UseSQLServer, false, connectionFileName);
|
||||
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
ConnectionsService.LastSqlUpdate = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectionFileName == ConnectionsService.GetDefaultStartupConnectionFileName())
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = connectionFileName;
|
||||
}
|
||||
}
|
||||
|
||||
// re-enable sql update checking after updates are loaded
|
||||
ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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);
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
LoadConnections(withDialog);
|
||||
return;
|
||||
case 1:
|
||||
Settings.Default.UseSQLServer = false;
|
||||
LoadConnections(true);
|
||||
return;
|
||||
default:
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ex is FileNotFoundException && !withDialog)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);
|
||||
|
||||
string[] commandButtons =
|
||||
{
|
||||
Language.ConfigurationCreateNew,
|
||||
Language.ConfigurationCustomPath,
|
||||
Language.ConfigurationImportFile,
|
||||
Language.strMenuExit
|
||||
};
|
||||
|
||||
var answered = false;
|
||||
while (!answered)
|
||||
{
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
ConnectionsService.NewConnectionsFile(connectionFileName);
|
||||
answered = true;
|
||||
break;
|
||||
case 1:
|
||||
LoadConnections(true);
|
||||
answered = true;
|
||||
break;
|
||||
case 2:
|
||||
ConnectionsService.NewConnectionsFile(connectionFileName);
|
||||
Import.ImportFromFile(ConnectionsService.ConnectionTreeModel.RootNodes[0]);
|
||||
answered = true;
|
||||
break;
|
||||
case 3:
|
||||
Application.Exit();
|
||||
answered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
|
||||
if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
|
||||
{
|
||||
LoadConnections(withDialog);
|
||||
}
|
||||
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);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,38 @@
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Screens
|
||||
public class Screens
|
||||
{
|
||||
public static void SendFormToScreen(Screen screen)
|
||||
private readonly FrmMain _frmMain;
|
||||
|
||||
public Screens(FrmMain frmMain)
|
||||
{
|
||||
_frmMain = frmMain.ThrowIfNull(nameof(frmMain));
|
||||
}
|
||||
|
||||
public void SendFormToScreen(Screen screen)
|
||||
{
|
||||
var frmMain = FrmMain.Default;
|
||||
var wasMax = false;
|
||||
|
||||
if (frmMain.WindowState == FormWindowState.Maximized)
|
||||
if (_frmMain.WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
wasMax = true;
|
||||
frmMain.WindowState = FormWindowState.Normal;
|
||||
_frmMain.WindowState = FormWindowState.Normal;
|
||||
}
|
||||
|
||||
frmMain.Location = screen.Bounds.Location;
|
||||
_frmMain.Location = screen.Bounds.Location;
|
||||
|
||||
if (wasMax)
|
||||
{
|
||||
frmMain.WindowState = FormWindowState.Maximized;
|
||||
_frmMain.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendPanelToScreen(DockContent panel, Screen screen)
|
||||
public void SendPanelToScreen(DockContent panel, Screen screen)
|
||||
{
|
||||
panel.DockState = DockState.Float;
|
||||
if (panel.ParentForm == null) return;
|
||||
|
||||
@@ -3,29 +3,41 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Shutdown
|
||||
public class Shutdown
|
||||
{
|
||||
private readonly SettingsSaver _settingsSaver;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly FrmMain _frmMain;
|
||||
private static string _updateFilePath;
|
||||
|
||||
public Shutdown(SettingsSaver settingsSaver, IConnectionsService connectionsService, FrmMain frmMain)
|
||||
{
|
||||
_settingsSaver = settingsSaver.ThrowIfNull(nameof(settingsSaver));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_frmMain = frmMain.ThrowIfNull(nameof(frmMain));
|
||||
}
|
||||
|
||||
private static bool UpdatePending
|
||||
{
|
||||
get { return !string.IsNullOrEmpty(_updateFilePath); }
|
||||
}
|
||||
|
||||
public static void Quit(string updateFilePath = null)
|
||||
public void Quit(string updateFilePath = null)
|
||||
{
|
||||
_updateFilePath = updateFilePath;
|
||||
FrmMain.Default.Close();
|
||||
_frmMain.Close();
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
public void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,34 +53,34 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static void StopPuttySessionWatcher()
|
||||
private void StopPuttySessionWatcher()
|
||||
{
|
||||
PuttySessionsManager.Instance.StopWatcher();
|
||||
}
|
||||
|
||||
private static void DisposeNotificationAreaIcon()
|
||||
private void DisposeNotificationAreaIcon()
|
||||
{
|
||||
if (Runtime.NotificationAreaIcon != null && Runtime.NotificationAreaIcon.Disposed == false)
|
||||
Runtime.NotificationAreaIcon.Dispose();
|
||||
}
|
||||
|
||||
private static void SaveConnections()
|
||||
private void SaveConnections()
|
||||
{
|
||||
if (Settings.Default.SaveConsOnExit)
|
||||
Runtime.ConnectionsService.SaveConnections();
|
||||
_connectionsService.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
private void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
_settingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
private void UnregisterBrowsers()
|
||||
{
|
||||
IeBrowserEmulation.Unregister();
|
||||
}
|
||||
|
||||
public static void StartUpdate()
|
||||
public void StartUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -80,7 +92,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static void RunUpdateFile()
|
||||
private void RunUpdateFile()
|
||||
{
|
||||
if (UpdatePending)
|
||||
Process.Start(_updateFilePath);
|
||||
|
||||
@@ -7,6 +7,7 @@ using mRemoteNG.App.Initialization;
|
||||
using mRemoteNG.App.Update;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Config.Connections.Multiuser;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
@@ -17,30 +18,34 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public class Startup
|
||||
public class Startup
|
||||
{
|
||||
private AppUpdater _appUpdate;
|
||||
private readonly AppUpdater _appUpdate;
|
||||
private readonly ConnectionIconLoader _connectionIconLoader;
|
||||
private readonly FrmMain _frmMain = FrmMain.Default;
|
||||
private readonly FrmMain _frmMain;
|
||||
private readonly Windows _windows;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly DatabaseConnectorFactory _databaseConnectorFactory;
|
||||
private readonly CompatibilityChecker _compatibilityChecker;
|
||||
|
||||
public static Startup Instance { get; } = new Startup();
|
||||
|
||||
private Startup()
|
||||
public Startup(FrmMain frmMain, Windows windows, IConnectionsService connectionsService,
|
||||
AppUpdater appUpdate, DatabaseConnectorFactory databaseConnectorFactory, CompatibilityChecker compatibilityChecker)
|
||||
{
|
||||
_appUpdate = new AppUpdater();
|
||||
_frmMain = frmMain.ThrowIfNull(nameof(frmMain));
|
||||
_windows = windows.ThrowIfNull(nameof(windows));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_appUpdate = appUpdate.ThrowIfNull(nameof(appUpdate));
|
||||
_databaseConnectorFactory = databaseConnectorFactory.ThrowIfNull(nameof(databaseConnectorFactory));
|
||||
_compatibilityChecker = compatibilityChecker.ThrowIfNull(nameof(compatibilityChecker));
|
||||
_connectionIconLoader = new ConnectionIconLoader(GeneralAppInfo.HomePath + "\\Icons\\");
|
||||
}
|
||||
|
||||
static Startup()
|
||||
{
|
||||
}
|
||||
|
||||
public void InitializeProgram(MessageCollector messageCollector)
|
||||
{
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
var startupLogger = new StartupDataLogger(messageCollector);
|
||||
startupLogger.LogStartupData();
|
||||
CompatibilityChecker.CheckCompatibility(messageCollector);
|
||||
_compatibilityChecker.CheckCompatibility();
|
||||
ParseCommandLineArgs(messageCollector);
|
||||
IeBrowserEmulation.Register();
|
||||
_connectionIconLoader.GetConnectionIcons();
|
||||
@@ -59,17 +64,14 @@ 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.Enable();
|
||||
var sqlConnectionsUpdateChecker = new SqlConnectionsUpdateChecker(_connectionsService, _databaseConnectorFactory);
|
||||
_connectionsService.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(sqlConnectionsUpdateChecker, _connectionsService);
|
||||
_connectionsService.RemoteConnectionsSyncronizer.Enable();
|
||||
}
|
||||
|
||||
public void CheckForUpdate()
|
||||
{
|
||||
if (_appUpdate == null)
|
||||
{
|
||||
_appUpdate = new AppUpdater();
|
||||
}
|
||||
else if (_appUpdate.IsGetUpdateInfoRunning)
|
||||
if (_appUpdate.IsGetUpdateInfoRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +109,7 @@ namespace mRemoteNG.App
|
||||
|
||||
if (_appUpdate.IsUpdateAvailable())
|
||||
{
|
||||
Windows.Show(WindowType.Update);
|
||||
_windows.Show(WindowType.Update);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Security;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using System.Security.Cryptography;
|
||||
@@ -22,6 +23,7 @@ namespace mRemoteNG.App.Update
|
||||
private WebProxy _webProxy;
|
||||
private Thread _getUpdateInfoThread;
|
||||
private Thread _getChangeLogThread;
|
||||
private readonly Func<SecureString> _encryptionKeyRetrievalFunc;
|
||||
|
||||
#region Public Properties
|
||||
|
||||
@@ -48,8 +50,9 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public AppUpdater()
|
||||
public AppUpdater(Func<SecureString> encryptionKeyRetrievalFunc)
|
||||
{
|
||||
_encryptionKeyRetrievalFunc = encryptionKeyRetrievalFunc;
|
||||
SetProxySettings();
|
||||
}
|
||||
|
||||
@@ -61,7 +64,7 @@ namespace mRemoteNG.App.Update
|
||||
var useAuthentication = Settings.Default.UpdateProxyUseAuthentication;
|
||||
var username = Settings.Default.UpdateProxyAuthUser;
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var password = cryptographyProvider.Decrypt(Settings.Default.UpdateProxyAuthPass, Runtime.EncryptionKey);
|
||||
var password = cryptographyProvider.Decrypt(Settings.Default.UpdateProxyAuthPass, _encryptionKeyRetrievalFunc());
|
||||
|
||||
SetProxySettings(shouldWeUseProxy, proxyAddress, port, useAuthentication, username, password);
|
||||
}
|
||||
|
||||
@@ -1,88 +1,134 @@
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using System;
|
||||
using System;
|
||||
using mRemoteNG.App.Update;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Windows
|
||||
public class Windows
|
||||
{
|
||||
private static AboutWindow _aboutForm;
|
||||
private static ActiveDirectoryImportWindow _adimportForm;
|
||||
private static HelpWindow _helpForm;
|
||||
private static ExternalToolsWindow _externalappsForm;
|
||||
private static PortScanWindow _portscanForm;
|
||||
private static UltraVNCWindow _ultravncscForm;
|
||||
private static ComponentsCheckWindow _componentscheckForm;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private AboutWindow _aboutForm;
|
||||
private ActiveDirectoryImportWindow _adimportForm;
|
||||
private HelpWindow _helpForm;
|
||||
private ExternalToolsWindow _externalappsForm;
|
||||
private PortScanWindow _portscanForm;
|
||||
private UltraVNCWindow _ultravncscForm;
|
||||
private ComponentsCheckWindow _componentscheckForm;
|
||||
private UpdateWindow _updateForm;
|
||||
private readonly Func<UpdateWindow> _updateWindowBuilder;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
private readonly Func<ExternalToolsWindow> _externalToolsWindowBuilder;
|
||||
private readonly Func<PortScanWindow> _portScanWindowBuilder;
|
||||
private readonly Func<ActiveDirectoryImportWindow> _activeDirectoryImportWindowBuilder;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly AppUpdater _appUpdater;
|
||||
private readonly DatabaseConnectorFactory _databaseConnectorFactory;
|
||||
private readonly FrmMain _frmMain;
|
||||
|
||||
internal static ConnectionTreeWindow TreeForm { get; set; } = new ConnectionTreeWindow();
|
||||
internal static ConfigWindow ConfigForm { get; set; } = new ConfigWindow();
|
||||
internal static ErrorAndInfoWindow ErrorsForm { get; set; } = new ErrorAndInfoWindow();
|
||||
internal static ScreenshotManagerWindow ScreenshotForm { get; set; } = new ScreenshotManagerWindow();
|
||||
private static UpdateWindow UpdateForm { get; set; } = new UpdateWindow();
|
||||
internal static SSHTransferWindow SshtransferForm { get; private set; } = new SSHTransferWindow();
|
||||
internal ConnectionTreeWindow TreeForm { get; }
|
||||
internal ConfigWindow ConfigForm { get; }
|
||||
internal ErrorAndInfoWindow ErrorsForm { get; }
|
||||
internal ScreenshotManagerWindow ScreenshotForm { get; }
|
||||
internal SSHTransferWindow SshtransferForm { get; private set; }
|
||||
|
||||
public Windows(
|
||||
IConnectionInitiator connectionInitiator,
|
||||
ConnectionTreeWindow treeForm,
|
||||
ConfigWindow configForm,
|
||||
ErrorAndInfoWindow errorAndInfoWindow,
|
||||
ScreenshotManagerWindow screenshotForm,
|
||||
SSHTransferWindow sshtransferForm,
|
||||
Func<UpdateWindow> updateWindowBuilder,
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder,
|
||||
Func<ExternalToolsWindow> externalToolsWindowBuilder,
|
||||
IConnectionsService connectionsService,
|
||||
Func<PortScanWindow> portScanWindowBuilder,
|
||||
Func<ActiveDirectoryImportWindow> activeDirectoryImportWindowBuilder,
|
||||
AppUpdater appUpdater,
|
||||
DatabaseConnectorFactory databaseConnectorFactory,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
TreeForm = treeForm.ThrowIfNull(nameof(treeForm));
|
||||
ConfigForm = configForm.ThrowIfNull(nameof(configForm));
|
||||
ErrorsForm = errorAndInfoWindow.ThrowIfNull(nameof(errorAndInfoWindow));
|
||||
ScreenshotForm = screenshotForm.ThrowIfNull(nameof(screenshotForm));
|
||||
SshtransferForm = sshtransferForm.ThrowIfNull(nameof(sshtransferForm));
|
||||
_updateWindowBuilder = updateWindowBuilder;
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder;
|
||||
_externalToolsWindowBuilder = externalToolsWindowBuilder;
|
||||
_portScanWindowBuilder = portScanWindowBuilder;
|
||||
_activeDirectoryImportWindowBuilder = activeDirectoryImportWindowBuilder;
|
||||
_frmMain = frmMain;
|
||||
_databaseConnectorFactory = databaseConnectorFactory.ThrowIfNull(nameof(databaseConnectorFactory));
|
||||
_appUpdater = appUpdater.ThrowIfNull(nameof(appUpdater));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
|
||||
public static void Show(WindowType windowType)
|
||||
public void Show(WindowType windowType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dockPanel = FrmMain.Default.pnlDock;
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (windowType)
|
||||
{
|
||||
case WindowType.About:
|
||||
if (_aboutForm == null || _aboutForm.IsDisposed)
|
||||
_aboutForm = new AboutWindow();
|
||||
_aboutForm.Show(dockPanel);
|
||||
_aboutForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.ActiveDirectoryImport:
|
||||
if (_adimportForm == null || _adimportForm.IsDisposed)
|
||||
_adimportForm = new ActiveDirectoryImportWindow();
|
||||
_adimportForm.Show(dockPanel);
|
||||
_adimportForm = _activeDirectoryImportWindowBuilder();
|
||||
_adimportForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.Options:
|
||||
using (var optionsForm = new frmOptions())
|
||||
using (var optionsForm = new frmOptions(_connectionInitiator, Show, _notificationAreaIconBuilder, _connectionsService, _appUpdater, _databaseConnectorFactory, _frmMain))
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
optionsForm.ShowDialog(_frmMain);
|
||||
}
|
||||
break;
|
||||
case WindowType.SSHTransfer:
|
||||
if (SshtransferForm == null || SshtransferForm.IsDisposed)
|
||||
SshtransferForm = new SSHTransferWindow();
|
||||
SshtransferForm.Show(dockPanel);
|
||||
SshtransferForm = new SSHTransferWindow(_frmMain);
|
||||
SshtransferForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.Update:
|
||||
if (UpdateForm == null || UpdateForm.IsDisposed)
|
||||
UpdateForm = new UpdateWindow();
|
||||
UpdateForm.Show(dockPanel);
|
||||
if (_updateForm == null || _updateForm.IsDisposed)
|
||||
_updateForm = _updateWindowBuilder();
|
||||
_updateForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.Help:
|
||||
if (_helpForm == null || _helpForm.IsDisposed)
|
||||
_helpForm = new HelpWindow();
|
||||
_helpForm.Show(dockPanel);
|
||||
_helpForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.ExternalApps:
|
||||
if (_externalappsForm == null || _externalappsForm.IsDisposed)
|
||||
_externalappsForm = new ExternalToolsWindow();
|
||||
_externalappsForm.Show(dockPanel);
|
||||
_externalappsForm = _externalToolsWindowBuilder();
|
||||
_externalappsForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.PortScan:
|
||||
_portscanForm = new PortScanWindow();
|
||||
_portscanForm.Show(dockPanel);
|
||||
_portscanForm = _portScanWindowBuilder();
|
||||
_portscanForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.UltraVNCSC:
|
||||
if (_ultravncscForm == null || _ultravncscForm.IsDisposed)
|
||||
_ultravncscForm = new UltraVNCWindow();
|
||||
_ultravncscForm.Show(dockPanel);
|
||||
_ultravncscForm = new UltraVNCWindow(Show);
|
||||
_ultravncscForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
case WindowType.ComponentsCheck:
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Showing ComponentsCheck window", true);
|
||||
if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
|
||||
_componentscheckForm = new ComponentsCheckWindow();
|
||||
_componentscheckForm.Show(dockPanel);
|
||||
_componentscheckForm.Show(_frmMain.pnlDock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -92,4 +138,4 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers.Csv;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
@@ -12,21 +11,18 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
private readonly string _connectionFileName;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
|
||||
public CsvConnectionsSaver(string connectionFileName, SaveFilter saveFilter)
|
||||
public CsvConnectionsSaver(string connectionFileName, SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionFileName))
|
||||
throw new ArgumentException($"Argument '{nameof(connectionFileName)}' cannot be null or empty");
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
|
||||
_connectionFileName = connectionFileName;
|
||||
_saveFilter = saveFilter;
|
||||
_connectionFileName = connectionFileName.ThrowIfNullOrEmpty(nameof(connectionFileName));
|
||||
_saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
_credentialRepositoryList = credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
|
||||
}
|
||||
|
||||
public void Save(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
|
||||
var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat(_saveFilter, _credentialRepositoryList);
|
||||
var dataProvider = new FileDataProvider(_connectionFileName);
|
||||
var csvContent = csvConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
dataProvider.Save(csvContent);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Timers;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Connections.Multiuser
|
||||
@@ -9,15 +11,17 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
private readonly Timer _updateTimer;
|
||||
private readonly IConnectionsUpdateChecker _updateChecker;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public double TimerIntervalInMilliseconds
|
||||
{
|
||||
get { return _updateTimer.Interval; }
|
||||
}
|
||||
|
||||
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker)
|
||||
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker, IConnectionsService connectionsService)
|
||||
{
|
||||
_updateChecker = updateChecker;
|
||||
_updateChecker = updateChecker.ThrowIfNull(nameof(updateChecker));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_updateTimer = new Timer(3000);
|
||||
SetEventListeners();
|
||||
}
|
||||
@@ -33,7 +37,7 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
|
||||
private void Load(object sender, ConnectionsUpdateAvailableEventArgs args)
|
||||
{
|
||||
Runtime.ConnectionsService.LoadConnections(true, false, "");
|
||||
_connectionsService.LoadConnections(true, false, "");
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ using System.Data.SqlClient;
|
||||
using System.Threading;
|
||||
using mRemoteNG.Config.Connections.Multiuser;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
@@ -13,13 +15,15 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
private readonly SqlDatabaseConnector _sqlConnector;
|
||||
private readonly SqlCommand _sqlQuery;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private DateTime _lastUpdateTime;
|
||||
private DateTime _lastDatabaseUpdateTime;
|
||||
|
||||
|
||||
public SqlConnectionsUpdateChecker()
|
||||
public SqlConnectionsUpdateChecker(IConnectionsService connectionsService, DatabaseConnectorFactory databaseConnectorFactory)
|
||||
{
|
||||
_sqlConnector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
databaseConnectorFactory.ThrowIfNull(nameof(databaseConnectorFactory));
|
||||
_sqlConnector = databaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
_sqlQuery = new SqlCommand("SELECT * FROM tblUpdate", _sqlConnector.SqlConnection);
|
||||
_lastUpdateTime = default(DateTime);
|
||||
_lastDatabaseUpdateTime = default(DateTime);
|
||||
@@ -64,7 +68,7 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private bool CheckIfIAmTheLastOneUpdated(DateTime lastUpdateInDb)
|
||||
{
|
||||
DateTime LastSqlUpdateWithoutMilliseconds = new DateTime(Runtime.ConnectionsService.LastSqlUpdate.Ticks - (Runtime.ConnectionsService.LastSqlUpdate.Ticks % TimeSpan.TicksPerSecond), Runtime.ConnectionsService.LastSqlUpdate.Kind);
|
||||
DateTime LastSqlUpdateWithoutMilliseconds = new DateTime(_connectionsService.LastSqlUpdate.Ticks - (_connectionsService.LastSqlUpdate.Ticks % TimeSpan.TicksPerSecond), _connectionsService.LastSqlUpdate.Kind);
|
||||
return lastUpdateInDb == LastSqlUpdateWithoutMilliseconds;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Connection;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SaveConnectionsOnEdit
|
||||
{
|
||||
private readonly ConnectionsService _connectionsService;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public SaveConnectionsOnEdit(ConnectionsService connectionsService)
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
public SaveConnectionsOnEdit(IConnectionsService connectionsService)
|
||||
{
|
||||
if (connectionsService == null)
|
||||
throw new ArgumentNullException(nameof(connectionsService));
|
||||
@@ -20,10 +22,9 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
{
|
||||
|
||||
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
|
||||
|
||||
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)
|
||||
{
|
||||
oldTree.CollectionChanged -= ConnectionTreeModelOnCollectionChanged;
|
||||
@@ -45,7 +46,11 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
if (!mRemoteNG.Settings.Default.SaveConnectionsAfterEveryEdit)
|
||||
return;
|
||||
_connectionsService.SaveConnections();
|
||||
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
_connectionsService.SaveConnectionsAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,31 @@
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Versioning;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsLoader
|
||||
{
|
||||
private readonly DatabaseConnectorFactory _databaseConnectorFactory;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public SqlConnectionsLoader(DatabaseConnectorFactory databaseConnectorFactory, IConnectionsService connectionsService)
|
||||
{
|
||||
_databaseConnectorFactory = databaseConnectorFactory.ThrowIfNull(nameof(databaseConnectorFactory));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Load()
|
||||
{
|
||||
var connector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
var connector = _databaseConnectorFactory.SqlDatabaseConnectorFromSettings();
|
||||
var dataProvider = new SqlDataProvider(connector);
|
||||
var databaseVersionVerifier = new SqlDatabaseVersionVerifier(connector);
|
||||
databaseVersionVerifier.VerifyDatabaseVersion();
|
||||
var dataTable = dataProvider.Load();
|
||||
var deserializer = new DataTableDeserializer();
|
||||
var deserializer = new DataTableDeserializer(_connectionsService);
|
||||
return deserializer.Deserialize(dataTable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Versioning;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
@@ -21,14 +21,15 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
|
||||
{
|
||||
private SecureString _password = Runtime.EncryptionKey;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly DatabaseConnectorFactory _databaseConnectorFactory;
|
||||
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter)
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter, IConnectionsService connectionsService, DatabaseConnectorFactory databaseConnectorFactory)
|
||||
{
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
_saveFilter = saveFilter;
|
||||
_saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
_databaseConnectorFactory = databaseConnectorFactory.ThrowIfNull(nameof(databaseConnectorFactory));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
public void Save(ConnectionTreeModel connectionTreeModel)
|
||||
@@ -40,7 +41,7 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
|
||||
|
||||
using (var sqlConnector = DatabaseConnectorFactory.SqlDatabaseConnectorFromSettings())
|
||||
using (var sqlConnector = _databaseConnectorFactory.SqlDatabaseConnectorFromSettings())
|
||||
{
|
||||
sqlConnector.Connect();
|
||||
var databaseVersionVerifier = new SqlDatabaseVersionVerifier(sqlConnector);
|
||||
@@ -67,17 +68,17 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
if (rootTreeNode.Password)
|
||||
{
|
||||
_password = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsProtected", _password);
|
||||
_connectionsService.EncryptionKey = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsProtected", _connectionsService.EncryptionKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _connectionsService.EncryptionKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _password);
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", _connectionsService.EncryptionKey);
|
||||
}
|
||||
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblRoot", sqlDatabaseConnector.SqlConnection);
|
||||
|
||||
@@ -1,41 +1,37 @@
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Security;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using System.IO;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class XmlConnectionsLoader
|
||||
{
|
||||
public class XmlConnectionsLoader
|
||||
{
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly string _connectionFilePath;
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public XmlConnectionsLoader(string connectionFilePath)
|
||||
public XmlConnectionsLoader(string connectionFilePath, IConnectionsService connectionsService, IWin32Window dialogWindowParent)
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionFilePath))
|
||||
throw new ArgumentException($"{nameof(connectionFilePath)} cannot be null or empty");
|
||||
|
||||
if (!File.Exists(connectionFilePath))
|
||||
throw new FileNotFoundException($"{connectionFilePath} does not exist");
|
||||
|
||||
_connectionFilePath = connectionFilePath;
|
||||
_dialogWindowParent = dialogWindowParent;
|
||||
_connectionFilePath = connectionFilePath.ThrowIfNullOrEmpty(nameof(connectionFilePath));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Load()
|
||||
{
|
||||
var dataProvider = new FileDataProvider(_connectionFilePath);
|
||||
var xmlString = dataProvider.Load();
|
||||
var deserializer = new XmlConnectionsDeserializer(PromptForPassword);
|
||||
var deserializer = new XmlConnectionsDeserializer(_connectionsService, _dialogWindowParent, PromptForPassword);
|
||||
return deserializer.Deserialize(xmlString);
|
||||
}
|
||||
|
||||
private SecureString PromptForPassword()
|
||||
private Optional<SecureString> PromptForPassword()
|
||||
{
|
||||
var password = MiscTools.PasswordDialog("", false);
|
||||
return password;
|
||||
return MiscTools.PasswordDialog("", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace mRemoteNG.Config.Connections
|
||||
try
|
||||
{
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer26(
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public class FileBackupPruner
|
||||
{
|
||||
public void PruneBackupFiles(string baseName)
|
||||
public void PruneBackupFiles(string filePath, int maxBackupsToKeep)
|
||||
{
|
||||
var fileName = Path.GetFileName(baseName);
|
||||
var directoryName = Path.GetDirectoryName(baseName);
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
var directoryName = Path.GetDirectoryName(filePath);
|
||||
|
||||
if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(directoryName)) return;
|
||||
if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(directoryName))
|
||||
return;
|
||||
|
||||
var searchPattern = string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, "*");
|
||||
var files = Directory.GetFiles(directoryName, searchPattern);
|
||||
|
||||
if (files.Length <= mRemoteNG.Settings.Default.BackupFileKeepCount) return;
|
||||
if (files.Length <= maxBackupsToKeep)
|
||||
return;
|
||||
|
||||
Array.Sort(files);
|
||||
Array.Resize(ref files, files.Length - mRemoteNG.Settings.Default.BackupFileKeepCount);
|
||||
var filesToDelete = files
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
|
||||
foreach (var file in files)
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
using mRemoteNG.App;
|
||||
using System;
|
||||
using System.Security;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class DatabaseConnectorFactory
|
||||
{
|
||||
public static SqlDatabaseConnector SqlDatabaseConnectorFromSettings()
|
||||
private readonly Func<SecureString> _decryptionKeyRetrievalFun;
|
||||
|
||||
public DatabaseConnectorFactory(Func<SecureString> decryptionKeyRetrievalFun)
|
||||
{
|
||||
_decryptionKeyRetrievalFun = decryptionKeyRetrievalFun;
|
||||
}
|
||||
|
||||
public SqlDatabaseConnector SqlDatabaseConnectorFromSettings()
|
||||
{
|
||||
var sqlHost = mRemoteNG.Settings.Default.SQLHost;
|
||||
var sqlCatalog = mRemoteNG.Settings.Default.SQLDatabaseName;
|
||||
var sqlUsername = mRemoteNG.Settings.Default.SQLUser;
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var sqlPassword = cryptographyProvider.Decrypt(mRemoteNG.Settings.Default.SQLPass, Runtime.EncryptionKey);
|
||||
var sqlPassword = cryptographyProvider.Decrypt(mRemoteNG.Settings.Default.SQLPass, _decryptionKeyRetrievalFun());
|
||||
return new SqlDatabaseConnector(sqlHost, sqlCatalog, sqlUsername, sqlPassword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Config.Serializers.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
@@ -13,6 +15,15 @@ namespace mRemoteNG.Config.Import
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public MRemoteNGXmlImporter(IConnectionsService connectionsService, IWin32Window dialogWindowParent)
|
||||
{
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
}
|
||||
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
@@ -26,7 +37,7 @@ namespace mRemoteNG.Config.Import
|
||||
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer(_connectionsService, _dialogWindowParent);
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using mRemoteNG.Tools;
|
||||
using System.Collections.Generic;
|
||||
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 class PuttySessionsManager
|
||||
{
|
||||
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();
|
||||
|
||||
@@ -35,10 +35,12 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider provider)
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
var rootTreeNode = provider.RootInfo;
|
||||
provider.GetSessions();
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
|
||||
var rootTreeNode = puttySessionProvider.RootInfo;
|
||||
puttySessionProvider.GetSessions();
|
||||
|
||||
if (!RootPuttySessionsNodes.Contains(rootTreeNode) && rootTreeNode.HasChildren())
|
||||
RootPuttySessionsNodes.Add(rootTreeNode);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Management;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
|
||||
private static ManagementEventWatcher _eventWatcher;
|
||||
@@ -39,7 +39,10 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
{
|
||||
if (string.IsNullOrEmpty(sessionName))
|
||||
return null;
|
||||
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
|
||||
if (sessionKey == null) return null;
|
||||
@@ -50,10 +53,15 @@ namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = Convert.ToString(sessionKey.GetValue("HostName")),
|
||||
Username = Convert.ToString(sessionKey.GetValue("UserName"))
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
var protocol = Convert.ToString(sessionKey.GetValue("Protocol")) ?? "ssh";
|
||||
|
||||
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
: sessionKey.GetValue("Protocol").ToString();
|
||||
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
@@ -65,16 +73,15 @@ namespace mRemoteNG.Config.Putty
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
var sshVersionObject = sessionKey.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
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
|
||||
* 2 for SSH2 with a 1 fallback
|
||||
*
|
||||
* 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;
|
||||
@@ -82,7 +89,12 @@ namespace mRemoteNG.Config.Putty
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
sessionInfo.Port = Convert.ToInt32(sessionKey.GetValue("PortNumber"));
|
||||
|
||||
int.TryParse(sessionKey.GetValue("PortNumber")?.ToString(), out var portNumber);
|
||||
if (portNumber == default(int))
|
||||
sessionInfo.SetDefaultPort();
|
||||
else
|
||||
sessionInfo.Port = portNumber;
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace mRemoteNG.Config.Putty
|
||||
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")));
|
||||
}
|
||||
|
||||
@@ -125,9 +126,6 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StartWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged += OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
@@ -136,18 +134,22 @@ namespace mRemoteNG.Config.Putty
|
||||
try
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -173,7 +175,8 @@ namespace mRemoteNG.Config.Putty
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
|
||||
return Path.Combine(Path.GetDirectoryName(puttyPath), "putty.conf");
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
return string.IsNullOrEmpty(puttyPath) ? null : Path.Combine(puttyPath, "putty.conf");
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
@@ -200,6 +203,9 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
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;
|
||||
|
||||
@@ -234,6 +234,12 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out value))
|
||||
connectionRecord.RedirectPrinters = value;
|
||||
}
|
||||
if (headers.Contains("RedirectClipboard"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectClipboard")], out value))
|
||||
connectionRecord.RedirectClipboard = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectSmartCards"))
|
||||
{
|
||||
@@ -453,6 +459,13 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
connectionRecord.Inheritance.RedirectPrinters = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectClipboard"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectClipboard")], out value))
|
||||
connectionRecord.Inheritance.RedirectClipboard = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritRedirectSmartCards"))
|
||||
{
|
||||
bool value;
|
||||
|
||||
@@ -52,9 +52,9 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
sb.Append("Password;");
|
||||
if (_saveFilter.SaveDomain)
|
||||
sb.Append("Domain;");
|
||||
sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
|
||||
sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectClipboard;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
|
||||
if (_saveFilter.SaveInheritance)
|
||||
sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
|
||||
sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectClipboard;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo node, StringBuilder sb)
|
||||
@@ -116,6 +116,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
.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))
|
||||
@@ -164,6 +165,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectKeys))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPorts))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSound))
|
||||
.Append(FormatForCsv(con.Inheritance.Resolution))
|
||||
|
||||
@@ -210,7 +210,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));
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo,XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
if (encryptionKey == null)
|
||||
throw new ArgumentNullException(nameof(encryptionKey));
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
|
||||
_cryptographyProvider = cryptographyProvider;
|
||||
_encryptionKey = encryptionKey;
|
||||
_saveFilter = saveFilter;
|
||||
}
|
||||
|
||||
public XElement Serialize(ConnectionInfo connectionInfo)
|
||||
{
|
||||
var element = new XElement(XName.Get("Node", ""));
|
||||
SetElementAttributes(element, connectionInfo);
|
||||
SetInheritanceAttributes(element, connectionInfo);
|
||||
return element;
|
||||
}
|
||||
|
||||
private void SetElementAttributes(XContainer element, ConnectionInfo connectionInfo)
|
||||
{
|
||||
var nodeAsContainer = connectionInfo as ContainerInfo;
|
||||
element.Add(new XAttribute("Name", connectionInfo.Name));
|
||||
element.Add(new XAttribute("Type", connectionInfo.GetTreeNodeType().ToString()));
|
||||
if (nodeAsContainer != null)
|
||||
element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Descr", connectionInfo.Description));
|
||||
element.Add(new XAttribute("Icon", connectionInfo.Icon));
|
||||
element.Add(new XAttribute("Panel", connectionInfo.Panel));
|
||||
element.Add(new XAttribute("Id", connectionInfo.ConstantID));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
|
||||
if (_saveFilter.SavePassword && !connectionInfo.Inheritance.Password)
|
||||
element.Add(new XAttribute("Password", _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
else
|
||||
element.Add(new XAttribute("Password", ""));
|
||||
|
||||
element.Add(new XAttribute("Hostname", connectionInfo.Hostname));
|
||||
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("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("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("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("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("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
element.Add(new XAttribute("UserField", connectionInfo.UserField));
|
||||
element.Add(new XAttribute("ExtApp", connectionInfo.ExtApp));
|
||||
element.Add(new XAttribute("VNCCompression", connectionInfo.VNCCompression));
|
||||
element.Add(new XAttribute("VNCEncoding", connectionInfo.VNCEncoding));
|
||||
element.Add(new XAttribute("VNCAuthMode", connectionInfo.VNCAuthMode));
|
||||
element.Add(new XAttribute("VNCProxyType", connectionInfo.VNCProxyType));
|
||||
element.Add(new XAttribute("VNCProxyIP", connectionInfo.VNCProxyIP));
|
||||
element.Add(new XAttribute("VNCProxyPort", connectionInfo.VNCProxyPort));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? 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(_saveFilter.SaveUsername
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
}
|
||||
|
||||
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
|
||||
{
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", connectionInfo.Inheritance.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
}
|
||||
else
|
||||
{
|
||||
var falseString = false.ToString().ToLowerInvariant();
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", falseString));
|
||||
element.Add(new XAttribute("InheritColors", falseString));
|
||||
element.Add(new XAttribute("InheritDescription", falseString));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", falseString));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", falseString));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", falseString));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", falseString));
|
||||
element.Add(new XAttribute("InheritDomain", falseString));
|
||||
element.Add(new XAttribute("InheritIcon", falseString));
|
||||
element.Add(new XAttribute("InheritPanel", falseString));
|
||||
element.Add(new XAttribute("InheritPassword", falseString));
|
||||
element.Add(new XAttribute("InheritPort", falseString));
|
||||
element.Add(new XAttribute("InheritProtocol", falseString));
|
||||
element.Add(new XAttribute("InheritPuttySession", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
element.Add(new XAttribute("InheritResolution", falseString));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", falseString));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", falseString));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", falseString));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", falseString));
|
||||
element.Add(new XAttribute("InheritUsername", falseString));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", falseString));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", falseString));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", falseString));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", falseString));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", falseString));
|
||||
element.Add(new XAttribute("InheritPreExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritPostExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritMacAddress", falseString));
|
||||
element.Add(new XAttribute("InheritUserField", falseString));
|
||||
element.Add(new XAttribute("InheritExtApp", falseString));
|
||||
element.Add(new XAttribute("InheritVNCCompression", falseString));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", falseString));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", falseString));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", falseString));
|
||||
element.Add(new XAttribute("InheritVNCColors", falseString));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", falseString));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", falseString));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", falseString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI.Forms;
|
||||
@@ -20,19 +21,23 @@ using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
|
||||
{
|
||||
public class XmlConnectionsDeserializer : IDeserializer<string, ConnectionTreeModel>
|
||||
{
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
private XmlDocument _xmlDocument;
|
||||
private double _confVersion;
|
||||
private XmlConnectionsDecryptor _decryptor;
|
||||
private string ConnectionFileName = "";
|
||||
private const double MaxSupportedConfVersion = 2.8;
|
||||
private readonly RootNodeInfo _rootNodeInfo = new RootNodeInfo(RootNodeType.Connection);
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
|
||||
public Func<SecureString> AuthenticationRequestor { get; set; }
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; }
|
||||
|
||||
public XmlConnectionsDeserializer(Func<SecureString> authenticationRequestor = null)
|
||||
public XmlConnectionsDeserializer(IConnectionsService connectionsService, IWin32Window dialogWindowParent, Func<Optional<SecureString>> authenticationRequestor = null)
|
||||
{
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
AuthenticationRequestor = authenticationRequestor;
|
||||
}
|
||||
|
||||
@@ -47,8 +52,6 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
LoadXmlConnectionData(xml);
|
||||
ValidateConnectionFileVersion();
|
||||
if (!import)
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = false;
|
||||
|
||||
var rootXmlElement = _xmlDocument.DocumentElement;
|
||||
InitializeRootNode(rootXmlElement);
|
||||
@@ -62,8 +65,6 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
|
||||
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
{
|
||||
mRemoteNG.Settings.Default.LoadConsFromCustomLocation = false;
|
||||
mRemoteNG.Settings.Default.CustomConsPath = "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -81,13 +82,13 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
AddNodesFromXmlRecursive(_xmlDocument.DocumentElement, _rootNodeInfo);
|
||||
|
||||
if (!import)
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = true;
|
||||
_connectionsService.IsConnectionsFileLoaded = true;
|
||||
|
||||
return connectionTreeModel;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = false;
|
||||
_connectionsService.IsConnectionsFileLoaded = false;
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(Language.strLoadFromXmlFailed, ex);
|
||||
throw;
|
||||
}
|
||||
@@ -117,7 +118,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private void ShowIncompatibleVersionDialogBox()
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
FrmMain.Default,
|
||||
_dialogWindowParent,
|
||||
Application.ProductName,
|
||||
"Incompatible connection file format",
|
||||
$"The format of this connection file is not supported. Please upgrade to a newer version of {Application.ProductName}.",
|
||||
@@ -208,7 +209,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
if (xmlnode.Attributes == null) return null;
|
||||
|
||||
var connectionId = xmlnode.Attributes["Id"]?.Value ?? Guid.NewGuid().ToString();
|
||||
var connectionId = xmlnode.Attributes["Id"]?.Value;
|
||||
if (string.IsNullOrWhiteSpace(connectionId))
|
||||
connectionId = Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
|
||||
try
|
||||
@@ -286,14 +289,14 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (_confVersion >= 0.5)
|
||||
{
|
||||
connectionInfo.RedirectDiskDrives = bool.Parse(xmlnode.Attributes["RedirectDiskDrives"].Value);
|
||||
connectionInfo.RedirectPrinters = bool.Parse(xmlnode.Attributes["RedirectPrinters"].Value);
|
||||
connectionInfo.RedirectPrinters = bool.Parse(xmlnode.Attributes["RedirectPrinters"].Value);
|
||||
connectionInfo.RedirectPorts = bool.Parse(xmlnode.Attributes["RedirectPorts"].Value);
|
||||
connectionInfo.RedirectSmartCards = bool.Parse(xmlnode.Attributes["RedirectSmartCards"].Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionInfo.RedirectDiskDrives = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPorts = false;
|
||||
connectionInfo.RedirectSmartCards = false;
|
||||
}
|
||||
@@ -509,6 +512,11 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.RDPAlertIdleTimeout = bool.Parse(xmlnode.Attributes["RDPAlertIdleTimeout"]?.Value ?? "False");
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout = bool.Parse(xmlnode.Attributes["InheritRDPAlertIdleTimeout"]?.Value ?? "False");
|
||||
}
|
||||
if(_confVersion >= 2.7)
|
||||
{
|
||||
connectionInfo.RedirectClipboard = bool.Parse(xmlnode.Attributes["RedirectClipboard"].Value);
|
||||
connectionInfo.Inheritance.RedirectClipboard = bool.Parse(xmlnode.Attributes["InheritRedirectClipboard"].Value);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -10,18 +10,26 @@ using mRemoteNG.Connection.Protocol.ICA;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
{
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public DataTableDeserializer(IConnectionsService connectionsService)
|
||||
{
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
var connectionList = CreateNodesFromTable(table);
|
||||
var connectionTreeModel = CreateNodeHierarchy(connectionList, table);
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = true;
|
||||
_connectionsService.IsConnectionsFileLoaded = true;
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
@@ -101,6 +109,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.RedirectDiskDrives = (bool)dataRow["RedirectDiskDrives"];
|
||||
connectionInfo.RedirectPorts = (bool)dataRow["RedirectPorts"];
|
||||
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"]);
|
||||
@@ -147,6 +156,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.Inheritance.RedirectKeys = (bool)dataRow["InheritRedirectKeys"];
|
||||
connectionInfo.Inheritance.RedirectPorts = (bool)dataRow["InheritRedirectPorts"];
|
||||
connectionInfo.Inheritance.RedirectPrinters = (bool)dataRow["InheritRedirectPrinters"];
|
||||
connectionInfo.Inheritance.RedirectClipboard = (bool)dataRow["InheritRedirectClipboard"];
|
||||
connectionInfo.Inheritance.RedirectSmartCards = (bool)dataRow["InheritRedirectSmartCards"];
|
||||
connectionInfo.Inheritance.RedirectSound = (bool)dataRow["InheritRedirectSound"];
|
||||
connectionInfo.Inheritance.SoundQuality = (bool)dataRow["InheritSoundQuality"];
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataTable.Columns.Add("RedirectDiskDrives", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectPorts", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectPrinters", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectClipboard", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectSmartCards", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectSound", typeof(string));
|
||||
dataTable.Columns.Add("RedirectKeys", typeof(bool));
|
||||
@@ -135,6 +136,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataTable.Columns.Add("InheritRedirectKeys", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectPorts", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectPrinters", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectClipboard", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectSmartCards", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectSound", typeof(bool));
|
||||
dataTable.Columns.Add("InheritResolution", typeof(bool));
|
||||
@@ -235,6 +237,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataRow["RedirectDiskDrives"] = connectionInfo.RedirectDiskDrives;
|
||||
dataRow["RedirectPorts"] = connectionInfo.RedirectPorts;
|
||||
dataRow["RedirectPrinters"] = connectionInfo.RedirectPrinters;
|
||||
dataRow["RedirectClipboard"] = connectionInfo.RedirectClipboard;
|
||||
dataRow["RedirectSmartCards"] = connectionInfo.RedirectSmartCards;
|
||||
dataRow["RedirectSound"] = connectionInfo.RedirectSound;
|
||||
dataRow["SoundQuality"] = connectionInfo.SoundQuality;
|
||||
@@ -282,6 +285,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataRow["InheritRedirectKeys"] = connectionInfo.Inheritance.RedirectKeys;
|
||||
dataRow["InheritRedirectPorts"] = connectionInfo.Inheritance.RedirectPorts;
|
||||
dataRow["InheritRedirectPrinters"] = connectionInfo.Inheritance.RedirectPrinters;
|
||||
dataRow["InheritRedirectClipboard"] = connectionInfo.Inheritance.RedirectClipboard;
|
||||
dataRow["InheritRedirectSmartCards"] = connectionInfo.Inheritance.RedirectSmartCards;
|
||||
dataRow["InheritRedirectSound"] = connectionInfo.Inheritance.RedirectSound;
|
||||
dataRow["InheritSoundQuality"] = connectionInfo.Inheritance.SoundQuality;
|
||||
@@ -339,6 +343,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataRow["InheritRedirectKeys"] = false;
|
||||
dataRow["InheritRedirectPorts"] = false;
|
||||
dataRow["InheritRedirectPrinters"] = false;
|
||||
dataRow["InheritRedirectClipboard"] = false;
|
||||
dataRow["InheritRedirectSmartCards"] = false;
|
||||
dataRow["InheritRedirectSound"] = false;
|
||||
dataRow["InheritSoundQuality"] = false;
|
||||
|
||||
@@ -108,6 +108,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
case "redirectprinters":
|
||||
connectionInfo.RedirectPrinters = value == "1";
|
||||
break;
|
||||
case "redirectclipboard":
|
||||
connectionInfo.RedirectClipboard = value == "1";
|
||||
break;
|
||||
case "audiomode":
|
||||
switch (value)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
@@ -7,8 +9,6 @@ using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
@@ -60,7 +60,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
else
|
||||
{
|
||||
var versionNode = rdcManNode.SelectSingleNode("./version")?.InnerText;
|
||||
var versionNode = rdcManNode?.SelectSingleNode("./version")?.InnerText;
|
||||
if (versionNode != null)
|
||||
{
|
||||
var version = new Version(versionNode);
|
||||
@@ -101,15 +101,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (_schemaVersion == 1)
|
||||
{
|
||||
// Program Verison 2.2 wraps all setting inside the Properties tags
|
||||
// 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);
|
||||
|
||||
if (_schemaVersion == 3)
|
||||
{
|
||||
// Program Verison 2.7 wraps these properties
|
||||
// Program Version 2.7 wraps these properties
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
newContainer.Name = containerPropertiesNode?.SelectSingleNode("./name")?.InnerText ?? Language.strNewFolder;
|
||||
@@ -130,20 +131,22 @@ 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
|
||||
connectionInfo.Hostname = propertiesNode.SelectSingleNode("./name")?.InnerText;
|
||||
connectionInfo.Name = propertiesNode.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Description = propertiesNode.SelectSingleNode("./comment")?.InnerText ?? String.Empty;
|
||||
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.Description = propertiesNode?.SelectSingleNode("./comment")?.InnerText ?? string.Empty;
|
||||
|
||||
var logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
|
||||
if (logonCredentialsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (logonCredentialsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.Username = logonCredentialsNode.SelectSingleNode("userName")?.InnerText;
|
||||
|
||||
var passwordNode = logonCredentialsNode.SelectSingleNode("./password");
|
||||
if (_schemaVersion == 1) // Version 2.2 allows clear text passwords
|
||||
{
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"].Value == "True" ? passwordNode.InnerText : DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True"
|
||||
? passwordNode.InnerText
|
||||
: DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,7 +163,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
|
||||
if (connectionSettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (connectionSettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
// ./startProgram
|
||||
@@ -174,7 +177,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RdpProtocol.RDGatewayUsageMethod.Always : RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName")?.InnerText;
|
||||
@@ -198,7 +201,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var remoteDesktopNode = xmlNode.SelectSingleNode("./remoteDesktop");
|
||||
if (remoteDesktopNode?.Attributes?["inherit"].Value == "None")
|
||||
if (remoteDesktopNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
var resolutionString = remoteDesktopNode.SelectSingleNode("./size")?.InnerText.Replace(" ", "");
|
||||
try
|
||||
@@ -231,7 +234,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
var localResourcesNode = xmlNode.SelectSingleNode("./localResources");
|
||||
if (localResourcesNode?.Attributes?["inherit"].Value == "None")
|
||||
if (localResourcesNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (localResourcesNode.SelectSingleNode("./audioRedirection")?.InnerText)
|
||||
@@ -271,10 +274,11 @@ 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.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
|
||||
{
|
||||
@@ -284,10 +288,11 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.Inheritance.RedirectPorts = true;
|
||||
connectionInfo.Inheritance.RedirectPrinters = true;
|
||||
connectionInfo.Inheritance.RedirectSmartCards = true;
|
||||
connectionInfo.Inheritance.RedirectClipboard = true;
|
||||
}
|
||||
|
||||
var securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings");
|
||||
if (securitySettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
if (securitySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (securitySettingsNode.SelectSingleNode("./authentication")?.InnerText)
|
||||
@@ -321,7 +326,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
private static string DecryptRdcManPassword(string ciphertext)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ciphertext))
|
||||
return null;
|
||||
return string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -332,7 +337,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
catch (Exception /*ex*/)
|
||||
{
|
||||
//Runtime.MessageCollector.AddExceptionMessage("RemoteDesktopConnectionManager.DecryptPassword() failed.", ex, logOnly: true);
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.Authentication;
|
||||
using mRemoteNG.Security.Factories;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers
|
||||
@@ -13,7 +14,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly RootNodeInfo _rootNodeInfo;
|
||||
|
||||
public Func<SecureString> AuthenticationRequestor { get; set; }
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; }
|
||||
|
||||
public int KeyDerivationIterations
|
||||
{
|
||||
@@ -91,16 +92,14 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
private bool Authenticate(string cipherText, SecureString password)
|
||||
{
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, cipherText)
|
||||
{
|
||||
AuthenticationRequestor = AuthenticationRequestor
|
||||
};
|
||||
|
||||
var authenticator = new PasswordAuthenticator(_cryptographyProvider, cipherText, AuthenticationRequestor);
|
||||
var authenticated = authenticator.Authenticate(password);
|
||||
|
||||
if (!authenticated) return authenticated;
|
||||
if (!authenticated)
|
||||
return false;
|
||||
|
||||
_rootNodeInfo.PasswordString = authenticator.LastAuthenticatedPassword.ConvertToUnsecureString();
|
||||
return authenticated;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using mRemoteNG.UI.Window;
|
||||
using System;
|
||||
using System.IO;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.Config.Settings
|
||||
@@ -13,16 +14,13 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
private readonly FrmMain _mainForm;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly Windows _windows;
|
||||
|
||||
public DockPanelLayoutLoader(FrmMain mainForm, MessageCollector messageCollector)
|
||||
public DockPanelLayoutLoader(FrmMain mainForm, MessageCollector messageCollector, Windows windows)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
if (messageCollector == null)
|
||||
throw new ArgumentNullException(nameof(messageCollector));
|
||||
|
||||
_mainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_mainForm = mainForm.ThrowIfNull(nameof(mainForm));
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_windows = windows.ThrowIfNull(nameof(windows));
|
||||
}
|
||||
|
||||
public void LoadPanelsFromXml()
|
||||
@@ -69,16 +67,16 @@ namespace mRemoteNG.Config.Settings
|
||||
try
|
||||
{
|
||||
if (persistString == typeof(ConfigWindow).ToString())
|
||||
return Windows.ConfigForm;
|
||||
return _windows.ConfigForm;
|
||||
|
||||
if (persistString == typeof(ConnectionTreeWindow).ToString())
|
||||
return Windows.TreeForm;
|
||||
return _windows.TreeForm;
|
||||
|
||||
if (persistString == typeof(ErrorAndInfoWindow).ToString())
|
||||
return Windows.ErrorsForm;
|
||||
return _windows.ErrorsForm;
|
||||
|
||||
if (persistString == typeof(ScreenshotManagerWindow).ToString())
|
||||
return Windows.ScreenshotForm;
|
||||
return _windows.ScreenshotForm;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace mRemoteNG.Config.Settings
|
||||
_dataProvider = dataProvider;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public void Save(DockPanel dockPanel)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace mRemoteNG.Config.Settings
|
||||
Directory.CreateDirectory(SettingsFileInfo.SettingsPath);
|
||||
}
|
||||
|
||||
var serializedLayout = _dockPanelSerializer.Serialize(FrmMain.Default.pnlDock);
|
||||
var serializedLayout = _dockPanelSerializer.Serialize(dockPanel);
|
||||
_dataProvider.Save(serializedLayout);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -4,6 +4,7 @@ using mRemoteNG.App.Info;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
@@ -12,22 +13,20 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
public class ExternalAppsLoader
|
||||
{
|
||||
private readonly FrmMain _mainForm;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly ExternalToolsService _externalToolsService;
|
||||
private readonly IConnectionsService _connectionsService;
|
||||
|
||||
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
public ExternalAppsLoader(MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip,
|
||||
IConnectionInitiator connectionInitiator, ExternalToolsService externalToolsService, IConnectionsService connectionsService)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
if (messageCollector == null)
|
||||
throw new ArgumentNullException(nameof(messageCollector));
|
||||
if (externalToolsToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(externalToolsToolStrip));
|
||||
|
||||
_mainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_externalToolsToolStrip = externalToolsToolStrip.ThrowIfNull(nameof(externalToolsToolStrip));
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_externalToolsService = externalToolsService.ThrowIfNull(nameof(externalToolsService));
|
||||
_connectionsService = connectionsService.ThrowIfNull(nameof(connectionsService));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +47,6 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {oldPath}", true);
|
||||
xDom.Load(oldPath);
|
||||
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@@ -65,7 +63,7 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
foreach (XmlElement xEl in xDom.DocumentElement.ChildNodes)
|
||||
{
|
||||
var extA = new ExternalTool
|
||||
var extA = new ExternalTool(_connectionInitiator, _connectionsService)
|
||||
{
|
||||
DisplayName = xEl.Attributes["DisplayName"].Value,
|
||||
FileName = xEl.Attributes["FileName"].Value,
|
||||
@@ -94,7 +92,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true);
|
||||
Runtime.ExternalToolsService.ExternalTools.Add(extA);
|
||||
_externalToolsService.ExternalTools.Add(extA);
|
||||
}
|
||||
|
||||
_externalToolsToolStrip.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Configuration;
|
||||
#if !PORTABLE
|
||||
using System.Configuration;
|
||||
#endif
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/// The MIT License (MIT)
|
||||
///
|
||||
/// Copyright(c) crdx
|
||||
///
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining
|
||||
/// a copy of this software and associated documentation files (the
|
||||
/// "Software"), to deal in the Software without restriction, including
|
||||
/// without limitation the rights to use, copy, modify, merge, publish,
|
||||
/// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
/// permit persons to whom the Software is furnished to do so, subject to
|
||||
/// the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be
|
||||
/// included in all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
/// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
/// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
/// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
/// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
/// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
///
|
||||
/// https://raw.githubusercontent.com/crdx/PortableSettingsProvider
|
||||
///
|
||||
using System.Linq;
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright(c) crdx
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// https://raw.githubusercontent.com/crdx/PortableSettingsProvider
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
//using mRemoteNG.App;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
@@ -43,63 +43,34 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
private const string _className = "PortableSettingsProvider";
|
||||
private XmlDocument _xmlDocument;
|
||||
|
||||
private string _filePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),
|
||||
string.Format("{0}.settings", ApplicationName));
|
||||
}
|
||||
}
|
||||
private string _filePath => Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException(), $"{ApplicationName}.settings");
|
||||
|
||||
private XmlNode _localSettingsNode
|
||||
{
|
||||
get
|
||||
{
|
||||
XmlNode settingsNode = GetSettingsNode(_localSettingsNodeName);
|
||||
XmlNode machineNode = settingsNode.SelectSingleNode(Environment.MachineName.ToLowerInvariant());
|
||||
private XmlNode _localSettingsNode => GetSettingsNode(_localSettingsNodeName);
|
||||
|
||||
if (machineNode == null)
|
||||
{
|
||||
machineNode = _rootDocument.CreateElement(Environment.MachineName.ToLowerInvariant());
|
||||
settingsNode.AppendChild(machineNode);
|
||||
}
|
||||
private XmlNode _globalSettingsNode => GetSettingsNode(_globalSettingsNodeName);
|
||||
|
||||
return machineNode;
|
||||
}
|
||||
}
|
||||
|
||||
private XmlNode _globalSettingsNode
|
||||
{
|
||||
get { return GetSettingsNode(_globalSettingsNodeName); }
|
||||
}
|
||||
|
||||
private XmlNode _rootNode
|
||||
{
|
||||
get { return _rootDocument.SelectSingleNode(_rootNodeName); }
|
||||
}
|
||||
private XmlNode _rootNode => _rootDocument.SelectSingleNode(_rootNodeName);
|
||||
|
||||
private XmlDocument _rootDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_xmlDocument == null)
|
||||
if (_xmlDocument != null) return _xmlDocument;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_xmlDocument = new XmlDocument();
|
||||
_xmlDocument.Load(_filePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (_xmlDocument.SelectSingleNode(_rootNodeName) != null)
|
||||
return _xmlDocument;
|
||||
|
||||
_xmlDocument = GetBlankXmlDocument();
|
||||
_xmlDocument = new XmlDocument();
|
||||
_xmlDocument.Load(_filePath);
|
||||
}
|
||||
catch (Exception /*ex*/)
|
||||
{
|
||||
// This casues hundreds of unit tests to fail for some reason...
|
||||
//Runtime.MessageCollector.AddExceptionStackTrace("PortableSettingsProvider: Error getting XML", ex);
|
||||
}
|
||||
|
||||
if (_xmlDocument?.SelectSingleNode(_rootNodeName) != null)
|
||||
return _xmlDocument;
|
||||
|
||||
_xmlDocument = GetBlankXmlDocument();
|
||||
|
||||
return _xmlDocument;
|
||||
}
|
||||
@@ -107,14 +78,11 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
public override string ApplicationName
|
||||
{
|
||||
get { return Path.GetFileNameWithoutExtension(Application.ExecutablePath); }
|
||||
get => Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
||||
set { }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return _className; }
|
||||
}
|
||||
public override string Name => _className;
|
||||
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
@@ -143,7 +111,7 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
|
||||
{
|
||||
SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
|
||||
var values = new SettingsPropertyValueCollection();
|
||||
|
||||
foreach (SettingsProperty property in collection)
|
||||
{
|
||||
@@ -158,11 +126,9 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private void SetValue(SettingsPropertyValue propertyValue)
|
||||
{
|
||||
XmlNode targetNode = IsGlobal(propertyValue.Property)
|
||||
? _globalSettingsNode
|
||||
: _localSettingsNode;
|
||||
var targetNode = IsGlobal(propertyValue.Property) ? _globalSettingsNode : _localSettingsNode;
|
||||
|
||||
XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", propertyValue.Name));
|
||||
var settingNode = targetNode.SelectSingleNode($"setting[@name='{propertyValue.Name}']");
|
||||
|
||||
if (settingNode != null)
|
||||
settingNode.InnerText = propertyValue.SerializedValue.ToString();
|
||||
@@ -170,10 +136,10 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
{
|
||||
settingNode = _rootDocument.CreateElement("setting");
|
||||
|
||||
XmlAttribute nameAttribute = _rootDocument.CreateAttribute("name");
|
||||
var nameAttribute = _rootDocument.CreateAttribute("name");
|
||||
nameAttribute.Value = propertyValue.Name;
|
||||
|
||||
settingNode.Attributes.Append(nameAttribute);
|
||||
settingNode.Attributes?.Append(nameAttribute);
|
||||
settingNode.InnerText = propertyValue.SerializedValue.ToString();
|
||||
|
||||
targetNode.AppendChild(settingNode);
|
||||
@@ -182,8 +148,8 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private string GetValue(SettingsProperty property)
|
||||
{
|
||||
XmlNode targetNode = IsGlobal(property) ? _globalSettingsNode : _localSettingsNode;
|
||||
XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", property.Name));
|
||||
var targetNode = IsGlobal(property) ? _globalSettingsNode : _localSettingsNode;
|
||||
var settingNode = targetNode.SelectSingleNode($"setting[@name='{property.Name}']");
|
||||
|
||||
if (settingNode == null)
|
||||
return property.DefaultValue != null ? property.DefaultValue.ToString() : string.Empty;
|
||||
@@ -191,7 +157,7 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
return settingNode.InnerText;
|
||||
}
|
||||
|
||||
private bool IsGlobal(SettingsProperty property)
|
||||
private static bool IsGlobal(SettingsProperty property)
|
||||
{
|
||||
foreach (DictionaryEntry attribute in property.Attributes)
|
||||
{
|
||||
@@ -204,20 +170,18 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
|
||||
private XmlNode GetSettingsNode(string name)
|
||||
{
|
||||
XmlNode settingsNode = _rootNode.SelectSingleNode(name);
|
||||
var settingsNode = _rootNode.SelectSingleNode(name);
|
||||
|
||||
if (settingsNode == null)
|
||||
{
|
||||
settingsNode = _rootDocument.CreateElement(name);
|
||||
_rootNode.AppendChild(settingsNode);
|
||||
}
|
||||
if (settingsNode != null) return settingsNode;
|
||||
settingsNode = _rootDocument.CreateElement(name);
|
||||
_rootNode.AppendChild(settingsNode);
|
||||
|
||||
return settingsNode;
|
||||
}
|
||||
|
||||
public XmlDocument GetBlankXmlDocument()
|
||||
private static XmlDocument GetBlankXmlDocument()
|
||||
{
|
||||
XmlDocument blankXmlDocument = new XmlDocument();
|
||||
var blankXmlDocument = new XmlDocument();
|
||||
blankXmlDocument.AppendChild(blankXmlDocument.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
|
||||
blankXmlDocument.AppendChild(blankXmlDocument.CreateElement(_rootNodeName));
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
private readonly ExternalAppsLoader _externalAppsLoader;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly MenuStrip _mainMenu;
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly MultiSshToolStrip _multiSshToolStrip;
|
||||
|
||||
private FrmMain MainForm { get; }
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
private readonly FrmMain _frmMain;
|
||||
|
||||
|
||||
public SettingsLoader(
|
||||
@@ -31,26 +32,20 @@ namespace mRemoteNG.Config.Settings
|
||||
MessageCollector messageCollector,
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip)
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
ExternalAppsLoader externalAppsLoader,
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder,
|
||||
MenuStrip mainMenu)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
if (messageCollector == null)
|
||||
throw new ArgumentNullException(nameof(messageCollector));
|
||||
if (quickConnectToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(quickConnectToolStrip));
|
||||
if (externalToolsToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(externalToolsToolStrip));
|
||||
if (multiSshToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(multiSshToolStrip));
|
||||
|
||||
MainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_quickConnectToolStrip = quickConnectToolStrip;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_multiSshToolStrip = multiSshToolStrip;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip);
|
||||
}
|
||||
_frmMain = mainForm.ThrowIfNull(nameof(mainForm));
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_quickConnectToolStrip = quickConnectToolStrip.ThrowIfNull(nameof(quickConnectToolStrip));
|
||||
_externalToolsToolStrip = externalToolsToolStrip.ThrowIfNull(nameof(externalToolsToolStrip));
|
||||
_multiSshToolStrip = multiSshToolStrip.ThrowIfNull(nameof(multiSshToolStrip));
|
||||
_externalAppsLoader = externalAppsLoader.ThrowIfNull(nameof(externalAppsLoader));
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder.ThrowIfNull(nameof(notificationAreaIconBuilder));
|
||||
_mainMenu = mainMenu.ThrowIfNull(nameof(mainMenu));
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
public void LoadSettings()
|
||||
@@ -80,10 +75,10 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetAlwaysShowPanelTabs()
|
||||
private void SetAlwaysShowPanelTabs()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.AlwaysShowPanelTabs)
|
||||
FrmMain.Default.pnlDock.DocumentStyle = DocumentStyle.DockingWindow;
|
||||
_frmMain.pnlDock.DocumentStyle = DocumentStyle.DockingWindow;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,32 +93,32 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
private void SetApplicationWindowPositionAndSize()
|
||||
{
|
||||
MainForm.WindowState = FormWindowState.Normal;
|
||||
_frmMain.WindowState = FormWindowState.Normal;
|
||||
if (mRemoteNG.Settings.Default.MainFormState == FormWindowState.Normal)
|
||||
{
|
||||
if (!mRemoteNG.Settings.Default.MainFormLocation.IsEmpty)
|
||||
MainForm.Location = mRemoteNG.Settings.Default.MainFormLocation;
|
||||
_frmMain.Location = mRemoteNG.Settings.Default.MainFormLocation;
|
||||
if (!mRemoteNG.Settings.Default.MainFormSize.IsEmpty)
|
||||
MainForm.Size = mRemoteNG.Settings.Default.MainFormSize;
|
||||
_frmMain.Size = mRemoteNG.Settings.Default.MainFormSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mRemoteNG.Settings.Default.MainFormRestoreLocation.IsEmpty)
|
||||
MainForm.Location = mRemoteNG.Settings.Default.MainFormRestoreLocation;
|
||||
_frmMain.Location = mRemoteNG.Settings.Default.MainFormRestoreLocation;
|
||||
if (!mRemoteNG.Settings.Default.MainFormRestoreSize.IsEmpty)
|
||||
MainForm.Size = mRemoteNG.Settings.Default.MainFormRestoreSize;
|
||||
_frmMain.Size = mRemoteNG.Settings.Default.MainFormRestoreSize;
|
||||
}
|
||||
|
||||
if (mRemoteNG.Settings.Default.MainFormState == FormWindowState.Maximized)
|
||||
{
|
||||
MainForm.WindowState = FormWindowState.Maximized;
|
||||
_frmMain.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
|
||||
// Make sure the form is visible on the screen
|
||||
const int minHorizontal = 300;
|
||||
const int minVertical = 150;
|
||||
var screenBounds = Screen.FromHandle(MainForm.Handle).Bounds;
|
||||
var newBounds = MainForm.Bounds;
|
||||
var screenBounds = Screen.FromHandle(_frmMain.Handle).Bounds;
|
||||
var newBounds = _frmMain.Bounds;
|
||||
|
||||
if (newBounds.Right < screenBounds.Left + minHorizontal)
|
||||
newBounds.X = screenBounds.Left + minHorizontal - newBounds.Width;
|
||||
@@ -134,29 +129,29 @@ namespace mRemoteNG.Config.Settings
|
||||
if (newBounds.Top > screenBounds.Bottom - minVertical)
|
||||
newBounds.Y = screenBounds.Bottom - minVertical;
|
||||
|
||||
MainForm.Location = newBounds.Location;
|
||||
_frmMain.Location = newBounds.Location;
|
||||
}
|
||||
|
||||
private void SetAutoSave()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.AutoSaveEveryMinutes <= 0) return;
|
||||
MainForm.tmrAutoSave.Interval = mRemoteNG.Settings.Default.AutoSaveEveryMinutes * 60000;
|
||||
MainForm.tmrAutoSave.Enabled = true;
|
||||
_frmMain.tmrAutoSave.Interval = mRemoteNG.Settings.Default.AutoSaveEveryMinutes * 60000;
|
||||
_frmMain.tmrAutoSave.Enabled = true;
|
||||
}
|
||||
|
||||
private void SetKioskMode()
|
||||
{
|
||||
if (!mRemoteNG.Settings.Default.MainFormKiosk) return;
|
||||
MainForm.Fullscreen.Value = true;
|
||||
_frmMain.Fullscreen.Value = true;
|
||||
}
|
||||
|
||||
private static void SetShowSystemTrayIcon()
|
||||
private void SetShowSystemTrayIcon()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.ShowSystemTrayIcon)
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon();
|
||||
Runtime.NotificationAreaIcon = _notificationAreaIconBuilder();
|
||||
}
|
||||
|
||||
private static void SetPuttyPath()
|
||||
private void SetPuttyPath()
|
||||
{
|
||||
PuttyBase.PuttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : GeneralAppInfo.PuttyPath;
|
||||
}
|
||||
@@ -197,6 +192,7 @@ namespace mRemoteNG.Config.Settings
|
||||
private void LoadToolbarsFromSettings()
|
||||
{
|
||||
ResetAllToolbarLocations();
|
||||
AddMainMenuPanel();
|
||||
AddExternalAppsPanel();
|
||||
AddQuickConnectPanel();
|
||||
AddMultiSshPanel();
|
||||
@@ -210,46 +206,64 @@ namespace mRemoteNG.Config.Settings
|
||||
private void ResetAllToolbarLocations()
|
||||
{
|
||||
var tempToolStrip = new ToolStripPanel();
|
||||
tempToolStrip.Join(_mainMenu);
|
||||
tempToolStrip.Join(_quickConnectToolStrip);
|
||||
tempToolStrip.Join(_externalToolsToolStrip);
|
||||
tempToolStrip.Join(_multiSshToolStrip);
|
||||
}
|
||||
|
||||
private void AddMainMenuPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_mainMenu);
|
||||
var toolStripPanel = ToolStripPanelFromString("top");
|
||||
toolStripPanel.Join(_mainMenu, new Point(3, 0));
|
||||
}
|
||||
|
||||
private void AddQuickConnectPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_quickConnectToolStrip);
|
||||
_quickConnectToolStrip.Visible = mRemoteNG.Settings.Default.QuickyTBVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.QuickyTBParentDock);
|
||||
toolStripPanel.Join(_quickConnectToolStrip, mRemoteNG.Settings.Default.QuickyTBLocation);
|
||||
_quickConnectToolStrip.Visible = mRemoteNG.Settings.Default.QuickyTBVisible;
|
||||
}
|
||||
|
||||
private void AddExternalAppsPanel()
|
||||
{
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock);
|
||||
toolStripPanel.Join(_externalToolsToolStrip, mRemoteNG.Settings.Default.ExtAppsTBLocation);
|
||||
SetToolstripGripStyle(_externalToolsToolStrip);
|
||||
_externalToolsToolStrip.Visible = mRemoteNG.Settings.Default.ExtAppsTBVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock);
|
||||
toolStripPanel.Join(_externalToolsToolStrip, mRemoteNG.Settings.Default.ExtAppsTBLocation);
|
||||
}
|
||||
|
||||
private void AddMultiSshPanel()
|
||||
{
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock);
|
||||
toolStripPanel.Join(_multiSshToolStrip, mRemoteNG.Settings.Default.MultiSshToolbarLocation);
|
||||
SetToolstripGripStyle(_multiSshToolStrip);
|
||||
_multiSshToolStrip.Visible = mRemoteNG.Settings.Default.MultiSshToolbarVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.MultiSshToolbarParentDock);
|
||||
toolStripPanel.Join(_multiSshToolStrip, mRemoteNG.Settings.Default.MultiSshToolbarLocation);
|
||||
}
|
||||
|
||||
private void SetToolstripGripStyle(ToolStrip toolbar)
|
||||
{
|
||||
toolbar.GripStyle = mRemoteNG.Settings.Default.LockToolbars
|
||||
? ToolStripGripStyle.Hidden
|
||||
: ToolStripGripStyle.Visible;
|
||||
}
|
||||
|
||||
private ToolStripPanel ToolStripPanelFromString(string panel)
|
||||
{
|
||||
switch (panel.ToLower())
|
||||
{
|
||||
case "top":
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
return _frmMain.tsContainer.TopToolStripPanel;
|
||||
case "bottom":
|
||||
return MainForm.tsContainer.BottomToolStripPanel;
|
||||
return _frmMain.tsContainer.BottomToolStripPanel;
|
||||
case "left":
|
||||
return MainForm.tsContainer.LeftToolStripPanel;
|
||||
return _frmMain.tsContainer.LeftToolStripPanel;
|
||||
case "right":
|
||||
return MainForm.tsContainer.RightToolStripPanel;
|
||||
return _frmMain.tsContainer.RightToolStripPanel;
|
||||
default:
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
return _frmMain.tsContainer.TopToolStripPanel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,4 +273,4 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,20 @@ using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
public static class SettingsSaver
|
||||
public class SettingsSaver
|
||||
{
|
||||
public static void SaveSettings(
|
||||
private readonly ExternalToolsService _externalToolsService;
|
||||
|
||||
public SettingsSaver(ExternalToolsService externalToolsService)
|
||||
{
|
||||
_externalToolsService = externalToolsService.ThrowIfNull(nameof(externalToolsService));
|
||||
}
|
||||
|
||||
public void SaveSettings(
|
||||
Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
@@ -19,7 +27,7 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
try
|
||||
{
|
||||
var windowPlacement = new WindowPlacement(FrmMain.Default);
|
||||
var windowPlacement = new WindowPlacement(frmMain);
|
||||
if (frmMain.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized)
|
||||
{
|
||||
frmMain.Opacity = 0;
|
||||
@@ -53,7 +61,7 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
mRemoteNG.Settings.Default.Save();
|
||||
|
||||
SaveDockPanelLayout();
|
||||
SaveDockPanelLayout(frmMain.pnlDock);
|
||||
SaveExternalApps();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -62,7 +70,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExternalAppsToolbarLocation(ExternalToolsToolStrip externalToolsToolStrip)
|
||||
private void SaveExternalAppsToolbarLocation(ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.ExtAppsTBLocation = externalToolsToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.ExtAppsTBVisible = externalToolsToolStrip.Visible;
|
||||
@@ -74,7 +82,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveQuickConnectToolbarLocation(Control quickConnectToolStrip)
|
||||
private void SaveQuickConnectToolbarLocation(Control quickConnectToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.QuickyTBLocation = quickConnectToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.QuickyTBVisible = quickConnectToolStrip.Visible;
|
||||
@@ -85,7 +93,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveMultiSshToolbarLocation(MultiSshToolStrip multiSshToolStrip)
|
||||
private void SaveMultiSshToolbarLocation(MultiSshToolStrip multiSshToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.MultiSshToolbarLocation = multiSshToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.MultiSshToolbarVisible = multiSshToolStrip.Visible;
|
||||
@@ -96,20 +104,20 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveDockPanelLayout()
|
||||
private void SaveDockPanelLayout(DockPanel dockPanel)
|
||||
{
|
||||
var panelLayoutXmlFilePath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
var panelLayoutSaver = new DockPanelLayoutSaver(
|
||||
new DockPanelLayoutSerializer(),
|
||||
new FileDataProvider(panelLayoutXmlFilePath)
|
||||
);
|
||||
panelLayoutSaver.Save();
|
||||
panelLayoutSaver.Save(dockPanel);
|
||||
}
|
||||
|
||||
private static void SaveExternalApps()
|
||||
private void SaveExternalApps()
|
||||
{
|
||||
var externalAppsSaver = new ExternalAppsSaver();
|
||||
externalAppsSaver.Save(Runtime.ExternalToolsService.ExternalTools);
|
||||
externalAppsSaver.Save(_externalToolsService.ExternalTools);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ namespace mRemoteNG.Connection
|
||||
private bool _redirectKeys;
|
||||
private bool _redirectDiskDrives;
|
||||
private bool _redirectPrinters;
|
||||
private bool _redirectClipboard;
|
||||
private bool _redirectPorts;
|
||||
private bool _redirectSmartCards;
|
||||
private RdpProtocol.RDPSounds _redirectSound;
|
||||
@@ -87,8 +88,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionName")]
|
||||
public virtual string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { SetField(ref _name, value, "Name"); }
|
||||
get => _name;
|
||||
set => SetField(ref _name, value, "Name");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay"),
|
||||
@@ -96,8 +97,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDescription")]
|
||||
public virtual string Description
|
||||
{
|
||||
get { return GetPropertyValue("Description", _description); }
|
||||
set { SetField(ref _description, value, "Description"); }
|
||||
get => GetPropertyValue("Description", _description);
|
||||
set => SetField(ref _description, value, "Description");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay"),
|
||||
@@ -106,8 +107,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionIcon")]
|
||||
public virtual string Icon
|
||||
{
|
||||
get { return GetPropertyValue("Icon", _icon); }
|
||||
set { SetField(ref _icon, value, "Icon"); }
|
||||
get => GetPropertyValue("Icon", _icon);
|
||||
set => SetField(ref _icon, value, "Icon");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryDisplay"),
|
||||
@@ -115,8 +116,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPanel")]
|
||||
public virtual string Panel
|
||||
{
|
||||
get { return GetPropertyValue("Panel", _panel); }
|
||||
set { SetField(ref _panel, value, "Panel"); }
|
||||
get => GetPropertyValue("Panel", _panel);
|
||||
set => SetField(ref _panel, value, "Panel");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -126,8 +127,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionAddress")]
|
||||
public virtual string Hostname
|
||||
{
|
||||
get { return _hostname.Trim(); }
|
||||
set { SetField(ref _hostname, value?.Trim(), "Hostname"); }
|
||||
get => _hostname.Trim();
|
||||
set => SetField(ref _hostname, value?.Trim(), "Hostname");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
|
||||
@@ -135,8 +136,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUsername")]
|
||||
public virtual string Username
|
||||
{
|
||||
get { return GetPropertyValue("Username", _username); }
|
||||
set { SetField(ref _username, value?.Trim(), "Username"); }
|
||||
get => GetPropertyValue("Username", _username);
|
||||
set => SetField(ref _username, value?.Trim(), "Username");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
|
||||
@@ -145,8 +146,8 @@ namespace mRemoteNG.Connection
|
||||
PasswordPropertyText(true)]
|
||||
public virtual string Password
|
||||
{
|
||||
get { return GetPropertyValue("Password", _password); }
|
||||
set { SetField(ref _password, value, "Password"); }
|
||||
get => GetPropertyValue("Password", _password);
|
||||
set => SetField(ref _password, value, "Password");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
|
||||
@@ -154,8 +155,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionDomain")]
|
||||
public string Domain
|
||||
{
|
||||
get { return GetPropertyValue("Domain", _domain).Trim(); }
|
||||
set { SetField(ref _domain, value?.Trim(), "Domain"); }
|
||||
get => GetPropertyValue("Domain", _domain).Trim();
|
||||
set => SetField(ref _domain, value?.Trim(), "Domain");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -166,8 +167,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public virtual ProtocolType Protocol
|
||||
{
|
||||
get { return GetPropertyValue("Protocol", _protocol); }
|
||||
set { SetField(ref _protocol, value, "Protocol"); }
|
||||
get => GetPropertyValue("Protocol", _protocol);
|
||||
set => SetField(ref _protocol, value, "Protocol");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -176,8 +177,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(ExternalToolsTypeConverter))]
|
||||
public string ExtApp
|
||||
{
|
||||
get { return GetPropertyValue("ExtApp", _extApp); }
|
||||
set { SetField(ref _extApp, value, "ExtApp"); }
|
||||
get => GetPropertyValue("ExtApp", _extApp);
|
||||
set => SetField(ref _extApp, value, "ExtApp");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -185,8 +186,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPort")]
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetPropertyValue("Port", _port); }
|
||||
set { SetField(ref _port, value, "Port"); }
|
||||
get => GetPropertyValue("Port", _port);
|
||||
set => SetField(ref _port, value, "Port");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -195,8 +196,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(Config.Putty.PuttySessionsManager.SessionList))]
|
||||
public virtual string PuttySession
|
||||
{
|
||||
get { return GetPropertyValue("PuttySession", _puttySession); }
|
||||
set { SetField(ref _puttySession, value, "PuttySession"); }
|
||||
get => GetPropertyValue("PuttySession", _puttySession);
|
||||
set => SetField(ref _puttySession, value, "PuttySession");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -205,8 +206,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public IcaProtocol.EncryptionStrength ICAEncryptionStrength
|
||||
{
|
||||
get { return GetPropertyValue("ICAEncryptionStrength", _icaEncryption); }
|
||||
set { SetField(ref _icaEncryption, value, "ICAEncryptionStrength"); }
|
||||
get => GetPropertyValue("ICAEncryptionStrength", _icaEncryption);
|
||||
set => SetField(ref _icaEncryption, value, "ICAEncryptionStrength");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -215,8 +216,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool UseConsoleSession
|
||||
{
|
||||
get { return GetPropertyValue("UseConsoleSession", _useConsoleSession); }
|
||||
set { SetField(ref _useConsoleSession, value, "UseConsoleSession"); }
|
||||
get => GetPropertyValue("UseConsoleSession", _useConsoleSession);
|
||||
set => SetField(ref _useConsoleSession, value, "UseConsoleSession");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -225,8 +226,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.AuthenticationLevel RDPAuthenticationLevel
|
||||
{
|
||||
get { return GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel); }
|
||||
set { SetField(ref _rdpAuthenticationLevel, value, "RDPAuthenticationLevel"); }
|
||||
get => GetPropertyValue("RDPAuthenticationLevel", _rdpAuthenticationLevel);
|
||||
set => SetField(ref _rdpAuthenticationLevel, value, "RDPAuthenticationLevel");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -234,7 +235,7 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDPMinutesToIdleTimeout")]
|
||||
public virtual int RDPMinutesToIdleTimeout
|
||||
{
|
||||
get { return GetPropertyValue("RDPMinutesToIdleTimeout", _rdpMinutesToIdleTimeout); }
|
||||
get => GetPropertyValue("RDPMinutesToIdleTimeout", _rdpMinutesToIdleTimeout);
|
||||
set {
|
||||
if(value < 0)
|
||||
value = 0;
|
||||
@@ -249,8 +250,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDPAlertIdleTimeout")]
|
||||
public bool RDPAlertIdleTimeout
|
||||
{
|
||||
get { return GetPropertyValue("RDPAlertIdleTimeout", _rdpAlertIdleTimeout); }
|
||||
set { SetField(ref _rdpAlertIdleTimeout, value, "RDPAlertIdleTimeout"); }
|
||||
get => GetPropertyValue("RDPAlertIdleTimeout", _rdpAlertIdleTimeout);
|
||||
set => SetField(ref _rdpAlertIdleTimeout, value, "RDPAlertIdleTimeout");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -258,8 +259,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionLoadBalanceInfo")]
|
||||
public string LoadBalanceInfo
|
||||
{
|
||||
get { return GetPropertyValue("LoadBalanceInfo", _loadBalanceInfo).Trim(); }
|
||||
set { SetField(ref _loadBalanceInfo, value?.Trim(), "LoadBalanceInfo"); }
|
||||
get => GetPropertyValue("LoadBalanceInfo", _loadBalanceInfo).Trim();
|
||||
set => SetField(ref _loadBalanceInfo, value?.Trim(), "LoadBalanceInfo");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -268,8 +269,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public HTTPBase.RenderingEngine RenderingEngine
|
||||
{
|
||||
get { return GetPropertyValue("RenderingEngine", _renderingEngine); }
|
||||
set { SetField(ref _renderingEngine, value, "RenderingEngine"); }
|
||||
get => GetPropertyValue("RenderingEngine", _renderingEngine);
|
||||
set => SetField(ref _renderingEngine, value, "RenderingEngine");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 3),
|
||||
@@ -278,8 +279,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool UseCredSsp
|
||||
{
|
||||
get { return GetPropertyValue("UseCredSsp", _useCredSsp); }
|
||||
set { SetField(ref _useCredSsp, value, "UseCredSsp"); }
|
||||
get => GetPropertyValue("UseCredSsp", _useCredSsp);
|
||||
set => SetField(ref _useCredSsp, value, "UseCredSsp");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -290,8 +291,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDGatewayUsageMethod RDGatewayUsageMethod
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod); }
|
||||
set { SetField(ref _rdGatewayUsageMethod, value, "RDGatewayUsageMethod"); }
|
||||
get => GetPropertyValue("RDGatewayUsageMethod", _rdGatewayUsageMethod);
|
||||
set => SetField(ref _rdGatewayUsageMethod, value, "RDGatewayUsageMethod");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
|
||||
@@ -299,8 +300,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayHostname")]
|
||||
public string RDGatewayHostname
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayHostname", _rdGatewayHostname).Trim(); }
|
||||
set { SetField(ref _rdGatewayHostname, value?.Trim(), "RDGatewayHostname"); }
|
||||
get => GetPropertyValue("RDGatewayHostname", _rdGatewayHostname).Trim();
|
||||
set => SetField(ref _rdGatewayHostname, value?.Trim(), "RDGatewayHostname");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
|
||||
@@ -309,8 +310,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDGatewayUseConnectionCredentials RDGatewayUseConnectionCredentials
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials); }
|
||||
set { SetField(ref _rdGatewayUseConnectionCredentials, value, "RDGatewayUseConnectionCredentials"); }
|
||||
get => GetPropertyValue("RDGatewayUseConnectionCredentials", _rdGatewayUseConnectionCredentials);
|
||||
set => SetField(ref _rdGatewayUseConnectionCredentials, value, "RDGatewayUseConnectionCredentials");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
|
||||
@@ -318,8 +319,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayUsername")]
|
||||
public string RDGatewayUsername
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayUsername", _rdGatewayUsername).Trim(); }
|
||||
set { SetField(ref _rdGatewayUsername, value?.Trim(), "RDGatewayUsername"); }
|
||||
get => GetPropertyValue("RDGatewayUsername", _rdGatewayUsername).Trim();
|
||||
set => SetField(ref _rdGatewayUsername, value?.Trim(), "RDGatewayUsername");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
|
||||
@@ -328,8 +329,8 @@ namespace mRemoteNG.Connection
|
||||
PasswordPropertyText(true)]
|
||||
public string RDGatewayPassword
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayPassword", _rdGatewayPassword); }
|
||||
set { SetField(ref _rdGatewayPassword, value, "RDGatewayPassword"); }
|
||||
get => GetPropertyValue("RDGatewayPassword", _rdGatewayPassword);
|
||||
set => SetField(ref _rdGatewayPassword, value, "RDGatewayPassword");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryGateway", 4),
|
||||
@@ -337,8 +338,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRDGatewayDomain")]
|
||||
public string RDGatewayDomain
|
||||
{
|
||||
get { return GetPropertyValue("RDGatewayDomain", _rdGatewayDomain).Trim(); }
|
||||
set { SetField(ref _rdGatewayDomain, value?.Trim(), "RDGatewayDomain"); }
|
||||
get => GetPropertyValue("RDGatewayDomain", _rdGatewayDomain).Trim();
|
||||
set => SetField(ref _rdGatewayDomain, value?.Trim(), "RDGatewayDomain");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -349,8 +350,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDPResolutions Resolution
|
||||
{
|
||||
get { return GetPropertyValue("Resolution", _resolution); }
|
||||
set { SetField(ref _resolution, value, "Resolution"); }
|
||||
get => GetPropertyValue("Resolution", _resolution);
|
||||
set => SetField(ref _resolution, value, "Resolution");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -359,8 +360,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool AutomaticResize
|
||||
{
|
||||
get { return GetPropertyValue("AutomaticResize", _automaticResize); }
|
||||
set { SetField(ref _automaticResize, value, "AutomaticResize"); }
|
||||
get => GetPropertyValue("AutomaticResize", _automaticResize);
|
||||
set => SetField(ref _automaticResize, value, "AutomaticResize");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -369,8 +370,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDPColors Colors
|
||||
{
|
||||
get { return GetPropertyValue("Colors", _colors); }
|
||||
set { SetField(ref _colors, value, "Colors"); }
|
||||
get => GetPropertyValue("Colors", _colors);
|
||||
set => SetField(ref _colors, value, "Colors");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -379,8 +380,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool CacheBitmaps
|
||||
{
|
||||
get { return GetPropertyValue("CacheBitmaps", _cacheBitmaps); }
|
||||
set { SetField(ref _cacheBitmaps, value, "CacheBitmaps"); }
|
||||
get => GetPropertyValue("CacheBitmaps", _cacheBitmaps);
|
||||
set => SetField(ref _cacheBitmaps, value, "CacheBitmaps");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -389,8 +390,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool DisplayWallpaper
|
||||
{
|
||||
get { return GetPropertyValue("DisplayWallpaper", _displayWallpaper); }
|
||||
set { SetField(ref _displayWallpaper, value, "DisplayWallpaper"); }
|
||||
get => GetPropertyValue("DisplayWallpaper", _displayWallpaper);
|
||||
set => SetField(ref _displayWallpaper, value, "DisplayWallpaper");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -399,8 +400,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool DisplayThemes
|
||||
{
|
||||
get { return GetPropertyValue("DisplayThemes", _displayThemes); }
|
||||
set { SetField(ref _displayThemes, value, "DisplayThemes"); }
|
||||
get => GetPropertyValue("DisplayThemes", _displayThemes);
|
||||
set => SetField(ref _displayThemes, value, "DisplayThemes");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -409,8 +410,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool EnableFontSmoothing
|
||||
{
|
||||
get { return GetPropertyValue("EnableFontSmoothing", _enableFontSmoothing); }
|
||||
set { SetField(ref _enableFontSmoothing, value, "EnableFontSmoothing"); }
|
||||
get => GetPropertyValue("EnableFontSmoothing", _enableFontSmoothing);
|
||||
set => SetField(ref _enableFontSmoothing, value, "EnableFontSmoothing");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -419,8 +420,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool EnableDesktopComposition
|
||||
{
|
||||
get { return GetPropertyValue("EnableDesktopComposition", _enableDesktopComposition); }
|
||||
set { SetField(ref _enableDesktopComposition, value, "EnableDesktopComposition"); }
|
||||
get => GetPropertyValue("EnableDesktopComposition", _enableDesktopComposition);
|
||||
set => SetField(ref _enableDesktopComposition, value, "EnableDesktopComposition");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -431,8 +432,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectKeys
|
||||
{
|
||||
get { return GetPropertyValue("RedirectKeys", _redirectKeys); }
|
||||
set { SetField(ref _redirectKeys, value, "RedirectKeys"); }
|
||||
get => GetPropertyValue("RedirectKeys", _redirectKeys);
|
||||
set => SetField(ref _redirectKeys, value, "RedirectKeys");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -441,8 +442,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectDiskDrives
|
||||
{
|
||||
get { return GetPropertyValue("RedirectDiskDrives", _redirectDiskDrives); }
|
||||
set { SetField(ref _redirectDiskDrives, value, "RedirectDiskDrives"); }
|
||||
get => GetPropertyValue("RedirectDiskDrives", _redirectDiskDrives);
|
||||
set => SetField(ref _redirectDiskDrives, value, "RedirectDiskDrives");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -451,8 +452,18 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectPrinters
|
||||
{
|
||||
get { return GetPropertyValue("RedirectPrinters", _redirectPrinters); }
|
||||
set { SetField(ref _redirectPrinters, value, "RedirectPrinters"); }
|
||||
get => GetPropertyValue("RedirectPrinters", _redirectPrinters);
|
||||
set => SetField(ref _redirectPrinters, value, "RedirectPrinters");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
LocalizedAttributes.LocalizedDisplayName("strPropertyNameRedirectClipboard"),
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionRedirectClipboard"),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectClipboard
|
||||
{
|
||||
get { return GetPropertyValue("RedirectClipboard", _redirectClipboard); }
|
||||
set { SetField(ref _redirectClipboard, value, "RedirectClipboard"); }
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -461,8 +472,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectPorts
|
||||
{
|
||||
get { return GetPropertyValue("RedirectPorts", _redirectPorts); }
|
||||
set { SetField(ref _redirectPorts, value, "RedirectPorts"); }
|
||||
get => GetPropertyValue("RedirectPorts", _redirectPorts);
|
||||
set => SetField(ref _redirectPorts, value, "RedirectPorts");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -471,8 +482,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool RedirectSmartCards
|
||||
{
|
||||
get { return GetPropertyValue("RedirectSmartCards", _redirectSmartCards); }
|
||||
set { SetField(ref _redirectSmartCards, value, "RedirectSmartCards"); }
|
||||
get => GetPropertyValue("RedirectSmartCards", _redirectSmartCards);
|
||||
set => SetField(ref _redirectSmartCards, value, "RedirectSmartCards");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -481,8 +492,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDPSounds RedirectSound
|
||||
{
|
||||
get { return GetPropertyValue("RedirectSound", _redirectSound); }
|
||||
set { SetField(ref _redirectSound, value, "RedirectSound"); }
|
||||
get => GetPropertyValue("RedirectSound", _redirectSound);
|
||||
set => SetField(ref _redirectSound, value, "RedirectSound");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 6),
|
||||
@@ -491,8 +502,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public RdpProtocol.RDPSoundQuality SoundQuality
|
||||
{
|
||||
get { return GetPropertyValue("SoundQuality", _soundQuality); }
|
||||
set { SetField(ref _soundQuality, value, "SoundQuality"); }
|
||||
get => GetPropertyValue("SoundQuality", _soundQuality);
|
||||
set => SetField(ref _soundQuality, value, "SoundQuality");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -506,8 +517,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(ExternalToolsTypeConverter))]
|
||||
public virtual string PreExtApp
|
||||
{
|
||||
get { return GetPropertyValue("PreExtApp", _preExtApp); }
|
||||
set { SetField(ref _preExtApp, value, "PreExtApp"); }
|
||||
get => GetPropertyValue("PreExtApp", _preExtApp);
|
||||
set => SetField(ref _preExtApp, value, "PreExtApp");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -516,8 +527,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(ExternalToolsTypeConverter))]
|
||||
public virtual string PostExtApp
|
||||
{
|
||||
get { return GetPropertyValue("PostExtApp", _postExtApp); }
|
||||
set { SetField(ref _postExtApp, value, "PostExtApp"); }
|
||||
get => GetPropertyValue("PostExtApp", _postExtApp);
|
||||
set => SetField(ref _postExtApp, value, "PostExtApp");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -525,8 +536,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionMACAddress")]
|
||||
public virtual string MacAddress
|
||||
{
|
||||
get { return GetPropertyValue("MacAddress", _macAddress); }
|
||||
set { SetField(ref _macAddress, value, "MacAddress"); }
|
||||
get => GetPropertyValue("MacAddress", _macAddress);
|
||||
set => SetField(ref _macAddress, value, "MacAddress");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -534,8 +545,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionUser1")]
|
||||
public virtual string UserField
|
||||
{
|
||||
get { return GetPropertyValue("UserField", _userField); }
|
||||
set { SetField(ref _userField, value, "UserField"); }
|
||||
get => GetPropertyValue("UserField", _userField);
|
||||
set => SetField(ref _userField, value, "UserField");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -547,8 +558,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.Compression VNCCompression
|
||||
{
|
||||
get { return GetPropertyValue("VNCCompression", _vncCompression); }
|
||||
set { SetField(ref _vncCompression, value, "VNCCompression"); }
|
||||
get => GetPropertyValue("VNCCompression", _vncCompression);
|
||||
set => SetField(ref _vncCompression, value, "VNCCompression");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -558,8 +569,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.Encoding VNCEncoding
|
||||
{
|
||||
get { return GetPropertyValue("VNCEncoding", _vncEncoding); }
|
||||
set { SetField(ref _vncEncoding, value, "VNCEncoding"); }
|
||||
get => GetPropertyValue("VNCEncoding", _vncEncoding);
|
||||
set => SetField(ref _vncEncoding, value, "VNCEncoding");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryConnection", 2),
|
||||
@@ -569,8 +580,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.AuthMode VNCAuthMode
|
||||
{
|
||||
get { return GetPropertyValue("VNCAuthMode", _vncAuthMode); }
|
||||
set { SetField(ref _vncAuthMode, value, "VNCAuthMode"); }
|
||||
get => GetPropertyValue("VNCAuthMode", _vncAuthMode);
|
||||
set => SetField(ref _vncAuthMode, value, "VNCAuthMode");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -580,8 +591,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.ProxyType VNCProxyType
|
||||
{
|
||||
get { return GetPropertyValue("VNCProxyType", _vncProxyType); }
|
||||
set { SetField(ref _vncProxyType, value, "VNCProxyType"); }
|
||||
get => GetPropertyValue("VNCProxyType", _vncProxyType);
|
||||
set => SetField(ref _vncProxyType, value, "VNCProxyType");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -590,8 +601,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyAddress")]
|
||||
public string VNCProxyIP
|
||||
{
|
||||
get { return GetPropertyValue("VNCProxyIP", _vncProxyIp); }
|
||||
set { SetField(ref _vncProxyIp, value, "VNCProxyIP"); }
|
||||
get => GetPropertyValue("VNCProxyIP", _vncProxyIp);
|
||||
set => SetField(ref _vncProxyIp, value, "VNCProxyIP");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -600,8 +611,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyPort")]
|
||||
public int VNCProxyPort
|
||||
{
|
||||
get { return GetPropertyValue("VNCProxyPort", _vncProxyPort); }
|
||||
set { SetField(ref _vncProxyPort, value, "VNCProxyPort"); }
|
||||
get => GetPropertyValue("VNCProxyPort", _vncProxyPort);
|
||||
set => SetField(ref _vncProxyPort, value, "VNCProxyPort");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -610,8 +621,8 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDescription("strPropertyDescriptionVNCProxyUsername")]
|
||||
public string VNCProxyUsername
|
||||
{
|
||||
get { return GetPropertyValue("VNCProxyUsername", _vncProxyUsername); }
|
||||
set { SetField(ref _vncProxyUsername, value, "VNCProxyUsername"); }
|
||||
get => GetPropertyValue("VNCProxyUsername", _vncProxyUsername);
|
||||
set => SetField(ref _vncProxyUsername, value, "VNCProxyUsername");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryMiscellaneous", 7),
|
||||
@@ -621,8 +632,8 @@ namespace mRemoteNG.Connection
|
||||
PasswordPropertyText(true)]
|
||||
public string VNCProxyPassword
|
||||
{
|
||||
get { return GetPropertyValue("VNCProxyPassword", _vncProxyPassword); }
|
||||
set { SetField(ref _vncProxyPassword, value, "VNCProxyPassword"); }
|
||||
get => GetPropertyValue("VNCProxyPassword", _vncProxyPassword);
|
||||
set => SetField(ref _vncProxyPassword, value, "VNCProxyPassword");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -632,8 +643,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.Colors VNCColors
|
||||
{
|
||||
get { return GetPropertyValue("VNCColors", _vncColors); }
|
||||
set { SetField(ref _vncColors, value, "VNCColors"); }
|
||||
get => GetPropertyValue("VNCColors", _vncColors);
|
||||
set => SetField(ref _vncColors, value, "VNCColors");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -642,8 +653,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.EnumTypeConverter))]
|
||||
public ProtocolVNC.SmartSizeMode VNCSmartSizeMode
|
||||
{
|
||||
get { return GetPropertyValue("VNCSmartSizeMode", _vncSmartSizeMode); }
|
||||
set { SetField(ref _vncSmartSizeMode, value, "VNCSmartSizeMode"); }
|
||||
get => GetPropertyValue("VNCSmartSizeMode", _vncSmartSizeMode);
|
||||
set => SetField(ref _vncSmartSizeMode, value, "VNCSmartSizeMode");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryAppearance", 5),
|
||||
@@ -652,8 +663,8 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
public bool VNCViewOnly
|
||||
{
|
||||
get { return GetPropertyValue("VNCViewOnly", _vncViewOnly); }
|
||||
set { SetField(ref _vncViewOnly, value, "VNCViewOnly"); }
|
||||
get => GetPropertyValue("VNCViewOnly", _vncViewOnly);
|
||||
set => SetField(ref _vncViewOnly, value, "VNCViewOnly");
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
@@ -665,7 +676,7 @@ namespace mRemoteNG.Connection
|
||||
|
||||
protected virtual TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
|
||||
{
|
||||
return (TPropertyType)GetType().GetProperty(propertyName).GetValue(this, null);
|
||||
return (TPropertyType)GetType().GetProperty(propertyName)?.GetValue(this, null);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
@@ -674,12 +685,11 @@ namespace mRemoteNG.Connection
|
||||
PropertyChanged?.Invoke(sender, new PropertyChangedEventArgs(args.PropertyName));
|
||||
}
|
||||
|
||||
protected bool SetField<T>(ref T field, T value, string propertyName = null)
|
||||
private void SetField<T>(ref T field, T value, string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return;
|
||||
field = value;
|
||||
RaisePropertyChangedEvent(this, new PropertyChangedEventArgs(propertyName));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
@@ -15,12 +10,16 @@ using mRemoteNG.Connection.Protocol.Telnet;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
[DefaultProperty("Name")]
|
||||
[DefaultProperty("Name")]
|
||||
public class ConnectionInfo : AbstractConnectionRecord, IHasParent, IInheritable
|
||||
{
|
||||
#region Public Properties
|
||||
@@ -79,7 +78,8 @@ namespace mRemoteNG.Connection
|
||||
var newConnectionInfo = new ConnectionInfo();
|
||||
newConnectionInfo.CopyFrom(this);
|
||||
newConnectionInfo.Inheritance = Inheritance.Clone();
|
||||
return newConnectionInfo;
|
||||
newConnectionInfo.Inheritance.Parent = newConnectionInfo;
|
||||
return newConnectionInfo;
|
||||
}
|
||||
|
||||
public void CopyFrom(ConnectionInfo sourceConnectionInfo)
|
||||
@@ -127,6 +127,14 @@ namespace mRemoteNG.Connection
|
||||
return filteredProperties;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<PropertyInfo> GetSerializableProperties()
|
||||
{
|
||||
var excludedProperties = new[] { "Parent", "Name", "Hostname", "Port", "Inheritance", "OpenConnections",
|
||||
"IsContainer", "IsDefault", "PositionID", "ConstantID", "TreeNode", "IsQuickConnect", "PleaseConnect" };
|
||||
|
||||
return GetProperties(excludedProperties);
|
||||
}
|
||||
|
||||
public virtual void SetParent(ContainerInfo newParent)
|
||||
{
|
||||
RemoveParent();
|
||||
@@ -165,10 +173,11 @@ namespace mRemoteNG.Connection
|
||||
if (!ShouldThisPropertyBeInherited(propertyName))
|
||||
return value;
|
||||
|
||||
var inheritedValue = GetInheritedPropertyValue<TPropertyType>(propertyName);
|
||||
if (inheritedValue.Equals(default(TPropertyType)))
|
||||
return value;
|
||||
return inheritedValue;
|
||||
var couldGetInheritedValue = TryGetInheritedPropertyValue<TPropertyType>(propertyName, out var inheritedValue);
|
||||
|
||||
return couldGetInheritedValue
|
||||
? inheritedValue
|
||||
: value;
|
||||
}
|
||||
|
||||
private bool ShouldThisPropertyBeInherited(string propertyName)
|
||||
@@ -189,22 +198,23 @@ namespace mRemoteNG.Connection
|
||||
return inheritPropertyValue;
|
||||
}
|
||||
|
||||
private TPropertyType GetInheritedPropertyValue<TPropertyType>(string propertyName)
|
||||
private bool TryGetInheritedPropertyValue<TPropertyType>(string propertyName, out TPropertyType inheritedValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var connectionInfoType = Parent.GetType();
|
||||
var parentPropertyInfo = connectionInfoType.GetProperty(propertyName);
|
||||
if (parentPropertyInfo == null)
|
||||
return default(TPropertyType); // shouldn't get here...
|
||||
var parentPropertyValue = (TPropertyType)parentPropertyInfo.GetValue(Parent, null);
|
||||
throw new NullReferenceException($"Could not retrieve property data for property '{propertyName}' on parent node '{Parent?.Name}'");
|
||||
|
||||
return parentPropertyValue;
|
||||
inheritedValue = (TPropertyType)parentPropertyInfo.GetValue(Parent, null);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Error retrieving inherited property '{propertyName}'", e);
|
||||
return default(TPropertyType);
|
||||
inheritedValue = default(TPropertyType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +313,10 @@ namespace mRemoteNG.Connection
|
||||
RedirectKeys = Settings.Default.ConDefaultRedirectKeys;
|
||||
RedirectDiskDrives = Settings.Default.ConDefaultRedirectDiskDrives;
|
||||
RedirectPrinters = Settings.Default.ConDefaultRedirectPrinters;
|
||||
RedirectClipboard = Settings.Default.ConDefaultRedirectClipboard;
|
||||
RedirectPorts = Settings.Default.ConDefaultRedirectPorts;
|
||||
RedirectSmartCards = Settings.Default.ConDefaultRedirectSmartCards;
|
||||
RedirectSound = (RdpProtocol.RDPSounds) Enum.Parse(typeof(RdpProtocol.RDPSounds), Settings.Default.ConDefaultRedirectSound);
|
||||
RedirectSound = (RdpProtocol.RDPSounds) Enum.Parse(typeof(RdpProtocol.RDPSounds), Settings.Default.ConDefaultRedirectSound);
|
||||
SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), Settings.Default.ConDefaultSoundQuality);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,8 +215,13 @@ namespace mRemoteNG.Connection
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameRedirectPrinters"),
|
||||
LocalizedAttributes.LocalizedDescriptionInheritAttribute("strPropertyDescriptionRedirectPrinters"),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool RedirectPrinters {get; set;}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 7),
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 7),
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameRedirectClipboard"),
|
||||
LocalizedAttributes.LocalizedDescriptionInheritAttribute("strPropertyDescriptionRedirectClipboard"),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool RedirectClipboard { get; set; }
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryRedirect", 7),
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameRedirectPorts"),
|
||||
LocalizedAttributes.LocalizedDescriptionInheritAttribute("strPropertyDescriptionRedirectPorts"),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool RedirectPorts {get; set;}
|
||||
|
||||
@@ -5,6 +5,8 @@ using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Panels;
|
||||
using mRemoteNG.UI.Window;
|
||||
@@ -14,8 +16,25 @@ using TabPage = Crownwood.Magic.Controls.TabPage;
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public class ConnectionInitiator : IConnectionInitiator
|
||||
{
|
||||
private readonly PanelAdder _panelAdder = new PanelAdder();
|
||||
{
|
||||
private readonly WindowList _windowList;
|
||||
private readonly ExternalToolsService _externalToolsService;
|
||||
private readonly ProtocolFactory _protocolFactory;
|
||||
private readonly FrmMain _frmMain;
|
||||
|
||||
/// <summary>
|
||||
/// This is a property because we have a circular dependency.
|
||||
/// </summary>
|
||||
public PanelAdder Adder { get; set; }
|
||||
|
||||
|
||||
public ConnectionInitiator(WindowList windowList, ExternalToolsService externalToolsService, ProtocolFactory protocolFactory, FrmMain frmMain)
|
||||
{
|
||||
_frmMain = frmMain;
|
||||
_windowList = windowList.ThrowIfNull(nameof(windowList));
|
||||
_externalToolsService = externalToolsService.ThrowIfNull(nameof(externalToolsService));
|
||||
_protocolFactory = protocolFactory.ThrowIfNull(nameof(protocolFactory));
|
||||
}
|
||||
|
||||
public void OpenConnection(ContainerInfo containerInfo, ConnectionInfo.Force force = ConnectionInfo.Force.None)
|
||||
{
|
||||
@@ -53,7 +72,7 @@ namespace mRemoteNG.Connection
|
||||
var connectionWindow = (ConnectionWindow)interfaceControl.FindForm();
|
||||
connectionWindow?.Focus();
|
||||
var findForm = (ConnectionWindow)interfaceControl.FindForm();
|
||||
findForm?.Show(FrmMain.Default.pnlDock);
|
||||
findForm?.Show(_frmMain.pnlDock);
|
||||
var tabPage = (TabPage)interfaceControl.Parent;
|
||||
tabPage.Selected = true;
|
||||
return true;
|
||||
@@ -92,10 +111,10 @@ namespace mRemoteNG.Connection
|
||||
return;
|
||||
}
|
||||
|
||||
var protocolFactory = new ProtocolFactory();
|
||||
var newProtocol = protocolFactory.CreateProtocol(connectionInfo);
|
||||
var newProtocol = _protocolFactory.CreateProtocol(connectionInfo);
|
||||
|
||||
var connectionPanel = SetConnectionPanel(connectionInfo, force);
|
||||
if (string.IsNullOrEmpty(connectionPanel)) return;
|
||||
var connectionForm = SetConnectionForm(conForm, connectionPanel);
|
||||
var connectionContainer = SetConnectionContainer(connectionInfo, connectionForm);
|
||||
SetConnectionFormEventHandlers(newProtocol, connectionForm);
|
||||
@@ -117,7 +136,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
|
||||
connectionInfo.OpenConnections.Add(newProtocol);
|
||||
FrmMain.Default.SelectedConnection = connectionInfo;
|
||||
_frmMain.SelectedConnection = connectionInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -125,19 +144,19 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
}
|
||||
|
||||
private static void StartPreConnectionExternalApp(ConnectionInfo connectionInfo)
|
||||
private void StartPreConnectionExternalApp(ConnectionInfo connectionInfo)
|
||||
{
|
||||
if (connectionInfo.PreExtApp == "") return;
|
||||
var extA = Runtime.ExternalToolsService.GetExtAppByName(connectionInfo.PreExtApp);
|
||||
var extA = _externalToolsService.GetExtAppByName(connectionInfo.PreExtApp);
|
||||
extA?.Start(connectionInfo);
|
||||
}
|
||||
|
||||
private static InterfaceControl FindConnectionContainer(ConnectionInfo connectionInfo)
|
||||
private InterfaceControl FindConnectionContainer(ConnectionInfo connectionInfo)
|
||||
{
|
||||
if (connectionInfo.OpenConnections.Count <= 0) return null;
|
||||
for (var i = 0; i <= Runtime.WindowList.Count - 1; i++)
|
||||
for (var i = 0; i <= _windowList.Count - 1; i++)
|
||||
{
|
||||
var window = Runtime.WindowList[i] as ConnectionWindow;
|
||||
var window = _windowList[i] as ConnectionWindow;
|
||||
var connectionWindow = window;
|
||||
if (connectionWindow?.TabController == null) continue;
|
||||
foreach (TabPage t in connectionWindow.TabController.TabPages)
|
||||
@@ -153,16 +172,20 @@ namespace mRemoteNG.Connection
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string SetConnectionPanel(ConnectionInfo connectionInfo, ConnectionInfo.Force force)
|
||||
private string SetConnectionPanel(ConnectionInfo connectionInfo, ConnectionInfo.Force force)
|
||||
{
|
||||
var connectionPanel = "";
|
||||
if (connectionInfo.Panel == "" || (force & ConnectionInfo.Force.OverridePanel) == ConnectionInfo.Force.OverridePanel | Settings.Default.AlwaysShowPanelSelectionDlg)
|
||||
{
|
||||
var frmPnl = new frmChoosePanel();
|
||||
var frmPnl = new frmChoosePanel(Adder, _windowList);
|
||||
if (frmPnl.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
connectionPanel = frmPnl.Panel;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,24 +196,24 @@ namespace mRemoteNG.Connection
|
||||
|
||||
private Form SetConnectionForm(Form conForm, string connectionPanel)
|
||||
{
|
||||
var connectionForm = conForm ?? Runtime.WindowList.FromString(connectionPanel);
|
||||
var connectionForm = conForm ?? _windowList.FromString(connectionPanel);
|
||||
|
||||
if (connectionForm == null)
|
||||
connectionForm = _panelAdder.AddPanel(connectionPanel);
|
||||
connectionForm = Adder.AddPanel(connectionPanel);
|
||||
else
|
||||
((ConnectionWindow)connectionForm).Show(FrmMain.Default.pnlDock);
|
||||
((ConnectionWindow)connectionForm).Show(_frmMain.pnlDock);
|
||||
|
||||
connectionForm.Focus();
|
||||
return connectionForm;
|
||||
}
|
||||
|
||||
private static Control SetConnectionContainer(ConnectionInfo connectionInfo, Form connectionForm)
|
||||
private Control SetConnectionContainer(ConnectionInfo connectionInfo, Form connectionForm)
|
||||
{
|
||||
Control connectionContainer = ((ConnectionWindow)connectionForm).AddConnectionTab(connectionInfo);
|
||||
|
||||
if (connectionInfo.Protocol != ProtocolType.IntApp) return connectionContainer;
|
||||
|
||||
var extT = Runtime.ExternalToolsService.GetExtAppByName(connectionInfo.ExtApp);
|
||||
var extT = _externalToolsService.GetExtAppByName(connectionInfo.ExtApp);
|
||||
|
||||
if(extT == null) return connectionContainer;
|
||||
|
||||
@@ -205,7 +228,7 @@ namespace mRemoteNG.Connection
|
||||
newProtocol.Closed += ((ConnectionWindow)connectionForm).Prot_Event_Closed;
|
||||
}
|
||||
|
||||
private static void SetConnectionEventHandlers(ProtocolBase newProtocol)
|
||||
private void SetConnectionEventHandlers(ProtocolBase newProtocol)
|
||||
{
|
||||
newProtocol.Disconnected += Prot_Event_Disconnected;
|
||||
newProtocol.Connected += Prot_Event_Connected;
|
||||
@@ -246,7 +269,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
}
|
||||
|
||||
private static void Prot_Event_Closed(object sender)
|
||||
private void Prot_Event_Closed(object sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -264,7 +287,7 @@ namespace mRemoteNG.Connection
|
||||
prot.InterfaceControl.Info.OpenConnections.Remove(prot);
|
||||
|
||||
if (prot.InterfaceControl.Info.PostExtApp == "") return;
|
||||
var extA = Runtime.ExternalToolsService.GetExtAppByName(prot.InterfaceControl.Info.PostExtApp);
|
||||
var extA = _externalToolsService.GetExtAppByName(prot.InterfaceControl.Info.PostExtApp);
|
||||
extA?.Start(prot.InterfaceControl.Info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,55 +1,62 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Config.Connections.Multiuser;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public class ConnectionsService
|
||||
public class ConnectionsService : IConnectionsService
|
||||
{
|
||||
private static readonly object SaveLock = new object();
|
||||
private bool _showDialogWhenLoadingConnections;
|
||||
private readonly PuttySessionsManager _puttySessionsManager;
|
||||
private readonly Import _import;
|
||||
private readonly IWin32Window _dialogWindowParent;
|
||||
private bool _batchingSaves = false;
|
||||
private bool _saveRequested = false;
|
||||
private bool _saveAsyncRequested = false;
|
||||
|
||||
public bool IsConnectionsFileLoaded { get; set; }
|
||||
public bool UsingDatabase { get; private set; }
|
||||
public string ConnectionFileName { get; private set; }
|
||||
public RemoteConnectionsSyncronizer RemoteConnectionsSyncronizer { get; set; }
|
||||
public DateTime LastSqlUpdate { get; set; }
|
||||
|
||||
public SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
// TODO - this is only a property to break up a circular dependency. move to ctor when able
|
||||
public DatabaseConnectorFactory DatabaseConnectorFactory { get; set; }
|
||||
public ConnectionTreeModel ConnectionTreeModel { get; private set; }
|
||||
//public ConnectionTreeModel ConnectionTreeModel
|
||||
//{
|
||||
// get { return Windows.TreeForm.ConnectionTree.ConnectionTreeModel; }
|
||||
// set { Windows.TreeForm.ConnectionTree.ConnectionTreeModel = value; }
|
||||
//}
|
||||
|
||||
public ConnectionsService(PuttySessionsManager puttySessionsManager)
|
||||
public ConnectionsService(PuttySessionsManager puttySessionsManager, Import import, IWin32Window dialogWindowParent)
|
||||
{
|
||||
if (puttySessionsManager == null)
|
||||
throw new ArgumentNullException(nameof(puttySessionsManager));
|
||||
|
||||
_puttySessionsManager = puttySessionsManager;
|
||||
_puttySessionsManager = puttySessionsManager.ThrowIfNull(nameof(puttySessionsManager));
|
||||
_import = import.ThrowIfNull(nameof(import));
|
||||
_dialogWindowParent = dialogWindowParent.ThrowIfNull(nameof(dialogWindowParent));
|
||||
}
|
||||
|
||||
public void NewConnectionsFile(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
filename.ThrowIfNullOrEmpty(nameof(filename));
|
||||
var newConnectionsModel = new ConnectionTreeModel();
|
||||
newConnectionsModel.AddRootNode(new RootNodeInfo(RootNodeType.Connection));
|
||||
SaveConnections(newConnectionsModel, false, new SaveFilter(), filename);
|
||||
SaveConnections(newConnectionsModel, false, new SaveFilter(), filename, true);
|
||||
LoadConnections(false, false, filename);
|
||||
UpdateCustomConsPathSetting(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -79,6 +86,10 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
newConnectionInfo.Port = uri.Port;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(newConnectionInfo.Panel))
|
||||
newConnectionInfo.Panel = Language.strGeneral;
|
||||
|
||||
newConnectionInfo.IsQuickConnect = true;
|
||||
|
||||
return newConnectionInfo;
|
||||
@@ -97,16 +108,24 @@ namespace mRemoteNG.Connection
|
||||
/// <param name="useDatabase"></param>
|
||||
/// <param name="import"></param>
|
||||
/// <param name="connectionFileName"></param>
|
||||
public ConnectionTreeModel LoadConnections(bool useDatabase, bool import, string connectionFileName)
|
||||
public void LoadConnections(bool useDatabase, bool import, string connectionFileName)
|
||||
{
|
||||
var oldConnectionTreeModel = ConnectionTreeModel;
|
||||
var oldIsUsingDatabaseValue = UsingDatabase;
|
||||
|
||||
var newConnectionTreeModel =
|
||||
(useDatabase
|
||||
? new SqlConnectionsLoader().Load()
|
||||
: new XmlConnectionsLoader(connectionFileName).Load())
|
||||
?? new ConnectionTreeModel();
|
||||
var newConnectionTreeModel = useDatabase
|
||||
? new SqlConnectionsLoader(DatabaseConnectorFactory, this).Load()
|
||||
: new XmlConnectionsLoader(connectionFileName, this, _dialogWindowParent).Load();
|
||||
|
||||
if (newConnectionTreeModel == null)
|
||||
{
|
||||
DialogFactory.ShowLoadConnectionsFailedDialog(connectionFileName, "Decrypting connection file failed", IsConnectionsFileLoaded, this);
|
||||
return;
|
||||
}
|
||||
|
||||
IsConnectionsFileLoaded = true;
|
||||
ConnectionFileName = connectionFileName;
|
||||
UsingDatabase = useDatabase;
|
||||
|
||||
if (!import)
|
||||
{
|
||||
@@ -114,12 +133,35 @@ namespace mRemoteNG.Connection
|
||||
newConnectionTreeModel.RootNodes.AddRange(_puttySessionsManager.RootPuttySessionsNodes);
|
||||
}
|
||||
|
||||
IsConnectionsFileLoaded = true;
|
||||
ConnectionFileName = connectionFileName;
|
||||
UsingDatabase = useDatabase;
|
||||
ConnectionTreeModel = newConnectionTreeModel;
|
||||
UpdateCustomConsPathSetting(connectionFileName);
|
||||
RaiseConnectionsLoadedEvent(oldConnectionTreeModel, newConnectionTreeModel, oldIsUsingDatabaseValue, useDatabase, connectionFileName);
|
||||
return newConnectionTreeModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When turned on, calls to <see cref="SaveConnections()"/> or
|
||||
/// <see cref="SaveConnectionsAsync"/> will not immediately execute.
|
||||
/// Instead, they will be deferred until <see cref="EndBatchingSaves"/>
|
||||
/// is called.
|
||||
/// </summary>
|
||||
public void BeginBatchingSaves()
|
||||
{
|
||||
_batchingSaves = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Immediately executes a single <see cref="SaveConnections()"/> or
|
||||
/// <see cref="SaveConnectionsAsync"/> if one has been requested
|
||||
/// since calling <see cref="BeginBatchingSaves"/>.
|
||||
/// </summary>
|
||||
public void EndBatchingSaves()
|
||||
{
|
||||
_batchingSaves = false;
|
||||
|
||||
if (_saveAsyncRequested)
|
||||
SaveConnectionsAsync();
|
||||
else if(_saveRequested)
|
||||
SaveConnections();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -128,8 +170,6 @@ namespace mRemoteNG.Connection
|
||||
/// </summary>
|
||||
public void SaveConnections()
|
||||
{
|
||||
if (!IsConnectionsFileLoaded)
|
||||
return;
|
||||
SaveConnections(ConnectionTreeModel, UsingDatabase, new SaveFilter(), ConnectionFileName);
|
||||
}
|
||||
|
||||
@@ -141,17 +181,29 @@ namespace mRemoteNG.Connection
|
||||
/// <param name="useDatabase"></param>
|
||||
/// <param name="saveFilter"></param>
|
||||
/// <param name="connectionFileName"></param>
|
||||
public void SaveConnections(ConnectionTreeModel connectionTreeModel, bool useDatabase, SaveFilter saveFilter, string connectionFileName)
|
||||
/// <param name="forceSave">Bypasses safety checks that prevent saving if a connection file isn't loaded.</param>
|
||||
public void SaveConnections(ConnectionTreeModel connectionTreeModel, bool useDatabase, SaveFilter saveFilter, string connectionFileName, bool forceSave = false)
|
||||
{
|
||||
if (connectionTreeModel == null) return;
|
||||
if (connectionTreeModel == null)
|
||||
return;
|
||||
|
||||
if (!forceSave && !IsConnectionsFileLoaded)
|
||||
return;
|
||||
|
||||
if (_batchingSaves)
|
||||
{
|
||||
_saveRequested = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Saving connections...");
|
||||
RemoteConnectionsSyncronizer?.Disable();
|
||||
|
||||
var previouslyUsingDatabase = UsingDatabase;
|
||||
if (useDatabase)
|
||||
new SqlConnectionsSaver(saveFilter).Save(connectionTreeModel);
|
||||
new SqlConnectionsSaver(saveFilter, this, DatabaseConnectorFactory).Save(connectionTreeModel);
|
||||
else
|
||||
new XmlConnectionsSaver(connectionFileName, saveFilter).Save(connectionTreeModel);
|
||||
|
||||
@@ -161,6 +213,7 @@ namespace mRemoteNG.Connection
|
||||
UsingDatabase = useDatabase;
|
||||
ConnectionFileName = connectionFileName;
|
||||
RaiseConnectionsSavedEvent(connectionTreeModel, previouslyUsingDatabase, UsingDatabase, connectionFileName);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Successfully saved connections");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -174,6 +227,12 @@ namespace mRemoteNG.Connection
|
||||
|
||||
public void SaveConnectionsAsync()
|
||||
{
|
||||
if (_batchingSaves)
|
||||
{
|
||||
_saveAsyncRequested = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var t = new Thread(SaveConnectionsBGd);
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
@@ -181,19 +240,175 @@ namespace mRemoteNG.Connection
|
||||
|
||||
private void SaveConnectionsBGd()
|
||||
{
|
||||
Monitor.Enter(SaveLock);
|
||||
SaveConnections();
|
||||
Monitor.Exit(SaveLock);
|
||||
lock (SaveLock)
|
||||
{
|
||||
SaveConnections();
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadConnectionsAsync()
|
||||
{
|
||||
_showDialogWhenLoadingConnections = false;
|
||||
|
||||
var t = new Thread(LoadConnectionsBGd);
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
}
|
||||
|
||||
|
||||
private void LoadConnectionsBGd()
|
||||
{
|
||||
LoadConnections(_showDialogWhenLoadingConnections);
|
||||
}
|
||||
|
||||
public void LoadConnections(bool withDialog = false)
|
||||
{
|
||||
var connectionFileName = "";
|
||||
|
||||
try
|
||||
{
|
||||
// disable sql update checking while we are loading updates
|
||||
RemoteConnectionsSyncronizer?.Disable();
|
||||
|
||||
if (!Settings.Default.UseSQLServer)
|
||||
{
|
||||
if (withDialog)
|
||||
{
|
||||
var loadDialog = DialogFactory.BuildLoadConnectionsDialog();
|
||||
if (loadDialog.ShowDialog() != DialogResult.OK) return;
|
||||
connectionFileName = loadDialog.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionFileName = GetStartupConnectionFileName();
|
||||
}
|
||||
}
|
||||
|
||||
LoadConnections(Settings.Default.UseSQLServer, false, connectionFileName);
|
||||
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
LastSqlUpdate = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connectionFileName == GetDefaultStartupConnectionFileName())
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Default.LoadConsFromCustomLocation = true;
|
||||
Settings.Default.CustomConsPath = connectionFileName;
|
||||
}
|
||||
}
|
||||
|
||||
// re-enable sql update checking after updates are loaded
|
||||
RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
Runtime.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);
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
LoadConnections(withDialog);
|
||||
return;
|
||||
case 1:
|
||||
Settings.Default.UseSQLServer = false;
|
||||
LoadConnections(true);
|
||||
return;
|
||||
default:
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ex is FileNotFoundException && !withDialog)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);
|
||||
|
||||
string[] commandButtons =
|
||||
{
|
||||
Language.ConfigurationCreateNew,
|
||||
Language.ConfigurationCustomPath,
|
||||
Language.ConfigurationImportFile,
|
||||
Language.strMenuExit
|
||||
};
|
||||
|
||||
var answered = false;
|
||||
while (!answered)
|
||||
{
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
NewConnectionsFile(connectionFileName);
|
||||
answered = true;
|
||||
break;
|
||||
case 1:
|
||||
LoadConnections(true);
|
||||
answered = true;
|
||||
break;
|
||||
case 2:
|
||||
NewConnectionsFile(connectionFileName);
|
||||
_import.ImportFromFile(ConnectionTreeModel.RootNodes[0]);
|
||||
answered = true;
|
||||
break;
|
||||
case 3:
|
||||
Application.Exit();
|
||||
answered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
|
||||
if (connectionFileName != GetStartupConnectionFileName())
|
||||
{
|
||||
LoadConnections(withDialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(_dialogWindowParent,
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetStartupConnectionFileName()
|
||||
{
|
||||
return Settings.Default.LoadConsFromCustomLocation == false ? GetDefaultStartupConnectionFileName() : Settings.Default.CustomConsPath;
|
||||
return Settings.Default.LoadConsFromCustomLocation == false
|
||||
? GetDefaultStartupConnectionFileName()
|
||||
: Settings.Default.CustomConsPath;
|
||||
}
|
||||
|
||||
public string GetDefaultStartupConnectionFileName()
|
||||
{
|
||||
return Runtime.IsPortableEdition ? GetDefaultStartupConnectionFileNamePortableEdition() : GetDefaultStartupConnectionFileNameNormalEdition();
|
||||
return Runtime.IsPortableEdition
|
||||
? GetDefaultStartupConnectionFileNamePortableEdition()
|
||||
: GetDefaultStartupConnectionFileNameNormalEdition();
|
||||
}
|
||||
|
||||
private void UpdateCustomConsPathSetting(string filename)
|
||||
|
||||
@@ -1,35 +1,44 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using mRemoteNG.App;
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public class DefaultConnectionInfo : ConnectionInfo
|
||||
public class DefaultConnectionInfo : ConnectionInfo
|
||||
{
|
||||
public static DefaultConnectionInfo Instance { get; } = new DefaultConnectionInfo();
|
||||
private readonly string[] _excludedProperties = { "Parent", "Name", "Hostname", "Port", "Inheritance",
|
||||
"OpenConnections", "IsContainer", "IsDefault", "PositionID", "ConstantID", "TreeNode", "IsQuickConnect", "PleaseConnect" };
|
||||
|
||||
private DefaultConnectionInfo()
|
||||
{
|
||||
IsDefault = true;
|
||||
Inheritance = DefaultConnectionInheritance.Instance;
|
||||
}
|
||||
|
||||
public void LoadFrom<TSource>(TSource sourceInstance, Func<string, string> propertyNameMutator = null)
|
||||
{
|
||||
if (propertyNameMutator == null) propertyNameMutator = a => a;
|
||||
var connectionProperties = GetProperties(_excludedProperties);
|
||||
if (propertyNameMutator == null)
|
||||
propertyNameMutator = a => a;
|
||||
|
||||
var connectionProperties = GetSerializableProperties();
|
||||
foreach (var property in connectionProperties)
|
||||
{
|
||||
try
|
||||
{
|
||||
var propertyFromSource = typeof(TSource).GetProperty(propertyNameMutator(property.Name));
|
||||
if (propertyFromSource == null) continue;
|
||||
var valueFromSource = propertyFromSource.GetValue(sourceInstance, null);
|
||||
var typeConverter = TypeDescriptor.GetConverter(property.PropertyType);
|
||||
if (typeConverter.CanConvertFrom(valueFromSource.GetType()))
|
||||
property.SetValue(Instance, typeConverter.ConvertFrom(valueFromSource), null);
|
||||
var expectedPropertyName = propertyNameMutator(property.Name);
|
||||
var propertyFromSource = typeof(TSource).GetProperty(expectedPropertyName);
|
||||
if (propertyFromSource == null)
|
||||
throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found.");
|
||||
|
||||
var valueFromSource = propertyFromSource.GetValue(sourceInstance, null);
|
||||
|
||||
if (property.PropertyType.IsEnum)
|
||||
{
|
||||
property.SetValue(Instance, Enum.Parse(property.PropertyType, valueFromSource.ToString()), null);
|
||||
continue;
|
||||
}
|
||||
|
||||
property.SetValue(Instance, Convert.ChangeType(valueFromSource, property.PropertyType), null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -40,19 +49,25 @@ namespace mRemoteNG.Connection
|
||||
|
||||
public void SaveTo<TDestination>(TDestination destinationInstance, Func<string, string> propertyNameMutator = null)
|
||||
{
|
||||
if (propertyNameMutator == null) propertyNameMutator = (a) => a;
|
||||
var inheritanceProperties = GetProperties(_excludedProperties);
|
||||
foreach (var property in inheritanceProperties)
|
||||
if (propertyNameMutator == null)
|
||||
propertyNameMutator = (a) => a;
|
||||
|
||||
var connectionProperties = GetSerializableProperties();
|
||||
|
||||
foreach (var property in connectionProperties)
|
||||
{
|
||||
try
|
||||
{
|
||||
var propertyFromDestination = typeof(TDestination).GetProperty(propertyNameMutator(property.Name));
|
||||
var localValue = property.GetValue(Instance, null);
|
||||
var typeConverter = TypeDescriptor.GetConverter(property.PropertyType);
|
||||
if (propertyFromDestination != null && !typeConverter.CanConvertTo(propertyFromDestination.PropertyType)) continue;
|
||||
if (propertyFromDestination == null) continue;
|
||||
var convertedValue = typeConverter.ConvertTo(localValue, propertyFromDestination.PropertyType);
|
||||
propertyFromDestination.SetValue(destinationInstance, convertedValue, null);
|
||||
var expectedPropertyName = propertyNameMutator(property.Name);
|
||||
var propertyFromDestination = typeof(TDestination).GetProperty(expectedPropertyName);
|
||||
|
||||
if (propertyFromDestination == null)
|
||||
throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found.");
|
||||
|
||||
// ensure value is of correct type
|
||||
var value = Convert.ChangeType(property.GetValue(Instance, null), propertyFromDestination.PropertyType);
|
||||
|
||||
propertyFromDestination.SetValue(destinationInstance, value, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user