From 16a1fb7981b9d27f13b578f4c3e15ffd11ed37ca Mon Sep 17 00:00:00 2001
From: Heiko <61519853+htcfreek@users.noreply.github.com>
Date: Mon, 22 Jul 2024 16:49:45 +0200
Subject: [PATCH] [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:**

**After the change**

### 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.
Disables the feature if set
to disabled. |
Validate remote machine IP Address | enabled & disabled |
MwbValidateRemoteIp | Enables the feature if set to enabled.
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



---
.github/actions/spell-check/expect.txt | 1 +
src/common/GPOWrapper/GPOWrapper.cpp | 36 ++++
src/common/GPOWrapper/GPOWrapper.h | 8 +
src/common/GPOWrapper/GPOWrapper.idl | 8 +
src/common/utils/gpo.h | 94 +++++++++-
src/gpo/assets/PowerToys.admx | 82 +++++++++
src/gpo/assets/en-US/PowerToys.adml | 72 ++++++++
.../MouseWithoutBorders/App/Class/Setting.cs | 112 ++++++++++++
.../App/Class/SocketStuff.cs | 3 +-
.../App/Form/frmMatrix.Designer.cs | 37 +++-
.../MouseWithoutBorders/App/Form/frmMatrix.cs | 50 ++++++
.../Views/MouseWithoutBordersPage.xaml | 108 +++++++++--
.../Settings.UI/Strings/en-us/Resources.resw | 6 +
.../MouseWithoutBordersViewModel.cs | 169 +++++++++++++++++-
.../BugReportTool/ReportGPOValues.cpp | 21 +++
15 files changed, 782 insertions(+), 25 deletions(-)
diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt
index c697204f95..e8e400bf59 100644
--- a/.github/actions/spell-check/expect.txt
+++ b/.github/actions/spell-check/expect.txt
@@ -1378,6 +1378,7 @@ SCID
Scip
scipbe
Scode
+screensaver
screenshots
scrollviewer
sddl
diff --git a/src/common/GPOWrapper/GPOWrapper.cpp b/src/common/GPOWrapper/GPOWrapper.cpp
index ee75ae71f5..de987ed81e 100644
--- a/src/common/GPOWrapper/GPOWrapper.cpp
+++ b/src/common/GPOWrapper/GPOWrapper.cpp
@@ -176,4 +176,40 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast(powertoys_gpo::getAllowedAdvancedPasteOnlineAIModelsValue());
}
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbClipboardSharingEnabledValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbClipboardSharingEnabledValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbFileTransferEnabledValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbFileTransferEnabledValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbUseOriginalUserInterfaceValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbUseOriginalUserInterfaceValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbDisallowBlockingScreensaverValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbDisallowBlockingScreensaverValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbSameSubnetOnlyValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbSameSubnetOnlyValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbValidateRemoteIpValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbValidateRemoteIpValue());
+ }
+ GpoRuleConfigured GPOWrapper::GetConfiguredMwbDisableUserDefinedIpMappingRulesValue()
+ {
+ return static_cast(powertoys_gpo::getConfiguredMwbDisableUserDefinedIpMappingRulesValue());
+ }
+ winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules()
+ {
+ // Assuming powertoys_gpo::getConfiguredMwbPolicyDefinedIpMappingRules() returns a std::wstring
+ std::wstring rules = powertoys_gpo::getConfiguredMwbPolicyDefinedIpMappingRules();
+
+ // Convert std::wstring to winrt::hstring
+ return to_hstring(rules.c_str());
+ }
}
diff --git a/src/common/GPOWrapper/GPOWrapper.h b/src/common/GPOWrapper/GPOWrapper.h
index e6e231c3c1..670124527b 100644
--- a/src/common/GPOWrapper/GPOWrapper.h
+++ b/src/common/GPOWrapper/GPOWrapper.h
@@ -50,6 +50,14 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue();
+ static GpoRuleConfigured GetConfiguredMwbClipboardSharingEnabledValue();
+ static GpoRuleConfigured GetConfiguredMwbFileTransferEnabledValue();
+ static GpoRuleConfigured GetConfiguredMwbUseOriginalUserInterfaceValue();
+ static GpoRuleConfigured GetConfiguredMwbDisallowBlockingScreensaverValue();
+ static GpoRuleConfigured GetConfiguredMwbSameSubnetOnlyValue();
+ static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
+ static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
+ static winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules();
};
}
diff --git a/src/common/GPOWrapper/GPOWrapper.idl b/src/common/GPOWrapper/GPOWrapper.idl
index 6bd22d8c31..27c2420b6e 100644
--- a/src/common/GPOWrapper/GPOWrapper.idl
+++ b/src/common/GPOWrapper/GPOWrapper.idl
@@ -54,6 +54,14 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredQoiPreviewEnabledValue();
static GpoRuleConfigured GetConfiguredQoiThumbnailsEnabledValue();
static GpoRuleConfigured GetAllowedAdvancedPasteOnlineAIModelsValue();
+ static GpoRuleConfigured GetConfiguredMwbClipboardSharingEnabledValue();
+ static GpoRuleConfigured GetConfiguredMwbFileTransferEnabledValue();
+ static GpoRuleConfigured GetConfiguredMwbUseOriginalUserInterfaceValue();
+ static GpoRuleConfigured GetConfiguredMwbDisallowBlockingScreensaverValue();
+ static GpoRuleConfigured GetConfiguredMwbSameSubnetOnlyValue();
+ static GpoRuleConfigured GetConfiguredMwbValidateRemoteIpValue();
+ static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
+ static String GetConfiguredMwbPolicyDefinedIpMappingRules();
}
}
}
diff --git a/src/common/utils/gpo.h b/src/common/utils/gpo.h
index 9c852bae58..cba300d8e5 100644
--- a/src/common/utils/gpo.h
+++ b/src/common/utils/gpo.h
@@ -2,6 +2,7 @@
#include
#include
+#include
namespace powertoys_gpo {
enum gpo_rule_configured_t {
@@ -71,11 +72,25 @@ namespace powertoys_gpo {
const std::wstring POLICY_ALLOW_EXPERIMENTATION = L"AllowExperimentation";
const std::wstring POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS = L"PowerLauncherAllPluginsEnabledState";
const std::wstring POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS = L"AllowPowerToysAdvancedPasteOnlineAIModels";
+ const std::wstring POLICY_MWB_CLIPBOARD_SHARING_ENABLED = L"MwbClipboardSharingEnabled";
+ const std::wstring POLICY_MWB_FILE_TRANSFER_ENABLED = L"MwbFileTransferEnabled";
+ const std::wstring POLICY_MWB_USE_ORIGINAL_USER_INTERFACE = L"MwbUseOriginalUserInterface";
+ const std::wstring POLICY_MWB_DISALLOW_BLOCKING_SCREENSAVER = L"MwbDisallowBlockingScreensaver";
+ const std::wstring POLICY_MWB_SAME_SUBNET_ONLY = L"MwbSameSubnetOnly";
+ const std::wstring POLICY_MWB_VALIDATE_REMOTE_IP = L"MwbValidateRemoteIp";
+ const std::wstring POLICY_MWB_DISABLE_USER_DEFINED_IP_MAPPING_RULES = L"MwbDisableUserDefinedIpMappingRules";
+ const std::wstring POLICY_MWB_POLICY_DEFINED_IP_MAPPING_RULES = L"MwbPolicyDefinedIpMappingRules";
- inline std::optional readRegistryStringValue(HKEY hRootKey, const std::wstring& subKey, const std::wstring& value_name)
+ inline std::optional readRegistryStringValue(HKEY hRootKey, const std::wstring& subKey, const std::wstring& value_name, const bool is_multi_line_text = false)
{
+ // Set value type
DWORD reg_value_type = REG_SZ;
DWORD reg_flags = RRF_RT_REG_SZ;
+ if (is_multi_line_text)
+ {
+ reg_value_type = REG_MULTI_SZ;
+ reg_flags = RRF_RT_REG_MULTI_SZ;
+ }
DWORD string_buffer_capacity;
// Request required buffer capacity / string length
@@ -97,8 +112,26 @@ namespace powertoys_gpo {
return std::nullopt;
}
- // Convert buffer to std::wstring, delete buffer and return REG_SZ value
- std::wstring string_value = temp_buffer;
+ // Convert buffer to std::wstring
+ std::wstring string_value = L"";
+ if (reg_value_type == REG_MULTI_SZ)
+ {
+ // If it is REG_MULTI_SZ handle this way
+ wchar_t* currentString = temp_buffer;
+ while (*currentString != L'\0')
+ {
+ // If first entry then assign the string, else add to the string
+ string_value = (string_value == L"") ? currentString : (string_value + L"\r\n" + currentString);
+ currentString += wcslen(currentString) + 1; // Move to the next string
+ }
+ }
+ else
+ {
+ // If it is REG_SZ handle this way
+ string_value = temp_buffer;
+ }
+
+ // delete buffer, return string value
delete temp_buffer;
return string_value;
}
@@ -475,4 +508,59 @@ namespace powertoys_gpo {
{
return getUtilityEnabledValue(POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS);
}
+
+ inline gpo_rule_configured_t getConfiguredMwbClipboardSharingEnabledValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_CLIPBOARD_SHARING_ENABLED);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbFileTransferEnabledValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_FILE_TRANSFER_ENABLED);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbUseOriginalUserInterfaceValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_USE_ORIGINAL_USER_INTERFACE);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbDisallowBlockingScreensaverValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_DISALLOW_BLOCKING_SCREENSAVER);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbSameSubnetOnlyValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_SAME_SUBNET_ONLY);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbValidateRemoteIpValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_VALIDATE_REMOTE_IP);
+ }
+
+ inline gpo_rule_configured_t getConfiguredMwbDisableUserDefinedIpMappingRulesValue()
+ {
+ return getUtilityEnabledValue(POLICY_MWB_DISABLE_USER_DEFINED_IP_MAPPING_RULES);
+ }
+
+ inline std::wstring getConfiguredMwbPolicyDefinedIpMappingRules()
+ {
+ // Important: HKLM has priority over HKCU
+ auto mapping_rules = readRegistryStringValue(HKEY_LOCAL_MACHINE, POLICIES_PATH, POLICY_MWB_POLICY_DEFINED_IP_MAPPING_RULES, true);
+ if (!mapping_rules.has_value())
+ {
+ mapping_rules = readRegistryStringValue(HKEY_CURRENT_USER, POLICIES_PATH, POLICY_MWB_POLICY_DEFINED_IP_MAPPING_RULES, true);
+ }
+
+ // return value
+ if (mapping_rules.has_value())
+ {
+ return mapping_rules.value();
+ }
+ else
+ {
+ return std::wstring ();
+ }
+ }
}
diff --git a/src/gpo/assets/PowerToys.admx b/src/gpo/assets/PowerToys.admx
index ab5f5fdd0c..a0f70baa30 100644
--- a/src/gpo/assets/PowerToys.admx
+++ b/src/gpo/assets/PowerToys.admx
@@ -19,6 +19,7 @@
+
@@ -32,6 +33,9 @@
+
+
+
@@ -507,5 +511,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/gpo/assets/en-US/PowerToys.adml b/src/gpo/assets/en-US/PowerToys.adml
index 202ad245fc..761abde90f 100644
--- a/src/gpo/assets/en-US/PowerToys.adml
+++ b/src/gpo/assets/en-US/PowerToys.adml
@@ -10,6 +10,7 @@
Installer and Updates
PowerToys Run
Advanced Paste
+ Mouse Without Borders
General settings
PowerToys version 0.64.0 or later
@@ -23,6 +24,7 @@
PowerToys version 0.78.0 or later
PowerToys version 0.81.0 or later
PowerToys version 0.81.1 or later
+ PowerToys version 0.83.0 or later
This policy configures the enabled state for all PowerToys utilities.
@@ -128,6 +130,65 @@ If you enable or don't configure this policy, the user takes control over the en
If you disable this policy, the user won't be able to enable Enable paste with AI Advanced Paste setting and use Advanced Paste AI prompt nor set up the Open AI key in PowerToys Settings.
+ This policy configures if the user can share the clipboard between machines.
+
+If you enable or don't configure this policy, the user takes control over the clipboard sharing setting.
+
+If you disable this policy, the user won't be able to enable the clipboard sharing setting.
+
+ This policy configures if the user can transfer files between machines.
+
+If you enable or don't configure this policy, the user takes control over the file sharing setting.
+
+If you disable this policy, the user won't be able to enable the file sharing Settings.
+
+Note: The file sharing feature depends on the clipboard sharing feature. Disabling clipboard sharing automatically disables file sharing too.
+
+ This policy configures if the user can use the old Mouse Without Borders user interface.
+
+If you enable or don't configure this policy, the user takes control over the setting and can enable or disable the old user interface.
+
+If you disable this policy, the user won't be able to enable the old user interface.
+
+ This policy configures if the user is allowed to disable the screensaver on the remote machines.
+
+If you enable this policy, the user won't be able to enable the "block screensaver" screensaver setting and the screensaver is not blocked.
+
+If you disable or don't configure this policy, the user takes control over the setting and can block the screensaver.
+
+
+ This policy configures if connections are only allowed in the same subnet.
+
+If you enable this policy, the setting is enabled and only connections in the same subnet are allowed.
+
+If you disable this policy, the setting is disabled and all connections are allowed.
+
+If you don't configure this policy, the user takes control over the setting and can enable or disable it.
+
+ This policy configures if reverse DNS lookup is used to validate the remote machine IP Address.
+
+If you enable this policy, the setting is enabled and the IP Address is validated.
+
+If you disable this policy, the setting is disabled and the IP Address is not validated.
+
+If you don't configure this policy, the user takes control over the setting and can enable or disable it.
+
+ This policy configures if the user can define IP Address mapping rules.
+
+If you enable this policy, the setting is disabled and the user can't define rules or use existing ones.
+
+If you disable or don't configure this policy, the user takes control over the setting.
+
+Note: Enabling this policy does not prevent policy defined mapping rules from working.
+
+ This policy allows you to define IP Address mapping rules.
+
+If you enable this policy, you can define IP Address mapping rules that the user can't change or disable.
+Please enter one mapping per line in the format: "hostname IP"
+
+If you disable or don't configure this policy, no predefined rules are applied.
+
+
Configure global utility enabled state
Advanced Paste: Configure enabled state
Always On Top: Configure enabled state
@@ -175,12 +236,23 @@ If you disable this policy, the user won't be able to enable Enable paste with A
QOI file preview: Configure enabled state
QOI file thumbnail: Configure enabled state
Allow using online AI models
+ Clipboard sharing enabled
+ File transfer enabled
+ Original user interface is available
+ Disallow blocking screensaver on other machines
+ Connect only in same subnet
+ Validate remote machine IP Address
+ Disable user defined IP Address mapping rules
+ Predefined IP Address mapping rules
List of managed plugins:
+
+ List of IP Address mappings:
+
diff --git a/src/modules/MouseWithoutBorders/App/Class/Setting.cs b/src/modules/MouseWithoutBorders/App/Class/Setting.cs
index 6a1dd05774..717c84acaf 100644
--- a/src/modules/MouseWithoutBorders/App/Class/Setting.cs
+++ b/src/modules/MouseWithoutBorders/App/Class/Setting.cs
@@ -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;
diff --git a/src/modules/MouseWithoutBorders/App/Class/SocketStuff.cs b/src/modules/MouseWithoutBorders/App/Class/SocketStuff.cs
index a3ea7e3c08..57600cde95 100644
--- a/src/modules/MouseWithoutBorders/App/Class/SocketStuff.cs
+++ b/src/modules/MouseWithoutBorders/App/Class/SocketStuff.cs
@@ -887,7 +887,8 @@ namespace MouseWithoutBorders.Class
if (!string.IsNullOrEmpty(Setting.Values.Name2IP))
{
- string[] name2ip = Setting.Values.Name2IP.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
+ string combinedName2ipList = Setting.Values.Name2IpPolicyList + Separator + Setting.Values.Name2IP;
+ string[] name2ip = combinedName2ipList.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
string[] nameNip;
if (name2ip != null)
diff --git a/src/modules/MouseWithoutBorders/App/Form/frmMatrix.Designer.cs b/src/modules/MouseWithoutBorders/App/Form/frmMatrix.Designer.cs
index 21697f490d..189503e022 100644
--- a/src/modules/MouseWithoutBorders/App/Form/frmMatrix.Designer.cs
+++ b/src/modules/MouseWithoutBorders/App/Form/frmMatrix.Designer.cs
@@ -1,6 +1,7 @@
using System.Windows.Forms;
using System.Collections.Generic;
using System.Drawing;
+using Windows.UI.Notifications;
namespace MouseWithoutBorders
{
@@ -88,6 +89,8 @@ namespace MouseWithoutBorders
this.linkLabelReConfigure = new System.Windows.Forms.LinkLabel();
this.tabControlSetting = new System.Windows.Forms.TabControl();
this.tabPageAdvancedSettings = new System.Windows.Forms.TabPage();
+ this.groupBoxName2IPPolicyList = new System.Windows.Forms.GroupBox();
+ this.textBoxMachineName2IPPolicyList = new System.Windows.Forms.TextBox();
this.pictureBoxMouseWithoutBorders = new System.Windows.Forms.PictureBox();
this.groupBoxDNS = new System.Windows.Forms.GroupBox();
this.textBoxMachineName2IP = new System.Windows.Forms.TextBox();
@@ -103,6 +106,7 @@ namespace MouseWithoutBorders
this.groupBoxMachineMatrix.SuspendLayout();
this.tabControlSetting.SuspendLayout();
this.tabPageAdvancedSettings.SuspendLayout();
+ this.groupBoxName2IPPolicyList.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMouseWithoutBorders)).BeginInit();
this.groupBoxDNS.SuspendLayout();
this.SuspendLayout();
@@ -977,6 +981,7 @@ namespace MouseWithoutBorders
// tabPageAdvancedSettings
//
this.tabPageAdvancedSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(246)))), ((int)(((byte)(245)))), ((int)(((byte)(242)))));
+ this.tabPageAdvancedSettings.Controls.Add(this.groupBoxName2IPPolicyList);
this.tabPageAdvancedSettings.Controls.Add(this.pictureBoxMouseWithoutBorders);
this.tabPageAdvancedSettings.Controls.Add(this.groupBoxDNS);
this.tabPageAdvancedSettings.Controls.Add(this.textBoxDNS);
@@ -986,6 +991,33 @@ namespace MouseWithoutBorders
this.tabPageAdvancedSettings.Size = new System.Drawing.Size(563, 362);
this.tabPageAdvancedSettings.TabIndex = 2;
this.tabPageAdvancedSettings.Text = "IP Mappings";
+ //
+ // groupBoxName2IPPolicyList
+ //
+ this.groupBoxName2IPPolicyList.Controls.Add(this.textBoxMachineName2IPPolicyList);
+ this.groupBoxName2IPPolicyList.Dock = System.Windows.Forms.DockStyle.Top;
+ this.groupBoxName2IPPolicyList.Location = new System.Drawing.Point(3, 241);
+ this.groupBoxName2IPPolicyList.Name = "groupBoxName2IPPolicyList";
+ this.groupBoxName2IPPolicyList.Size = new System.Drawing.Size(357, 150);
+ this.groupBoxName2IPPolicyList.TabIndex = 1;
+ this.groupBoxName2IPPolicyList.TabStop = false;
+ this.groupBoxName2IPPolicyList.Text = " Policy defined machine name to IP address mappings [Managed]";
+ this.groupBoxName2IPPolicyList.ForeColor = Color.DimGray;
+ this.groupBoxName2IPPolicyList.Visible = false;
+ //
+ // textBoxMachineName2IPPolicyList
+ //
+ this.textBoxMachineName2IPPolicyList.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.textBoxMachineName2IPPolicyList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.textBoxMachineName2IPPolicyList.Location = new System.Drawing.Point(3, 172); // 3,172
+ this.textBoxMachineName2IPPolicyList.MaxLength = 1024;
+ this.textBoxMachineName2IPPolicyList.Multiline = true;
+ this.textBoxMachineName2IPPolicyList.Name = "textBoxMachineName2IPPolicyList";
+ this.textBoxMachineName2IPPolicyList.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.textBoxMachineName2IPPolicyList.Size = new System.Drawing.Size(351, 131);
+ this.textBoxMachineName2IPPolicyList.TabIndex = 1;
+ this.textBoxMachineName2IPPolicyList.ReadOnly = true;
+ this.textBoxMachineName2IPPolicyList.Visible = false;
//
// pictureBoxMouseWithoutBorders
//
@@ -1098,12 +1130,13 @@ namespace MouseWithoutBorders
this.tabControlSetting.ResumeLayout(false);
this.tabPageAdvancedSettings.ResumeLayout(false);
this.tabPageAdvancedSettings.PerformLayout();
+ this.groupBoxName2IPPolicyList.ResumeLayout(false);
+ this.groupBoxName2IPPolicyList.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMouseWithoutBorders)).EndInit();
this.groupBoxDNS.ResumeLayout(false);
this.groupBoxDNS.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
-
}
#endregion
@@ -1140,6 +1173,8 @@ namespace MouseWithoutBorders
private GroupBox groupBoxDNS;
private TextBox textBoxDNS;
private TextBox textBoxMachineName2IP;
+ private GroupBox groupBoxName2IPPolicyList;
+ private TextBox textBoxMachineName2IPPolicyList;
private PictureBox pictureBoxMouseWithoutBorders;
private GroupBox groupBoxOtherOptions;
private CheckBox checkBoxDrawMouse;
diff --git a/src/modules/MouseWithoutBorders/App/Form/frmMatrix.cs b/src/modules/MouseWithoutBorders/App/Form/frmMatrix.cs
index 2392896d83..03fa34f498 100644
--- a/src/modules/MouseWithoutBorders/App/Form/frmMatrix.cs
+++ b/src/modules/MouseWithoutBorders/App/Form/frmMatrix.cs
@@ -853,6 +853,56 @@ namespace MouseWithoutBorders
comboBoxEasyMouse.Text = Setting.Values.HotKeyToggleEasyMouse == 0 ? "Disable" : new string(new char[] { (char)Setting.Values.HotKeyToggleEasyMouse });
#endif
+
+ // Apply policy configuration on UI elements
+ // Has to be the last action
+ if (Setting.Values.ShareClipboardIsGpoConfigured)
+ {
+ checkBoxShareClipboard.Enabled = false;
+ checkBoxShareClipboard.Text += " [Managed]";
+
+ // transfer file setting depends on clipboard sharing
+ checkBoxTransferFile.Enabled = false;
+ }
+
+ if (Setting.Values.TransferFileIsGpoConfigured)
+ {
+ checkBoxTransferFile.Enabled = false;
+ checkBoxTransferFile.Text += " [Managed]";
+ }
+
+ if (Setting.Values.BlockScreenSaverIsGpoConfigured)
+ {
+ checkBoxBlockScreenSaver.Enabled = false;
+ checkBoxBlockScreenSaver.Text += " [Managed]";
+ }
+
+ if (Setting.Values.SameSubNetOnlyIsGpoConfigured)
+ {
+ checkBoxSameSubNet.Enabled = false;
+ checkBoxSameSubNet.Text += " [Managed]";
+ }
+
+ if (Setting.Values.ReverseLookupIsGpoConfigured)
+ {
+ checkBoxReverseLookup.Enabled = false;
+ checkBoxReverseLookup.Text += " [Managed]";
+ }
+
+ if (Setting.Values.Name2IpIsGpoConfigured)
+ {
+ textBoxMachineName2IP.Enabled = false;
+ groupBoxDNS.ForeColor = Color.DimGray;
+ groupBoxDNS.Text += " [Managed]";
+ }
+
+ if (Setting.Values.Name2IpPolicyListIsGpoConfigured)
+ {
+ pictureBoxMouseWithoutBorders.Visible = false;
+ groupBoxName2IPPolicyList.Visible = true;
+ textBoxMachineName2IPPolicyList.Visible = true;
+ textBoxMachineName2IPPolicyList.Text = Setting.Values.Name2IpPolicyList;
+ }
}
private void RadioButton_CheckedChanged(object sender, EventArgs e)
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseWithoutBordersPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseWithoutBordersPage.xaml
index d9a572deff..46141e91a4 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseWithoutBordersPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseWithoutBordersPage.xaml
@@ -208,28 +208,43 @@
IsEnabled="{x:Bind ViewModel.CanUninstallService, Mode=OneWay}" />
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
@@ -292,11 +307,15 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -313,12 +386,19 @@
ActionIcon="{ui:FontIcon Glyph=}"
Command="{x:Bind ViewModel.AddFirewallRuleEventHandler}"
IsClickEnabled="True" />
-
-
+
+
+
+
+
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index 37f6943620..f2f04dd7d7 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -4199,4 +4199,10 @@ Activate by holding the key for the character you want to add an accent to, then
Automatically close the AdvancedPaste window after it loses focus
AdvancedPaste is a product name, do not loc
+
+ Rules defined by your organization
+
+
+ You can not change, remove or disable these enforced rules.
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs
index afc4621191..bc9eb69c12 100644
--- a/src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs
+++ b/src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs
@@ -66,11 +66,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public bool ShowOriginalUI
{
- get => Settings.Properties.ShowOriginalUI;
+ get
+ {
+ if (_useOriginalUserInterfaceGpoConfiguration == GpoRuleConfigured.Disabled)
+ {
+ return false;
+ }
+
+ return Settings.Properties.ShowOriginalUI;
+ }
set
{
- if (Settings.Properties.ShowOriginalUI != value)
+ if (!_useOriginalUserInterfaceIsGPOConfigured && (Settings.Properties.ShowOriginalUI != value))
{
Settings.Properties.ShowOriginalUI = value;
NotifyPropertyChanged(nameof(ShowOriginalUI));
@@ -78,6 +86,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForOriginalUiSettingIsEnabled => _useOriginalUserInterfaceIsGPOConfigured == false;
+
+ public bool ShowPolicyConfiguredInfoForOriginalUiSetting => IsEnabled && _useOriginalUserInterfaceIsGPOConfigured;
+
public bool UseService
{
get => Settings.Properties.UseService;
@@ -163,6 +175,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool _enabledStateIsGPOConfigured;
private bool _isEnabled;
+ // Configuration policy variables
+ private GpoRuleConfigured _clipboardSharingEnabledGpoConfiguration;
+ private bool _clipboardSharingEnabledIsGPOConfigured;
+ private GpoRuleConfigured _fileTransferEnabledGpoConfiguration;
+ private bool _fileTransferEnabledIsGPOConfigured;
+ private GpoRuleConfigured _useOriginalUserInterfaceGpoConfiguration;
+ private bool _useOriginalUserInterfaceIsGPOConfigured;
+ private GpoRuleConfigured _disallowBlockingScreensaverGpoConfiguration;
+ private bool _disallowBlockingScreensaverIsGPOConfigured;
+ private GpoRuleConfigured _sameSubnetOnlyGpoConfiguration;
+ private bool _sameSubnetOnlyIsGPOConfigured;
+ private GpoRuleConfigured _validateRemoteIpGpoConfiguration;
+ private bool _validateRemoteIpIsGPOConfigured;
+ private GpoRuleConfigured _disableUserDefinedIpMappingRulesGpoConfiguration;
+ private bool _disableUserDefinedIpMappingRulesIsGPOConfigured;
+ private string _policyDefinedIpMappingRulesGPOData;
+ private bool _policyDefinedIpMappingRulesIsGPOConfigured;
+
public string MachineHostName
{
get
@@ -385,6 +415,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
GeneralSettingsConfig = settingsRepository.SettingsConfig;
InitializeEnabledValue();
+ InitializePolicyValues();
// MouseWithoutBorders settings may be changed by the logic in the utility as machines connect. We need to get a fresh version everytime instead of using a repository.
MouseWithoutBordersSettings moduleSettings;
@@ -466,6 +497,33 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ private void InitializePolicyValues()
+ {
+ // Policies supporting only enabled state
+ _disallowBlockingScreensaverGpoConfiguration = GPOWrapper.GetConfiguredMwbDisallowBlockingScreensaverValue();
+ _disallowBlockingScreensaverIsGPOConfigured = _disallowBlockingScreensaverGpoConfiguration == GpoRuleConfigured.Enabled;
+ _disableUserDefinedIpMappingRulesGpoConfiguration = GPOWrapper.GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
+ _disableUserDefinedIpMappingRulesIsGPOConfigured = _disableUserDefinedIpMappingRulesGpoConfiguration == GpoRuleConfigured.Enabled;
+
+ // Policies supporting only disabled state
+ _clipboardSharingEnabledGpoConfiguration = GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue();
+ _clipboardSharingEnabledIsGPOConfigured = _clipboardSharingEnabledGpoConfiguration == GpoRuleConfigured.Disabled;
+ _fileTransferEnabledGpoConfiguration = GPOWrapper.GetConfiguredMwbFileTransferEnabledValue();
+ _fileTransferEnabledIsGPOConfigured = _fileTransferEnabledGpoConfiguration == GpoRuleConfigured.Disabled;
+ _useOriginalUserInterfaceGpoConfiguration = GPOWrapper.GetConfiguredMwbUseOriginalUserInterfaceValue();
+ _useOriginalUserInterfaceIsGPOConfigured = _useOriginalUserInterfaceGpoConfiguration == GpoRuleConfigured.Disabled;
+
+ // Policies supporting enabled and disabled state
+ _sameSubnetOnlyGpoConfiguration = GPOWrapper.GetConfiguredMwbSameSubnetOnlyValue();
+ _sameSubnetOnlyIsGPOConfigured = _sameSubnetOnlyGpoConfiguration == GpoRuleConfigured.Enabled || _sameSubnetOnlyGpoConfiguration == GpoRuleConfigured.Disabled;
+ _validateRemoteIpGpoConfiguration = GPOWrapper.GetConfiguredMwbValidateRemoteIpValue();
+ _validateRemoteIpIsGPOConfigured = _validateRemoteIpGpoConfiguration == GpoRuleConfigured.Enabled || _validateRemoteIpGpoConfiguration == GpoRuleConfigured.Disabled;
+
+ // Special policies
+ _policyDefinedIpMappingRulesGPOData = GPOWrapper.GetConfiguredMwbPolicyDefinedIpMappingRules();
+ _policyDefinedIpMappingRulesIsGPOConfigured = !string.IsNullOrWhiteSpace(_policyDefinedIpMappingRulesGPOData);
+ }
+
private void LoadViewModelFromSettings(MouseWithoutBordersSettings moduleSettings)
{
ArgumentNullException.ThrowIfNull(moduleSettings);
@@ -569,6 +627,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(ShowInfobarRunAsAdminText));
OnPropertyChanged(nameof(ShowInfobarCannotDragDropAsAdmin));
+ OnPropertyChanged(nameof(ShowPolicyConfiguredInfoForBehaviorSettings));
+ OnPropertyChanged(nameof(ShowPolicyConfiguredInfoForName2IPSetting));
+ OnPropertyChanged(nameof(ShowPolicyConfiguredInfoForOriginalUiSetting));
+ OnPropertyChanged(nameof(Name2IpListPolicyIsConfigured));
Task.Run(async () =>
{
@@ -654,28 +716,49 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
+ if (_clipboardSharingEnabledGpoConfiguration == GpoRuleConfigured.Disabled)
+ {
+ return false;
+ }
+
return Settings.Properties.ShareClipboard;
}
set
{
- if (Settings.Properties.ShareClipboard != value)
+ if (!_clipboardSharingEnabledIsGPOConfigured && (Settings.Properties.ShareClipboard != value))
{
Settings.Properties.ShareClipboard = value;
NotifyPropertyChanged();
+ OnPropertyChanged(nameof(TransferFile));
+ OnPropertyChanged(nameof(CardForTransferFileSettingIsEnabled));
}
}
}
+ public bool CardForShareClipboardSettingIsEnabled => _clipboardSharingEnabledIsGPOConfigured == false;
+
public bool TransferFile
{
get
{
- return Settings.Properties.TransferFile;
+ if (_fileTransferEnabledGpoConfiguration == GpoRuleConfigured.Disabled)
+ {
+ return false;
+ }
+
+ return Settings.Properties.TransferFile && Settings.Properties.ShareClipboard;
}
set
{
+ // If ShareClipboard is disabled the file transfer does not work and the setting is disabled. => Don't save toggle state.
+ // If FileTransferGpo is configured the file transfer does not work and the setting is disabled. => Don't save toggle state.
+ if (!ShareClipboard || _fileTransferEnabledIsGPOConfigured)
+ {
+ return;
+ }
+
if (Settings.Properties.TransferFile != value)
{
Settings.Properties.TransferFile = value;
@@ -684,6 +767,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForTransferFileSettingIsEnabled
+ {
+ get => ShareClipboard && !_fileTransferEnabledIsGPOConfigured;
+ }
+
public bool HideMouseAtScreenEdge
{
get
@@ -722,12 +810,21 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
+ if (_validateRemoteIpGpoConfiguration == GpoRuleConfigured.Enabled)
+ {
+ return true;
+ }
+ else if (_validateRemoteIpGpoConfiguration == GpoRuleConfigured.Disabled)
+ {
+ return false;
+ }
+
return Settings.Properties.ValidateRemoteMachineIP;
}
set
{
- if (Settings.Properties.ValidateRemoteMachineIP != value)
+ if (!_validateRemoteIpIsGPOConfigured && (Settings.Properties.ValidateRemoteMachineIP != value))
{
Settings.Properties.ValidateRemoteMachineIP = value;
NotifyPropertyChanged();
@@ -735,6 +832,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForValidateRemoteIpSettingIsEnabled => _validateRemoteIpIsGPOConfigured == false;
+
public string Name2IP
{
// Due to https://github.com/microsoft/microsoft-ui-xaml/issues/1826, we must
@@ -742,11 +841,21 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
// to make its behavior consistent with the old UI and MWB internal code.
get
{
+ if (_disableUserDefinedIpMappingRulesGpoConfiguration == GpoRuleConfigured.Enabled)
+ {
+ return string.Empty;
+ }
+
return Settings.Properties.Name2IP.Value.Replace("\r\n", "\r");
}
set
{
+ if (_disableUserDefinedIpMappingRulesIsGPOConfigured)
+ {
+ return;
+ }
+
var newValue = value.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
if (Settings.Properties.Name2IP.Value != newValue)
@@ -757,16 +866,40 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForName2IpSettingIsEnabled => _disableUserDefinedIpMappingRulesIsGPOConfigured == false;
+
+ public bool ShowPolicyConfiguredInfoForName2IPSetting => _disableUserDefinedIpMappingRulesIsGPOConfigured && IsEnabled;
+
+ public string Name2IpListPolicyData
+ {
+ // Due to https://github.com/microsoft/microsoft-ui-xaml/issues/1826, we must
+ // add back \n chars on set and remove them on get for the widget
+ // to make its behavior consistent with the old UI and MWB internal code.
+ // get => GPOWrapper.GetConfiguredMwbPolicyDefinedIpMappingRules().Replace("\r\n", "\r");
+ get => _policyDefinedIpMappingRulesGPOData.Replace("\r\n", "\r");
+ }
+
+ public bool Name2IpListPolicyIsConfigured => _policyDefinedIpMappingRulesIsGPOConfigured && IsEnabled;
+
public bool SameSubnetOnly
{
get
{
+ if (_sameSubnetOnlyGpoConfiguration == GpoRuleConfigured.Enabled)
+ {
+ return true;
+ }
+ else if (_sameSubnetOnlyGpoConfiguration == GpoRuleConfigured.Disabled)
+ {
+ return false;
+ }
+
return Settings.Properties.SameSubnetOnly;
}
set
{
- if (Settings.Properties.SameSubnetOnly != value)
+ if (!_sameSubnetOnlyIsGPOConfigured && (Settings.Properties.SameSubnetOnly != value))
{
Settings.Properties.SameSubnetOnly = value;
NotifyPropertyChanged();
@@ -774,15 +907,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForSameSubnetOnlySettingIsEnabled => _sameSubnetOnlyIsGPOConfigured == false;
+
public bool BlockScreenSaverOnOtherMachines
{
get
{
+ if (_disallowBlockingScreensaverGpoConfiguration == GpoRuleConfigured.Enabled)
+ {
+ return false;
+ }
+
return Settings.Properties.BlockScreenSaverOnOtherMachines;
}
set
{
+ if (_disallowBlockingScreensaverIsGPOConfigured)
+ {
+ return;
+ }
+
if (Settings.Properties.BlockScreenSaverOnOtherMachines != value)
{
Settings.Properties.BlockScreenSaverOnOtherMachines = value;
@@ -791,6 +936,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public bool CardForBlockScreensaverSettingIsEnabled => _disallowBlockingScreensaverIsGPOConfigured == false;
+
// Should match EasyMouseOption enum from MouseWithoutBorders and the ComboBox in the MouseWithoutBordersView.cs
private enum EasyMouseOption
{
@@ -1083,6 +1230,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SendCustomAction("uninstall_service");
}
+ public bool ShowPolicyConfiguredInfoForBehaviorSettings
+ {
+ get
+ {
+ return IsEnabled && (_disallowBlockingScreensaverIsGPOConfigured
+ || _clipboardSharingEnabledIsGPOConfigured || _fileTransferEnabledIsGPOConfigured
+ || _sameSubnetOnlyIsGPOConfigured || _validateRemoteIpIsGPOConfigured);
+ }
+ }
+
public bool ShowInfobarCannotDragDropAsAdmin
{
get { return IsElevated && IsEnabled; }
diff --git a/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp b/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp
index 3aa19a80eb..d59236cfc3 100644
--- a/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp
+++ b/tools/BugReportTool/BugReportTool/ReportGPOValues.cpp
@@ -3,6 +3,7 @@
#include
#include
#include
+#include
std::wstring gpo_rule_configured_to_string(powertoys_gpo::gpo_rule_configured_t gpo_rule)
{
@@ -22,6 +23,18 @@ std::wstring gpo_rule_configured_to_string(powertoys_gpo::gpo_rule_configured_t
}
}
+std::wstring gpo_string_to_string(const std::wstring &gpo_value)
+{
+ if (gpo_value == L"")
+ {
+ return L"not_configured";
+ }
+ else
+ {
+ return std::regex_replace(gpo_value, std::wregex(L"\r\n"), std::wstring(L"|"));
+ }
+}
+
void ReportGPOValues(const std::filesystem::path& tmpDir)
{
auto reportPath = tmpDir;
@@ -68,4 +81,12 @@ void ReportGPOValues(const std::filesystem::path& tmpDir)
report << "getConfiguredQoiPreviewEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredQoiPreviewEnabledValue()) << std::endl;
report << "getConfiguredQoiThumbnailsEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredQoiThumbnailsEnabledValue()) << std::endl;
report << "getAllowedAdvancedPasteOnlineAIModelsValue: " << gpo_rule_configured_to_string(powertoys_gpo::getAllowedAdvancedPasteOnlineAIModelsValue()) << std::endl;
+ report << "getConfiguredMwbClipboardSharingEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbClipboardSharingEnabledValue()) << std::endl;
+ report << "getConfiguredMwbFileTransferEnabledValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbFileTransferEnabledValue()) << std::endl;
+ report << "getConfiguredMwbUseOriginalUserInterfaceValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbUseOriginalUserInterfaceValue()) << std::endl;
+ report << "getConfiguredMwbDisallowBlockingScreensaverValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbDisallowBlockingScreensaverValue()) << std::endl;
+ report << "getConfiguredMwbSameSubnetOnlyValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbSameSubnetOnlyValue()) << std::endl;
+ report << "getConfiguredMwbValidateRemoteIpValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbValidateRemoteIpValue()) << std::endl;
+ report << "getConfiguredMwbDisableUserDefinedIpMappingRulesValue: " << gpo_rule_configured_to_string(powertoys_gpo::getConfiguredMwbDisableUserDefinedIpMappingRulesValue()) << std::endl;
+ report << "getConfiguredMwbPolicyDefinedIpMappingRules: " << gpo_string_to_string(powertoys_gpo::getConfiguredMwbPolicyDefinedIpMappingRules()) << std::endl;
}