From 8c45af88fb5e24ce4cbbcc2fd82787a5ce343e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Thu, 11 Jan 2024 12:32:48 +0100 Subject: [PATCH] SEBWIN-821: Forgot to implement default values and data mapping for always on configuration. --- .../ConfigurationData/DataMapper.cs | 3 +- .../DataMapping/DisplayDataMapper.cs | 11 +++++++ .../DataMapping/SystemDataMapper.cs | 33 +++++++++++++++++++ .../ConfigurationData/Keys.cs | 6 ++++ .../SafeExamBrowser.Configuration.csproj | 1 + SebWindowsConfig/SEBSettings.cs | 6 ++++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SystemDataMapper.cs diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs index d7b06b3f..3521d6ab 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs @@ -14,7 +14,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData { internal class DataMapper { - private BaseDataMapper[] mappers = + private readonly BaseDataMapper[] mappers = { new ApplicationDataMapper(), new AudioDataMapper(), @@ -27,6 +27,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData new SecurityDataMapper(), new ServerDataMapper(), new ServiceDataMapper(), + new SystemDataMapper(), new UserInterfaceDataMapper() }; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/DisplayDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/DisplayDataMapper.cs index 1ff2bfe7..3c68986a 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/DisplayDataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/DisplayDataMapper.cs @@ -19,6 +19,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping case Keys.Display.AllowedDisplays: MapAllowedDisplays(settings, value); break; + case Keys.Display.AlwaysOn: + MapAlwaysOn(settings, value); + break; case Keys.Display.IgnoreError: MapIgnoreError(settings, value); break; @@ -36,6 +39,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping } } + private void MapAlwaysOn(AppSettings settings, object value) + { + if (value is bool alwaysOn) + { + settings.Display.AlwaysOn = alwaysOn; + } + } + private void MapIgnoreError(AppSettings settings, object value) { if (value is bool ignore) diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SystemDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SystemDataMapper.cs new file mode 100644 index 00000000..44a5e802 --- /dev/null +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/SystemDataMapper.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +using SafeExamBrowser.Settings; + +namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping +{ + internal class SystemDataMapper : BaseDataMapper + { + internal override void Map(string key, object value, AppSettings settings) + { + switch (key) + { + case Keys.System.AlwaysOn: + MapAlwaysOn(settings, value); + break; + } + } + + private void MapAlwaysOn(AppSettings settings, object value) + { + if (value is bool alwaysOn) + { + settings.System.AlwaysOn = alwaysOn; + } + } + } +} diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index 3d202289..6625ced2 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -177,6 +177,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal static class Display { internal const string AllowedDisplays = "allowedDisplaysMaxNumber"; + internal const string AlwaysOn = "displayAlwaysOn"; internal const string IgnoreError = "allowedDisplaysIgnoreFailure"; internal const string InternalDisplayOnly = "allowedDisplayBuiltinEnforce"; } @@ -326,6 +327,11 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal const string SetVmwareConfiguration = "setVmwareConfiguration"; } + internal static class System + { + internal const string AlwaysOn = "systemAlwaysOn"; + } + internal static class UserInterface { internal const string ShowAudio = "audioControlEnabled"; diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj index c381cd0b..ac923a1f 100644 --- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj +++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj @@ -68,6 +68,7 @@ + diff --git a/SebWindowsConfig/SEBSettings.cs b/SebWindowsConfig/SEBSettings.cs index b92c9d54..92d751a9 100644 --- a/SebWindowsConfig/SEBSettings.cs +++ b/SebWindowsConfig/SEBSettings.cs @@ -435,6 +435,9 @@ namespace SebWindowsConfig public const String KeyEnableF11 = "enableF11"; public const String KeyEnableF12 = "enableF12"; + public const String KeyDisplayAlwaysOn = "displayAlwaysOn"; + public const String KeySystemAlwaysOn = "systemAlwaysOn"; + public enum sebConfigPurposes { sebConfigPurposeStartingExam, sebConfigPurposeConfiguringClient @@ -1056,6 +1059,9 @@ namespace SebWindowsConfig SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF11, true); SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF12, true); + SEBSettings.settingsDefault.Add(SEBSettings.KeyDisplayAlwaysOn, true); + SEBSettings.settingsDefault.Add(SEBSettings.KeySystemAlwaysOn, true); + // Clear all "current" lists and dictionaries