SEBWIN-110: Refactored configuration so that all taskbar-related settings are in the same interface.

This commit is contained in:
dbuechel 2017-11-09 10:27:55 +01:00
parent 91a8e4d6e4
commit a118f52ee3
9 changed files with 70 additions and 26 deletions

View file

@ -59,6 +59,7 @@
<Compile Include="Settings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemInfo.cs" />
<Compile Include="TaskbarSettings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">

View file

@ -25,21 +25,21 @@ namespace SafeExamBrowser.Configuration
Browser = new BrowserSettings(this);
Keyboard = new KeyboardSettings();
Mouse = new MouseSettings();
Taskbar = new TaskbarSettings();
}
public bool AllowApplicationLog => true;
public bool AllowKeyboardLayout => true;
public string AppDataFolderName => nameof(SafeExamBrowser);
public IBrowserSettings Browser { get; private set; }
public IKeyboardSettings Keyboard { get; private set; }
public IMouseSettings Mouse { get; private set; }
public ITaskbarSettings Taskbar { get; private set; }
public string ApplicationLogFile
{
get { return Path.Combine(LogFolderPath, $"{RuntimeIdentifier}_Application.txt"); }
}
public IBrowserSettings Browser { get; private set; }
public IKeyboardSettings Keyboard { get; private set; }
public IMouseSettings Mouse { get; private set; }
public string LogFolderPath
{
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolderName, "Logs"); }

View file

@ -0,0 +1,19 @@
/*
* Copyright (c) 2017 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.Contracts.Configuration.Settings;
namespace SafeExamBrowser.Configuration
{
public class TaskbarSettings : ITaskbarSettings
{
public bool AllowApplicationLog => true;
public bool AllowKeyboardLayout => true;
public bool AllowWirelessNetwork => true;
}
}

View file

@ -10,16 +10,6 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
{
public interface ISettings
{
/// <summary>
/// Determines whether the user may access the application log during runtime.
/// </summary>
bool AllowApplicationLog { get; }
/// <summary>
/// Determines whether the user may switch the keyboard layout during runtime.
/// </summary>
bool AllowKeyboardLayout { get; }
/// <summary>
/// The name used for the application data folder.
/// </summary>
@ -40,16 +30,16 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
/// </summary>
IKeyboardSettings Keyboard { get; }
/// <summary>
/// All mouse-related settings.
/// </summary>
IMouseSettings Mouse { get; }
/// <summary>
/// The path where the log files are to be stored.
/// </summary>
string LogFolderPath { get; }
/// <summary>
/// All mouse-related settings.
/// </summary>
IMouseSettings Mouse { get; }
/// <summary>
/// The copyright information for the application (i.e. the executing assembly).
/// </summary>
@ -69,5 +59,10 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
/// A string uniquely identifying the runtime of the application, used e.g. for the log file names.
/// </summary>
string RuntimeIdentifier { get; }
/// <summary>
/// All taskbar-related settings.
/// </summary>
ITaskbarSettings Taskbar { get; }
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2017 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/.
*/
namespace SafeExamBrowser.Contracts.Configuration.Settings
{
public interface ITaskbarSettings
{
/// <summary>
/// Determines whether the user may switch the keyboard layout during runtime.
/// </summary>
bool AllowKeyboardLayout { get; }
/// <summary>
/// Determines whether the user may access the application log during runtime.
/// </summary>
bool AllowApplicationLog { get; }
/// <summary>
/// Determines whether the user may control the wireless network connection during runtime.
/// </summary>
bool AllowWirelessNetwork { get; }
}
}

View file

@ -68,6 +68,7 @@
<Compile Include="Configuration\Settings\ISettings.cs" />
<Compile Include="Behaviour\IShutdownController.cs" />
<Compile Include="Behaviour\IStartupController.cs" />
<Compile Include="Configuration\Settings\ITaskbarSettings.cs" />
<Compile Include="I18n\IText.cs" />
<Compile Include="I18n\TextKey.cs" />
<Compile Include="Logging\ILogContent.cs" />

View file

@ -23,7 +23,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour.Operations
public class TaskbarOperationTests
{
private Mock<ILogger> loggerMock;
private Mock<ISettings> settingsMock;
private Mock<ITaskbarSettings> settingsMock;
private Mock<ISplashScreen> splashScreenMock;
private Mock<ISystemComponent<ISystemKeyboardLayoutControl>> keyboardLayoutMock;
private Mock<ISystemComponent<ISystemPowerSupplyControl>> powerSupplyMock;
@ -38,7 +38,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour.Operations
public void Initialize()
{
loggerMock = new Mock<ILogger>();
settingsMock = new Mock<ISettings>();
settingsMock = new Mock<ITaskbarSettings>();
splashScreenMock = new Mock<ISplashScreen>();
keyboardLayoutMock = new Mock<ISystemComponent<ISystemKeyboardLayoutControl>>();
powerSupplyMock = new Mock<ISystemComponent<ISystemPowerSupplyControl>>();

View file

@ -22,7 +22,7 @@ namespace SafeExamBrowser.Core.Behaviour.Operations
{
private ILogger logger;
private INotificationController logController;
private ISettings settings;
private ITaskbarSettings settings;
private ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout;
private ISystemComponent<ISystemPowerSupplyControl> powerSupply;
private ISystemInfo systemInfo;
@ -34,7 +34,7 @@ namespace SafeExamBrowser.Core.Behaviour.Operations
public TaskbarOperation(
ILogger logger,
ISettings settings,
ITaskbarSettings settings,
ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout,
ISystemComponent<ISystemPowerSupplyControl> powerSupply,
ISystemInfo systemInfo,

View file

@ -92,7 +92,7 @@ namespace SafeExamBrowser
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
StartupOperations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, Taskbar));
StartupOperations.Enqueue(new TaskbarOperation(logger, settings, keyboardLayout, powerSupply, systemInfo, Taskbar, text, uiFactory));
StartupOperations.Enqueue(new TaskbarOperation(logger, settings.Taskbar, keyboardLayout, powerSupply, systemInfo, Taskbar, text, uiFactory));
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods));