[MWB][Enterprise] Add new policies and improve settings UI for the Transfer File setting (#33571)

## Summary of the Pull Request

### Improve settings page for TransferFile setting
The TransferFile setting depends on ShareClipboard setting. This is now
visually shown.

**Before the change:**

![image](https://github.com/microsoft/PowerToys/assets/61519853/735ad7bd-4f45-4914-8bbc-bc47170a9b47)
**After the change**

![image](https://github.com/microsoft/PowerToys/assets/61519853/78fb74c3-29a0-4779-8f0c-9df6c4161be1)


### New policies are added for MWB
Name | Supported states | Id | Behavior
------------ | ------------- | ------------ | -------------
Clipboard sharing enabled | disabled | MwbClipboardSharingEnabled |
Disables the feature if set to disabled.
File transfer enabled | disabled | MwbFileTransferEnabled | Disables the
feature if set to disabled.
Original user interface enabled | disabled | MwbUseOriginalUserInterface
| Disables the feature if set to disabled. |
Disallow blocking screensaver on other machines | enabled |
MwbDisallowBlockingScreensaver | Disables the feature if set to enabled.
|
Connect only in same subnet | enabled & disabled | MwbSameSubnetOnly |
Enables the feature if set to enabled.<br />Disables the feature if set
to disabled. |
Validate remote machine IP Address | enabled & disabled |
MwbValidateRemoteIp | Enables the feature if set to enabled.<br
/>Disables the feature if set to disabled.
Disable user defined IP Address mapping rules | enabled |
MwbDisableUserDefinedIpMappingRules | If enabled the user can't define
IP Address mapping rules.
Predefined IP Address mappings | enabled with multi-line text value |
MwbPolicyDefinedIpMappingRules | Allows admins to force define IP
Address mapping rules.

#### User Interface screenshots

![image](https://github.com/microsoft/PowerToys/assets/61519853/3d8a46c5-13f3-4a47-80a1-c0d242d8541c)

![image](https://github.com/microsoft/PowerToys/assets/61519853/44f4dc60-5106-45bf-9bb4-aa0bde9ef6fa)

![image](https://github.com/microsoft/PowerToys/assets/61519853/569be956-e889-442c-bdc9-e319ad3c19e3)
This commit is contained in:
Heiko
2024-07-22 16:49:45 +02:00
committed by GitHub
parent ca97e01d59
commit 16a1fb7981
15 changed files with 782 additions and 25 deletions

View File

@@ -12,8 +12,10 @@ using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Security.Cryptography;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Windows.Forms;
using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
@@ -259,6 +261,11 @@ namespace MouseWithoutBorders.Class
{
get
{
if (GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue() == GpoRuleConfigured.Disabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.ShareClipboard;
@@ -267,6 +274,11 @@ namespace MouseWithoutBorders.Class
set
{
if (ShareClipboardIsGpoConfigured)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.ShareClipboard = value;
@@ -274,10 +286,19 @@ namespace MouseWithoutBorders.Class
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool ShareClipboardIsGpoConfigured => GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue() == GpoRuleConfigured.Disabled;
internal bool TransferFile
{
get
{
if (GPOWrapper.GetConfiguredMwbFileTransferEnabledValue() == GpoRuleConfigured.Disabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.TransferFile;
@@ -286,10 +307,19 @@ namespace MouseWithoutBorders.Class
set
{
if (TransferFileIsGpoConfigured)
{
return;
}
_properties.TransferFile = value;
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool TransferFileIsGpoConfigured => GPOWrapper.GetConfiguredMwbFileTransferEnabledValue() == GpoRuleConfigured.Disabled;
internal bool MatrixOneRow
{
get
@@ -491,6 +521,11 @@ namespace MouseWithoutBorders.Class
{
get
{
if (GPOWrapper.GetConfiguredMwbDisallowBlockingScreensaverValue() == GpoRuleConfigured.Enabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.BlockScreenSaverOnOtherMachines;
@@ -499,6 +534,11 @@ namespace MouseWithoutBorders.Class
set
{
if (BlockScreenSaverIsGpoConfigured)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.BlockScreenSaverOnOtherMachines = value;
@@ -506,6 +546,10 @@ namespace MouseWithoutBorders.Class
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool BlockScreenSaverIsGpoConfigured => GPOWrapper.GetConfiguredMwbDisallowBlockingScreensaverValue() == GpoRuleConfigured.Enabled;
internal bool MoveMouseRelatively
{
get
@@ -795,6 +839,15 @@ namespace MouseWithoutBorders.Class
{
get
{
if (GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Enabled)
{
return true;
}
else if (GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Disabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.ValidateRemoteMachineIP;
@@ -803,6 +856,11 @@ namespace MouseWithoutBorders.Class
set
{
if (ReverseLookupIsGpoConfigured)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.ValidateRemoteMachineIP = value;
@@ -810,10 +868,23 @@ namespace MouseWithoutBorders.Class
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool ReverseLookupIsGpoConfigured => GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Enabled || GPOWrapper.GetConfiguredMwbValidateRemoteIpValue() == GpoRuleConfigured.Disabled;
internal bool SameSubNetOnly
{
get
{
if (GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Enabled)
{
return true;
}
else if (GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Disabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.SameSubnetOnly;
@@ -822,6 +893,11 @@ namespace MouseWithoutBorders.Class
set
{
if (SameSubNetOnlyIsGpoConfigured)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.SameSubnetOnly = value;
@@ -829,10 +905,19 @@ namespace MouseWithoutBorders.Class
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool SameSubNetOnlyIsGpoConfigured => GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Enabled || GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue() == GpoRuleConfigured.Disabled;
internal string Name2IP
{
get
{
if (GPOWrapper.GetConfiguredMwbDisableUserDefinedIpMappingRulesValue() == GpoRuleConfigured.Enabled)
{
return string.Empty;
}
lock (_loadingSettingsLock)
{
return _properties.Name2IP.Value;
@@ -841,6 +926,11 @@ namespace MouseWithoutBorders.Class
set
{
if (Name2IpIsGpoConfigured)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.Name2IP.Value = value;
@@ -848,6 +938,18 @@ namespace MouseWithoutBorders.Class
}
}
[CmdConfigureIgnore]
[JsonIgnore]
internal bool Name2IpIsGpoConfigured => GPOWrapper.GetConfiguredMwbDisableUserDefinedIpMappingRulesValue() == GpoRuleConfigured.Enabled;
[CmdConfigureIgnore]
[JsonIgnore]
internal string Name2IpPolicyList => GPOWrapper.GetConfiguredMwbPolicyDefinedIpMappingRules();
[CmdConfigureIgnore]
[JsonIgnore]
internal bool Name2IpPolicyListIsGpoConfigured => !string.IsNullOrWhiteSpace(Name2IpPolicyList);
internal bool FirstCtrlShiftS
{
get
@@ -954,6 +1056,11 @@ namespace MouseWithoutBorders.Class
{
get
{
if (GPOWrapper.GetConfiguredMwbUseOriginalUserInterfaceValue() == GpoRuleConfigured.Disabled)
{
return false;
}
lock (_loadingSettingsLock)
{
return _properties.ShowOriginalUI;
@@ -962,6 +1069,11 @@ namespace MouseWithoutBorders.Class
set
{
if (GPOWrapper.GetConfiguredMwbUseOriginalUserInterfaceValue() == GpoRuleConfigured.Disabled)
{
return;
}
lock (_loadingSettingsLock)
{
_properties.ShowOriginalUI = value;