diff --git a/README.md b/README.md index c57d2fe6..2eca7a03 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,7 @@ See https://github.com/SafeExamBrowser/seb-win/releases for the current, officia ### Project Status [![Build Status](https://ci.appveyor.com/api/projects/status/f1iknxq4qmtjjkj3?svg=true)](https://ci.appveyor.com/project/dbuechel/seb-win-refactoring) -[![Code Coverage](https://codecov.io/gh/SafeExamBrowser/seb-win-refactoring/branch/master/graph/badge.svg)](https://codecov.io/gh/SafeExamBrowser/seb-win-refactoring) [![Unit Test Status](https://img.shields.io/appveyor/tests/dbuechel/seb-win-refactoring.svg)](https://ci.appveyor.com/project/dbuechel/seb-win-refactoring/build/tests) +[![Code Coverage](https://codecov.io/gh/SafeExamBrowser/seb-win-refactoring/branch/master/graph/badge.svg)](https://codecov.io/gh/SafeExamBrowser/seb-win-refactoring) + +Latest build: https://ci.appveyor.com/project/dbuechel/seb-win-refactoring/build/artifacts diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs index 4eb83bab..950108be 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationController.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs @@ -15,7 +15,7 @@ using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.Contracts.UserInterface.Taskbar; -using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; +using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings; namespace SafeExamBrowser.Browser { @@ -23,14 +23,14 @@ namespace SafeExamBrowser.Browser { private IApplicationButton button; private IList instances = new List(); - private IBrowserSettings settings; - private IRuntimeInfo runtimeInfo; + private BrowserSettings settings; + private RuntimeInfo runtimeInfo; private IUserInterfaceFactory uiFactory; private IText text; public BrowserApplicationController( - IBrowserSettings settings, - IRuntimeInfo runtimeInfo, + BrowserSettings settings, + RuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory) { diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index 75d8e089..f2daad50 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -26,7 +26,7 @@ namespace SafeExamBrowser.Browser public event TerminatedEventHandler Terminated; public event NameChangedEventHandler NameChanged; - public BrowserApplicationInstance(IBrowserSettings settings, IText text, IUserInterfaceFactory uiFactory, bool isMainInstance) + public BrowserApplicationInstance(BrowserSettings settings, IText text, IUserInterfaceFactory uiFactory, bool isMainInstance) { Id = Guid.NewGuid(); diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs index 126dabc2..d3f45254 100644 --- a/SafeExamBrowser.Browser/BrowserControl.cs +++ b/SafeExamBrowser.Browser/BrowserControl.cs @@ -11,14 +11,14 @@ using CefSharp.WinForms; using SafeExamBrowser.Browser.Handlers; using SafeExamBrowser.Contracts.I18n; using SafeExamBrowser.Contracts.UserInterface; -using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; +using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings; namespace SafeExamBrowser.Browser { class BrowserControl : ChromiumWebBrowser, IBrowserControl { private AddressChangedEventHandler addressChanged; - private IBrowserSettings settings; + private BrowserSettings settings; private TitleChangedEventHandler titleChanged; private IText text; @@ -34,7 +34,7 @@ namespace SafeExamBrowser.Browser remove { titleChanged -= value; } } - public BrowserControl(IBrowserSettings settings, IText text) : base(settings.StartUrl) + public BrowserControl(BrowserSettings settings, IText text) : base(settings.StartUrl) { this.settings = settings; this.text = text; diff --git a/SafeExamBrowser.Browser/Handlers/BrowserContextMenuHandler.cs b/SafeExamBrowser.Browser/Handlers/BrowserContextMenuHandler.cs index 9953e561..5cd19943 100644 --- a/SafeExamBrowser.Browser/Handlers/BrowserContextMenuHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/BrowserContextMenuHandler.cs @@ -8,7 +8,7 @@ using CefSharp; using SafeExamBrowser.Contracts.I18n; -using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; +using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings; namespace SafeExamBrowser.Browser.Handlers { @@ -19,10 +19,10 @@ namespace SafeExamBrowser.Browser.Handlers { private const int DEV_CONSOLE_COMMAND = (int) CefMenuCommand.UserFirst + 1; - private IBrowserSettings settings; + private BrowserSettings settings; private IText text; - public BrowserContextMenuHandler(IBrowserSettings settings, IText text) + public BrowserContextMenuHandler(BrowserSettings settings, IText text) { this.settings = settings; this.text = text; diff --git a/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs b/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs index d96fe7dd..54a0ae84 100644 --- a/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs @@ -8,7 +8,7 @@ using System.Windows.Forms; using CefSharp; -using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; +using BrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.BrowserSettings; namespace SafeExamBrowser.Browser.Handlers { @@ -17,9 +17,9 @@ namespace SafeExamBrowser.Browser.Handlers /// internal class BrowserKeyboardHandler : IKeyboardHandler { - private IBrowserSettings settings; + private BrowserSettings settings; - public BrowserKeyboardHandler(IBrowserSettings settings) + public BrowserKeyboardHandler(BrowserSettings settings) { this.settings = settings; } diff --git a/SafeExamBrowser.Client.UnitTests/Behaviour/Operations/TaskbarOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Behaviour/Operations/TaskbarOperationTests.cs index 0e01539a..700cfcbb 100644 --- a/SafeExamBrowser.Client.UnitTests/Behaviour/Operations/TaskbarOperationTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Behaviour/Operations/TaskbarOperationTests.cs @@ -23,7 +23,7 @@ namespace SafeExamBrowser.Client.UnitTests.Behaviour.Operations public class TaskbarOperationTests { private Mock loggerMock; - private Mock settingsMock; + private Mock settingsMock; private Mock> keyboardLayoutMock; private Mock> powerSupplyMock; private Mock> wirelessNetworkMock; @@ -38,7 +38,7 @@ namespace SafeExamBrowser.Client.UnitTests.Behaviour.Operations public void Initialize() { loggerMock = new Mock(); - settingsMock = new Mock(); + settingsMock = new Mock(); keyboardLayoutMock = new Mock>(); powerSupplyMock = new Mock>(); wirelessNetworkMock = new Mock>(); diff --git a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs index 01573744..8020ffeb 100644 --- a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs @@ -18,13 +18,13 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications [TestClass] public class AboutNotificationControllerTests { - private Mock runtimeInfoMock; + private Mock runtimeInfoMock; private Mock uiFactoryMock; [TestInitialize] public void Initialize() { - runtimeInfoMock = new Mock(); + runtimeInfoMock = new Mock(); uiFactoryMock = new Mock(); } @@ -35,7 +35,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications var window = new Mock(); var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); + uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); sut.RegisterNotification(button); button.Click(); sut.Terminate(); @@ -50,7 +50,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications var window = new Mock(); var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); + uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); sut.RegisterNotification(button); button.Click(); button.Click(); @@ -58,7 +58,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications button.Click(); button.Click(); - uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny()), Times.Once); + uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny()), Times.Once); window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.BringToForeground(), Times.Exactly(4)); } diff --git a/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs b/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs index 5d56cde1..814e7590 100644 --- a/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs +++ b/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs @@ -18,14 +18,14 @@ namespace SafeExamBrowser.Client.Behaviour.Operations { internal class ConfigurationOperation : IOperation { - private IClientConfiguration configuration; + private ClientConfiguration configuration; private ILogger logger; private IRuntimeProxy runtime; public bool Abort { get; private set; } public IProgressIndicator ProgressIndicator { private get; set; } - public ConfigurationOperation(IClientConfiguration configuration, ILogger logger, IRuntimeProxy runtime) + public ConfigurationOperation(ClientConfiguration configuration, ILogger logger, IRuntimeProxy runtime) { this.configuration = configuration; this.logger = logger; diff --git a/SafeExamBrowser.Client/Behaviour/Operations/TaskbarOperation.cs b/SafeExamBrowser.Client/Behaviour/Operations/TaskbarOperation.cs index 29d1f1a2..8eb65183 100644 --- a/SafeExamBrowser.Client/Behaviour/Operations/TaskbarOperation.cs +++ b/SafeExamBrowser.Client/Behaviour/Operations/TaskbarOperation.cs @@ -23,7 +23,7 @@ namespace SafeExamBrowser.Client.Behaviour.Operations { private ILogger logger; private INotificationController logController; - private ITaskbarSettings settings; + private TaskbarSettings settings; private ISystemComponent keyboardLayout; private ISystemComponent powerSupply; private ISystemComponent wirelessNetwork; @@ -37,7 +37,7 @@ namespace SafeExamBrowser.Client.Behaviour.Operations public TaskbarOperation( ILogger logger, - ITaskbarSettings settings, + TaskbarSettings settings, ISystemComponent keyboardLayout, ISystemComponent powerSupply, ISystemComponent wirelessNetwork, diff --git a/SafeExamBrowser.Client/Communication/ClientHost.cs b/SafeExamBrowser.Client/Communication/ClientHost.cs index f4c3edf3..e0fa0dc9 100644 --- a/SafeExamBrowser.Client/Communication/ClientHost.cs +++ b/SafeExamBrowser.Client/Communication/ClientHost.cs @@ -33,13 +33,13 @@ namespace SafeExamBrowser.Client.Communication // TODO } - protected override IResponse OnReceive(IMessage message) + protected override Response OnReceive(Message message) { // TODO return null; } - protected override IResponse OnReceive(Message message) + protected override Response OnReceive(MessagePurport message) { // TODO return null; diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs index d3b2502c..aec4bb97 100644 --- a/SafeExamBrowser.Client/CompositionRoot.cs +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -37,7 +37,7 @@ namespace SafeExamBrowser.Client { internal class CompositionRoot { - private IClientConfiguration configuration; + private ClientConfiguration configuration; private ILogger logger; private INativeMethods nativeMethods; private ISystemInfo systemInfo; @@ -92,9 +92,9 @@ namespace SafeExamBrowser.Client private void Validate(string[] args) { - var hasFourParameters = args?.Length == 4; + var hasFour = args?.Length == 4; - if (hasFourParameters) + if (hasFour) { var hasLogfilePath = Uri.TryCreate(args?[1], UriKind.Absolute, out Uri filePath) && filePath.IsFile; var hasHostUri = Uri.TryCreate(args?[2], UriKind.Absolute, out Uri hostUri) && hostUri.IsWellFormedOriginalString(); diff --git a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs index d7795634..7523b8d5 100644 --- a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs +++ b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs @@ -17,11 +17,11 @@ namespace SafeExamBrowser.Client.Notifications internal class AboutNotificationController : INotificationController { private INotificationButton notification; - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IUserInterfaceFactory uiFactory; private IWindow window; - public AboutNotificationController(IRuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory) + public AboutNotificationController(RuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory) { this.runtimeInfo = runtimeInfo; this.uiFactory = uiFactory; diff --git a/SafeExamBrowser.Configuration/ClientConfiguration.cs b/SafeExamBrowser.Configuration/ClientConfiguration.cs deleted file mode 100644 index 672b045b..00000000 --- a/SafeExamBrowser.Configuration/ClientConfiguration.cs +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration -{ - [Serializable] - public class ClientConfiguration : IClientConfiguration - { - public Guid SessionId { get; set; } - public ISettings Settings { get; set; } - public IRuntimeInfo RuntimeInfo { get; set; } - } -} diff --git a/SafeExamBrowser.Configuration/ConfigurationRepository.cs b/SafeExamBrowser.Configuration/ConfigurationRepository.cs index c8a348c7..c2ce726b 100644 --- a/SafeExamBrowser.Configuration/ConfigurationRepository.cs +++ b/SafeExamBrowser.Configuration/ConfigurationRepository.cs @@ -19,9 +19,9 @@ namespace SafeExamBrowser.Configuration private RuntimeInfo runtimeInfo; public ISession CurrentSession { get; private set; } - public ISettings CurrentSettings { get; private set; } + public Settings CurrentSettings { get; private set; } - public IRuntimeInfo RuntimeInfo + public RuntimeInfo RuntimeInfo { get { @@ -47,7 +47,7 @@ namespace SafeExamBrowser.Configuration return session; } - public IClientConfiguration BuildClientConfiguration() + public ClientConfiguration BuildClientConfiguration() { return new ClientConfiguration { @@ -57,21 +57,23 @@ namespace SafeExamBrowser.Configuration }; } - public ISettings LoadSettings(Uri path) + public Settings LoadSettings(Uri path) { // TODO return LoadDefaultSettings(); } - public ISettings LoadDefaultSettings() + public Settings LoadDefaultSettings() { - var settings = new Settings.Settings + var settings = new Settings() { // TODO ServicePolicy = ServicePolicy.Optional }; + settings.Browser.StartUrl = "https://www.duckduckgo.com"; + CurrentSettings = settings; return settings; diff --git a/SafeExamBrowser.Configuration/RuntimeInfo.cs b/SafeExamBrowser.Configuration/RuntimeInfo.cs deleted file mode 100644 index b0cd2403..00000000 --- a/SafeExamBrowser.Configuration/RuntimeInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration; - -namespace SafeExamBrowser.Configuration -{ - [Serializable] - public class RuntimeInfo : IRuntimeInfo - { - public string AppDataFolder { get; set; } - public DateTime ApplicationStartTime { get; set; } - public string BrowserCachePath { get; set; } - public string BrowserLogFile { get; set; } - public string ClientAddress { get; set; } - public string ClientExecutablePath { get; set; } - public Guid ClientId { get; set; } - public string ClientLogFile { get; set; } - public string DefaultSettingsFileName { get; set; } - public string ProgramCopyright { get; set; } - public string ProgramDataFolder { get; set; } - public string ProgramTitle { get; set; } - public string ProgramVersion { get; set; } - public string RuntimeAddress { get; set; } - public Guid RuntimeId { get; set; } - public string RuntimeLogFile { get; set; } - public string ServiceAddress { get; set; } - } -} diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj index 58eb6f82..220d96e9 100644 --- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj +++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj @@ -53,17 +53,10 @@ - - - - - - - diff --git a/SafeExamBrowser.Configuration/Settings/BrowserSettings.cs b/SafeExamBrowser.Configuration/Settings/BrowserSettings.cs deleted file mode 100644 index 6c8f0c9b..00000000 --- a/SafeExamBrowser.Configuration/Settings/BrowserSettings.cs +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration.Settings -{ - [Serializable] - internal class BrowserSettings : IBrowserSettings - { - public bool AllowAddressBar => true; - public bool AllowBackwardNavigation => true; - public bool AllowDeveloperConsole => true; - public bool AllowForwardNavigation => true; - public bool AllowReloading => true; - public string CachePath { get; set; } - public bool FullScreenMode => false; - public string LogFile { get; set; } - public string StartUrl => "www.duckduckgo.com"; - } -} diff --git a/SafeExamBrowser.Configuration/Settings/KeyboardSettings.cs b/SafeExamBrowser.Configuration/Settings/KeyboardSettings.cs deleted file mode 100644 index 1bea3dac..00000000 --- a/SafeExamBrowser.Configuration/Settings/KeyboardSettings.cs +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration.Settings -{ - [Serializable] - internal class KeyboardSettings : IKeyboardSettings - { - public bool AllowAltTab => false; - - public bool AllowEsc => false; - - public bool AllowF5 => true; - } -} diff --git a/SafeExamBrowser.Configuration/Settings/MouseSettings.cs b/SafeExamBrowser.Configuration/Settings/MouseSettings.cs deleted file mode 100644 index 223fdb04..00000000 --- a/SafeExamBrowser.Configuration/Settings/MouseSettings.cs +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration.Settings -{ - [Serializable] - internal class MouseSettings : IMouseSettings - { - public bool AllowMiddleButton => false; - - public bool AllowRightButton => true; - } -} diff --git a/SafeExamBrowser.Configuration/Settings/Settings.cs b/SafeExamBrowser.Configuration/Settings/Settings.cs deleted file mode 100644 index 25159977..00000000 --- a/SafeExamBrowser.Configuration/Settings/Settings.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration.Settings -{ - [Serializable] - internal class Settings : ISettings - { - public ConfigurationMode ConfigurationMode { get; set; } - public KioskMode KioskMode { get; set; } - public ServicePolicy ServicePolicy { get; set; } - - public IBrowserSettings Browser { get; set; } - public IKeyboardSettings Keyboard { get; set; } - public IMouseSettings Mouse { get; set; } - public ITaskbarSettings Taskbar { get; set; } - - public Settings() - { - Browser = new BrowserSettings(); - Keyboard = new KeyboardSettings(); - Mouse = new MouseSettings(); - Taskbar = new TaskbarSettings(); - } - } -} diff --git a/SafeExamBrowser.Configuration/Settings/TaskbarSettings.cs b/SafeExamBrowser.Configuration/Settings/TaskbarSettings.cs deleted file mode 100644 index 097a0c43..00000000 --- a/SafeExamBrowser.Configuration/Settings/TaskbarSettings.cs +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Configuration.Settings; - -namespace SafeExamBrowser.Configuration.Settings -{ - [Serializable] - internal class TaskbarSettings : ITaskbarSettings - { - public bool AllowApplicationLog => true; - public bool AllowKeyboardLayout => true; - public bool AllowWirelessNetwork => true; - } -} diff --git a/SafeExamBrowser.Contracts/Communication/IClientProxy.cs b/SafeExamBrowser.Contracts/Communication/IClientProxy.cs index 7a624000..3585f249 100644 --- a/SafeExamBrowser.Contracts/Communication/IClientProxy.cs +++ b/SafeExamBrowser.Contracts/Communication/IClientProxy.cs @@ -15,6 +15,6 @@ namespace SafeExamBrowser.Contracts.Communication /// /// Instructs the client to submit its authentication data. /// - IAuthenticationResponse RequestAuthentication(); + AuthenticationResponse RequestAuthentication(); } } diff --git a/SafeExamBrowser.Contracts/Communication/ICommunication.cs b/SafeExamBrowser.Contracts/Communication/ICommunication.cs index 956e9393..d2f1d9b6 100644 --- a/SafeExamBrowser.Contracts/Communication/ICommunication.cs +++ b/SafeExamBrowser.Contracts/Communication/ICommunication.cs @@ -10,10 +10,15 @@ using System; using System.ServiceModel; using SafeExamBrowser.Contracts.Communication.Messages; using SafeExamBrowser.Contracts.Communication.Responses; +using SafeExamBrowser.Contracts.Configuration; namespace SafeExamBrowser.Contracts.Communication { [ServiceContract(SessionMode = SessionMode.Required)] + [ServiceKnownType(typeof(SimpleMessage))] + [ServiceKnownType(typeof(AuthenticationResponse))] + [ServiceKnownType(typeof(ConfigurationResponse))] + [ServiceKnownType(typeof(ClientConfiguration))] public interface ICommunication { /// @@ -21,18 +26,18 @@ namespace SafeExamBrowser.Contracts.Communication /// specified. Returns a response indicating whether the connection request was successful or not. /// [OperationContract(IsInitiating = true)] - IConnectionResponse Connect(Guid? token = null); + ConnectionResponse Connect(Guid? token = null); /// /// Closes a connection. Returns a response indicating whether the disconnection request was successful or not. /// [OperationContract(IsInitiating = false, IsTerminating = true)] - IDisconnectionResponse Disconnect(IDisconnectionMessage message); + DisconnectionResponse Disconnect(DisconnectionMessage message); /// /// Sends a message, optionally returning a response. If no response is expected, null will be returned. /// [OperationContract(IsInitiating = false)] - IResponse Send(IMessage message); + Response Send(Message message); } } diff --git a/SafeExamBrowser.Contracts/Communication/IRuntimeProxy.cs b/SafeExamBrowser.Contracts/Communication/IRuntimeProxy.cs index 27dd9c7d..4405486f 100644 --- a/SafeExamBrowser.Contracts/Communication/IRuntimeProxy.cs +++ b/SafeExamBrowser.Contracts/Communication/IRuntimeProxy.cs @@ -15,7 +15,7 @@ namespace SafeExamBrowser.Contracts.Communication /// /// Retrieves the application configuration from the runtime. /// - IClientConfiguration GetConfiguration(); + ClientConfiguration GetConfiguration(); /// /// Informs the runtime that the client is ready. diff --git a/SafeExamBrowser.Contracts/Communication/IServiceProxy.cs b/SafeExamBrowser.Contracts/Communication/IServiceProxy.cs index 4c51d731..f7dd5807 100644 --- a/SafeExamBrowser.Contracts/Communication/IServiceProxy.cs +++ b/SafeExamBrowser.Contracts/Communication/IServiceProxy.cs @@ -22,7 +22,7 @@ namespace SafeExamBrowser.Contracts.Communication /// /// Instructs the service to start a new session according to the given parameters. /// - void StartSession(Guid sessionId, ISettings settings); + void StartSession(Guid sessionId, Settings settings); /// /// Instructs the service to stop the specified session. diff --git a/SafeExamBrowser.Contracts/Communication/Messages/IDisconnectionMessage.cs b/SafeExamBrowser.Contracts/Communication/Messages/DisconnectionMessage.cs similarity index 82% rename from SafeExamBrowser.Contracts/Communication/Messages/IDisconnectionMessage.cs rename to SafeExamBrowser.Contracts/Communication/Messages/DisconnectionMessage.cs index 6fdc559d..ff4955b5 100644 --- a/SafeExamBrowser.Contracts/Communication/Messages/IDisconnectionMessage.cs +++ b/SafeExamBrowser.Contracts/Communication/Messages/DisconnectionMessage.cs @@ -6,9 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Messages { - public interface IDisconnectionMessage : IMessage + [Serializable] + public class DisconnectionMessage : Message { } } diff --git a/SafeExamBrowser.Contracts/Communication/Messages/Message.cs b/SafeExamBrowser.Contracts/Communication/Messages/Message.cs index 3223c403..6f9769e6 100644 --- a/SafeExamBrowser.Contracts/Communication/Messages/Message.cs +++ b/SafeExamBrowser.Contracts/Communication/Messages/Message.cs @@ -6,23 +6,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Messages { - public enum Message + [Serializable] + public class Message { /// - /// Requests an interlocutor to submit data for authentication. + /// The communication token needed for authentication. /// - Authenticate = 1, - - /// - /// Sent from the client to the runtime to indicate that the client is ready to operate. - /// - ClientIsReady, - - /// - /// Sent from the client to the runtime to ask for the client configuration. - /// - ConfigurationNeeded, + public Guid CommunicationToken { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Messages/IMessage.cs b/SafeExamBrowser.Contracts/Communication/Messages/MessagePurport.cs similarity index 50% rename from SafeExamBrowser.Contracts/Communication/Messages/IMessage.cs rename to SafeExamBrowser.Contracts/Communication/Messages/MessagePurport.cs index 2ce257b8..858c9f5b 100644 --- a/SafeExamBrowser.Contracts/Communication/Messages/IMessage.cs +++ b/SafeExamBrowser.Contracts/Communication/Messages/MessagePurport.cs @@ -10,11 +10,22 @@ using System; namespace SafeExamBrowser.Contracts.Communication.Messages { - public interface IMessage + [Serializable] + public enum MessagePurport { /// - /// The communication token needed for authentication. + /// Requests an interlocutor to submit data for authentication. /// - Guid CommunicationToken { get; set; } + Authenticate = 1, + + /// + /// Sent from the client to the runtime to indicate that the client is ready to operate. + /// + ClientIsReady, + + /// + /// Sent from the client to the runtime to ask for the client configuration. + /// + ConfigurationNeeded, } } diff --git a/SafeExamBrowser.Contracts/Communication/Messages/ISimpleMessage.cs b/SafeExamBrowser.Contracts/Communication/Messages/SimpleMessage.cs similarity index 79% rename from SafeExamBrowser.Contracts/Communication/Messages/ISimpleMessage.cs rename to SafeExamBrowser.Contracts/Communication/Messages/SimpleMessage.cs index 9ff65345..b46fb3de 100644 --- a/SafeExamBrowser.Contracts/Communication/Messages/ISimpleMessage.cs +++ b/SafeExamBrowser.Contracts/Communication/Messages/SimpleMessage.cs @@ -6,13 +6,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Messages { - public interface ISimpleMessage : IMessage + [Serializable] + public class SimpleMessage : Message { /// /// The purport of the message. /// - Message Purport { get; } + public MessagePurport Purport { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Responses/IAuthenticationResponse.cs b/SafeExamBrowser.Contracts/Communication/Responses/AuthenticationResponse.cs similarity index 80% rename from SafeExamBrowser.Contracts/Communication/Responses/IAuthenticationResponse.cs rename to SafeExamBrowser.Contracts/Communication/Responses/AuthenticationResponse.cs index 99644d75..51e20020 100644 --- a/SafeExamBrowser.Contracts/Communication/Responses/IAuthenticationResponse.cs +++ b/SafeExamBrowser.Contracts/Communication/Responses/AuthenticationResponse.cs @@ -6,13 +6,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Responses { - public interface IAuthenticationResponse : IResponse + [Serializable] + public class AuthenticationResponse : Response { /// /// The process identifier used for authentication. /// - int ProcessId { get; } + public int ProcessId { get; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Responses/IConfigurationResponse.cs b/SafeExamBrowser.Contracts/Communication/Responses/ConfigurationResponse.cs similarity index 78% rename from SafeExamBrowser.Contracts/Communication/Responses/IConfigurationResponse.cs rename to SafeExamBrowser.Contracts/Communication/Responses/ConfigurationResponse.cs index 41bd32aa..d8d996a5 100644 --- a/SafeExamBrowser.Contracts/Communication/Responses/IConfigurationResponse.cs +++ b/SafeExamBrowser.Contracts/Communication/Responses/ConfigurationResponse.cs @@ -6,15 +6,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using SafeExamBrowser.Contracts.Configuration; namespace SafeExamBrowser.Contracts.Communication.Responses { - public interface IConfigurationResponse : IResponse + [Serializable] + public class ConfigurationResponse : Response { /// /// The configuration to be used by the client. /// - IClientConfiguration Configuration { get; } + public ClientConfiguration Configuration { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Responses/IConnectionResponse.cs b/SafeExamBrowser.Contracts/Communication/Responses/ConnectionResponse.cs similarity index 79% rename from SafeExamBrowser.Contracts/Communication/Responses/IConnectionResponse.cs rename to SafeExamBrowser.Contracts/Communication/Responses/ConnectionResponse.cs index b60284c5..61ddb965 100644 --- a/SafeExamBrowser.Contracts/Communication/Responses/IConnectionResponse.cs +++ b/SafeExamBrowser.Contracts/Communication/Responses/ConnectionResponse.cs @@ -10,16 +10,17 @@ using System; namespace SafeExamBrowser.Contracts.Communication.Responses { - public interface IConnectionResponse : IResponse + [Serializable] + public class ConnectionResponse : Response { /// /// The communication token needed for authentication. Is null if a connection was refused. /// - Guid? CommunicationToken { get; } + public Guid? CommunicationToken { get; set; } /// /// Indicates whether the connection request has been accepted. /// - bool ConnectionEstablished { get; } + public bool ConnectionEstablished { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Responses/IDisconnectionResponse.cs b/SafeExamBrowser.Contracts/Communication/Responses/DisconnectionResponse.cs similarity index 78% rename from SafeExamBrowser.Contracts/Communication/Responses/IDisconnectionResponse.cs rename to SafeExamBrowser.Contracts/Communication/Responses/DisconnectionResponse.cs index b8bd5a28..ac432f35 100644 --- a/SafeExamBrowser.Contracts/Communication/Responses/IDisconnectionResponse.cs +++ b/SafeExamBrowser.Contracts/Communication/Responses/DisconnectionResponse.cs @@ -6,13 +6,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Responses { - public interface IDisconnectionResponse : IResponse + [Serializable] + public class DisconnectionResponse : Response { /// /// Indicates whether the connection has been terminated. /// - bool ConnectionTerminated { get; } + public bool ConnectionTerminated { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Communication/Responses/IResponse.cs b/SafeExamBrowser.Contracts/Communication/Responses/Response.cs similarity index 87% rename from SafeExamBrowser.Contracts/Communication/Responses/IResponse.cs rename to SafeExamBrowser.Contracts/Communication/Responses/Response.cs index 94ae6427..8774e824 100644 --- a/SafeExamBrowser.Contracts/Communication/Responses/IResponse.cs +++ b/SafeExamBrowser.Contracts/Communication/Responses/Response.cs @@ -6,9 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Communication.Responses { - public interface IResponse + [Serializable] + public class Response { } } diff --git a/SafeExamBrowser.Contracts/Configuration/IClientConfiguration.cs b/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs similarity index 75% rename from SafeExamBrowser.Contracts/Configuration/IClientConfiguration.cs rename to SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs index 07c0f176..06340e03 100644 --- a/SafeExamBrowser.Contracts/Configuration/IClientConfiguration.cs +++ b/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs @@ -7,25 +7,25 @@ */ using System; -using SafeExamBrowser.Contracts.Configuration.Settings; namespace SafeExamBrowser.Contracts.Configuration { - public interface IClientConfiguration + [Serializable] + public class ClientConfiguration { /// /// The unique identifier for the current session. /// - Guid SessionId { get; set; } + public Guid SessionId { get; set; } /// /// The application settings to be used by the client. /// - ISettings Settings { get; set; } + public Settings.Settings Settings { get; set; } /// /// The information about the current runtime. /// - IRuntimeInfo RuntimeInfo { get; set; } + public RuntimeInfo RuntimeInfo { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs b/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs index 60bc8b01..39db57df 100644 --- a/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs +++ b/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs @@ -23,17 +23,17 @@ namespace SafeExamBrowser.Contracts.Configuration /// Retrieves the current settings, i.e. the last ones which were loaded. If no settings have been loaded yet, this property will /// be null! /// - ISettings CurrentSettings { get; } + Settings.Settings CurrentSettings { get; } /// /// The runtime information for the currently running application instance. /// - IRuntimeInfo RuntimeInfo { get; } + RuntimeInfo RuntimeInfo { get; } /// /// Builds a configuration for the client component, given the currently loaded settings, session and runtime information. /// - IClientConfiguration BuildClientConfiguration(); + ClientConfiguration BuildClientConfiguration(); /// /// Initializes all relevant data for a new session. @@ -44,11 +44,11 @@ namespace SafeExamBrowser.Contracts.Configuration /// Attempts to load settings from the specified path. /// /// Thrown if the given path cannot be resolved to a settings file. - ISettings LoadSettings(Uri path); + Settings.Settings LoadSettings(Uri path); /// /// Loads the default settings. /// - ISettings LoadDefaultSettings(); + Settings.Settings LoadDefaultSettings(); } } diff --git a/SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs b/SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs similarity index 73% rename from SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs rename to SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs index 9f94793d..9487459b 100644 --- a/SafeExamBrowser.Contracts/Configuration/IRuntimeInfo.cs +++ b/SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs @@ -10,27 +10,28 @@ using System; namespace SafeExamBrowser.Contracts.Configuration { - public interface IRuntimeInfo + [Serializable] + public class RuntimeInfo { /// /// The path of the application data folder. /// - string AppDataFolder { get; } + public string AppDataFolder { get; set; } /// /// The point in time when the application was started. /// - DateTime ApplicationStartTime { get; } + public DateTime ApplicationStartTime { get; set; } /// /// The path where the browser cache is to be stored. /// - string BrowserCachePath { get; } + public string BrowserCachePath { get; set; } /// /// The file path under which the log of the browser component is to be stored. /// - string BrowserLogFile { get; } + public string BrowserLogFile { get; set; } /// /// The communication address of the client component. @@ -38,12 +39,12 @@ namespace SafeExamBrowser.Contracts.Configuration /// TODO: Will need to be updated for each new client instance! /// /// - string ClientAddress { get; } + public string ClientAddress { get; set; } /// /// The executable path of the client compontent. /// - string ClientExecutablePath { get; } + public string ClientExecutablePath { get; set; } /// /// The unique identifier for the currently running client instance. @@ -51,42 +52,42 @@ namespace SafeExamBrowser.Contracts.Configuration /// TODO: Will need to be updated for each new client instance! -> Remove if unused! /// /// - Guid ClientId { get; } + public Guid ClientId { get; set; } /// /// The file path under which the log of the client component is to be stored. /// - string ClientLogFile { get; } + public string ClientLogFile { get; set; } /// /// The default file name for application settings. /// - string DefaultSettingsFileName { get; } + public string DefaultSettingsFileName { get; set; } /// /// The copyright information for the application (i.e. the executing assembly). /// - string ProgramCopyright { get; } + public string ProgramCopyright { get; set; } /// /// The path of the program data folder. /// - string ProgramDataFolder { get; } + public string ProgramDataFolder { get; set; } /// /// The program title of the application (i.e. the executing assembly). /// - string ProgramTitle { get; } + public string ProgramTitle { get; set; } /// /// The program version of the application (i.e. the executing assembly). /// - string ProgramVersion { get; } + public string ProgramVersion { get; set; } /// /// The communication address of the runtime component. /// - string RuntimeAddress { get; } + public string RuntimeAddress { get; set; } /// /// The unique identifier for the currently running runtime instance. @@ -94,16 +95,16 @@ namespace SafeExamBrowser.Contracts.Configuration /// TODO: Remove if unused! /// /// - Guid RuntimeId { get; } + public Guid RuntimeId { get; set; } /// /// The file path under which the log of the runtime component is to be stored. /// - string RuntimeLogFile { get; } + public string RuntimeLogFile { get; set; } /// /// The communication address of the service component. /// - string ServiceAddress { get; } + public string ServiceAddress { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs similarity index 76% rename from SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs rename to SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs index b19d2a30..663dccb2 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/IBrowserSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/BrowserSettings.cs @@ -6,43 +6,46 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Configuration.Settings { - public interface IBrowserSettings + [Serializable] + public class BrowserSettings { /// /// Determines whether the user should be allowed to change the URL of a browser window. /// - bool AllowAddressBar { get; } + public bool AllowAddressBar { get; set; } /// /// Determines whether the user should be allowed to navigate backwards in a browser window. /// - bool AllowBackwardNavigation { get; } + public bool AllowBackwardNavigation { get; set; } /// /// Determines whether the user should be allowed to open the developer console of a browser window. /// - bool AllowDeveloperConsole { get; } + public bool AllowDeveloperConsole { get; set; } /// /// Determines whether the user should be allowed to navigate forwards in a browser window. /// - bool AllowForwardNavigation { get; } + public bool AllowForwardNavigation { get; set; } /// /// Determines whether the user should be allowed to reload webpages. /// - bool AllowReloading { get; } + public bool AllowReloading { get; set; } /// /// Determines whether the main browser window should be rendered in fullscreen mode, i.e. without window frame. /// - bool FullScreenMode { get; } + public bool FullScreenMode { get; set; } /// /// The start URL with which a new browser window should be loaded. /// - string StartUrl { get; } + public string StartUrl { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/IKeyboardSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/KeyboardSettings.cs similarity index 78% rename from SafeExamBrowser.Contracts/Configuration/Settings/IKeyboardSettings.cs rename to SafeExamBrowser.Contracts/Configuration/Settings/KeyboardSettings.cs index ec9ac7c4..e653936d 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/IKeyboardSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/KeyboardSettings.cs @@ -6,23 +6,26 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Configuration.Settings { - public interface IKeyboardSettings + [Serializable] + public class KeyboardSettings { /// /// Determines whether the user may use the ALT+TAB shortcut. /// - bool AllowAltTab { get; } + public bool AllowAltTab { get; set; } /// /// Determines whether the user may use the escape key. /// - bool AllowEsc { get; } + public bool AllowEsc { get; set; } /// /// Determines whether the user may use the F5 key. /// - bool AllowF5 { get; } + public bool AllowF5 { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/IMouseSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/MouseSettings.cs similarity index 79% rename from SafeExamBrowser.Contracts/Configuration/Settings/IMouseSettings.cs rename to SafeExamBrowser.Contracts/Configuration/Settings/MouseSettings.cs index 254b549b..38fe176b 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/IMouseSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/MouseSettings.cs @@ -6,18 +6,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Configuration.Settings { - public interface IMouseSettings + [Serializable] + public class MouseSettings { /// /// Determines whether the user may use the middle mouse button. /// - bool AllowMiddleButton { get; } + public bool AllowMiddleButton { get; set; } /// /// Determines whether the user may use the right mouse button. /// - bool AllowRightButton { get; } + public bool AllowRightButton { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs similarity index 62% rename from SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs rename to SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs index 81aa6b93..83178b3c 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/ISettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs @@ -6,43 +6,54 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Configuration.Settings { - public interface ISettings + [Serializable] + public class Settings { /// /// The mode which determines the configuration behaviour. /// - ConfigurationMode ConfigurationMode { get; } + public ConfigurationMode ConfigurationMode { get; set; } /// /// All browser-related settings. /// - IBrowserSettings Browser { get; } + public BrowserSettings Browser { get; set; } /// /// All keyboard-related settings. /// - IKeyboardSettings Keyboard { get; } + public KeyboardSettings Keyboard { get; set; } /// /// The kiosk mode which determines how the computer is locked down. /// - KioskMode KioskMode { get; } + public KioskMode KioskMode { get; set; } /// /// All mouse-related settings. /// - IMouseSettings Mouse { get; } + public MouseSettings Mouse { get; set; } /// /// The active policy for the service component. /// - ServicePolicy ServicePolicy { get; } + public ServicePolicy ServicePolicy { get; set; } /// /// All taskbar-related settings. /// - ITaskbarSettings Taskbar { get; } + public TaskbarSettings Taskbar { get; set; } + + public Settings() + { + Browser = new BrowserSettings(); + Keyboard = new KeyboardSettings(); + Mouse = new MouseSettings(); + Taskbar = new TaskbarSettings(); + } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/ITaskbarSettings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/TaskbarSettings.cs similarity index 77% rename from SafeExamBrowser.Contracts/Configuration/Settings/ITaskbarSettings.cs rename to SafeExamBrowser.Contracts/Configuration/Settings/TaskbarSettings.cs index 9c2420d9..ee113286 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/ITaskbarSettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/TaskbarSettings.cs @@ -6,23 +6,26 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; + namespace SafeExamBrowser.Contracts.Configuration.Settings { - public interface ITaskbarSettings + [Serializable] + public class TaskbarSettings { /// /// Determines whether the user may switch the keyboard layout during runtime. /// - bool AllowKeyboardLayout { get; } + public bool AllowKeyboardLayout { get; set; } /// /// Determines whether the user may access the application log during runtime. /// - bool AllowApplicationLog { get; } + public bool AllowApplicationLog { get; set; } /// /// Determines whether the user may control the wireless network connection during runtime. /// - bool AllowWirelessNetwork { get; } + public bool AllowWirelessNetwork { get; set; } } } diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj index 3d0a3240..a3d67b08 100644 --- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj +++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj @@ -64,17 +64,17 @@ - - - - - - - - - - + + + + + + + + + + @@ -86,12 +86,12 @@ - - - - + + + + - + diff --git a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs index b5c0f141..e6c2b663 100644 --- a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs +++ b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs @@ -18,7 +18,7 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Creates a new about window displaying information about the currently running application version. /// - IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo); + IWindow CreateAboutWindow(RuntimeInfo runtimeInfo); /// /// Creates a taskbar button, initialized with the given application information. @@ -28,7 +28,7 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Creates a new browser window loaded with the given browser control and settings. /// - IBrowserWindow CreateBrowserWindow(IBrowserControl control, IBrowserSettings settings); + IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings); /// /// Creates a new log window which runs on its own thread. @@ -54,12 +54,12 @@ namespace SafeExamBrowser.Contracts.UserInterface /// Creates a new runtime window which runs on its own thread. /// /// - IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo); + IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo); /// /// Creates a new splash screen which runs on its own thread. /// - ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo); + ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo); /// /// Creates a system control which allows to change the wireless network connection of the computer. diff --git a/SafeExamBrowser.Core/Communication/BaseHost.cs b/SafeExamBrowser.Core/Communication/BaseHost.cs index 777ae9f4..17fab5f8 100644 --- a/SafeExamBrowser.Core/Communication/BaseHost.cs +++ b/SafeExamBrowser.Core/Communication/BaseHost.cs @@ -12,7 +12,6 @@ using SafeExamBrowser.Contracts.Communication; using SafeExamBrowser.Contracts.Communication.Messages; using SafeExamBrowser.Contracts.Communication.Responses; using SafeExamBrowser.Contracts.Logging; -using SafeExamBrowser.Core.Communication.Responses; namespace SafeExamBrowser.Core.Communication { @@ -39,10 +38,10 @@ namespace SafeExamBrowser.Core.Communication protected abstract bool OnConnect(Guid? token); protected abstract void OnDisconnect(); - protected abstract IResponse OnReceive(IMessage message); - protected abstract IResponse OnReceive(Message message); + protected abstract Response OnReceive(Message message); + protected abstract Response OnReceive(MessagePurport message); - public IConnectionResponse Connect(Guid? token = null) + public ConnectionResponse Connect(Guid? token = null) { logger.Debug($"Received connection request with authentication token '{token}'."); @@ -60,7 +59,7 @@ namespace SafeExamBrowser.Core.Communication return response; } - public IDisconnectionResponse Disconnect(IDisconnectionMessage message) + public DisconnectionResponse Disconnect(DisconnectionMessage message) { var response = new DisconnectionResponse(); @@ -78,17 +77,17 @@ namespace SafeExamBrowser.Core.Communication return response; } - public IResponse Send(IMessage message) + public Response Send(Message message) { - IResponse response = null; + Response response = null; logger.Debug($"Received message '{message}'."); if (IsAuthorized(message?.CommunicationToken)) { - if (message is ISimpleMessage) + if (message is SimpleMessage) { - response = OnReceive((message as ISimpleMessage).Purport); + response = OnReceive((message as SimpleMessage).Purport); } else { diff --git a/SafeExamBrowser.Core/Communication/BaseProxy.cs b/SafeExamBrowser.Core/Communication/BaseProxy.cs index e26e56bb..0d4db168 100644 --- a/SafeExamBrowser.Core/Communication/BaseProxy.cs +++ b/SafeExamBrowser.Core/Communication/BaseProxy.cs @@ -12,7 +12,6 @@ using SafeExamBrowser.Contracts.Communication; using SafeExamBrowser.Contracts.Communication.Messages; using SafeExamBrowser.Contracts.Communication.Responses; using SafeExamBrowser.Contracts.Logging; -using SafeExamBrowser.Core.Communication.Messages; namespace SafeExamBrowser.Core.Communication { @@ -41,10 +40,12 @@ namespace SafeExamBrowser.Core.Communication (channel as ICommunicationObject).Opened += BaseProxy_Opened; (channel as ICommunicationObject).Opening += BaseProxy_Opening; + Logger.Debug($"Trying to connect to endpoint {address} with authentication token '{token}'..."); + var response = channel.Connect(token); communicationToken = response.CommunicationToken; - Logger.Debug($"Tried to connect to {address}, connection was {(response.ConnectionEstablished ? "established" : "refused")}."); + Logger.Debug($"Connection was {(response.ConnectionEstablished ? "established" : "refused")}."); return response.ConnectionEstablished; } @@ -61,7 +62,7 @@ namespace SafeExamBrowser.Core.Communication return response.ConnectionTerminated; } - protected IResponse Send(IMessage message) + protected Response Send(Message message) { FailIfNotConnected(nameof(Send)); @@ -74,7 +75,7 @@ namespace SafeExamBrowser.Core.Communication return response; } - protected IResponse Send(Message purport) + protected Response Send(MessagePurport purport) { FailIfNotConnected(nameof(Send)); @@ -129,12 +130,12 @@ namespace SafeExamBrowser.Core.Communication return channel == null ? "null" : $"in state '{(channel as ICommunicationObject).State}'"; } - private string ToString(IMessage message) + private string ToString(Message message) { return message != null ? $"message of type '{message.GetType()}'" : "no message"; } - private string ToString(IResponse response) + private string ToString(Response response) { return response != null ? $"response of type '{response.GetType()}'" : "no response"; } diff --git a/SafeExamBrowser.Core/Communication/ClientProxy.cs b/SafeExamBrowser.Core/Communication/ClientProxy.cs index 8eca3588..26b01a4e 100644 --- a/SafeExamBrowser.Core/Communication/ClientProxy.cs +++ b/SafeExamBrowser.Core/Communication/ClientProxy.cs @@ -19,9 +19,9 @@ namespace SafeExamBrowser.Core.Communication { } - public IAuthenticationResponse RequestAuthentication() + public AuthenticationResponse RequestAuthentication() { - return (IAuthenticationResponse) Send(Message.ClientIsReady); + return (AuthenticationResponse) Send(MessagePurport.ClientIsReady); } } } diff --git a/SafeExamBrowser.Core/Communication/Messages/BaseMessage.cs b/SafeExamBrowser.Core/Communication/Messages/BaseMessage.cs deleted file mode 100644 index 0c554bf2..00000000 --- a/SafeExamBrowser.Core/Communication/Messages/BaseMessage.cs +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Messages; - -namespace SafeExamBrowser.Core.Communication.Messages -{ - [Serializable] - internal class BaseMessage : IMessage - { - public Guid CommunicationToken { get; set; } - } -} diff --git a/SafeExamBrowser.Core/Communication/Messages/DisconnectionMessage.cs b/SafeExamBrowser.Core/Communication/Messages/DisconnectionMessage.cs deleted file mode 100644 index 65f6a533..00000000 --- a/SafeExamBrowser.Core/Communication/Messages/DisconnectionMessage.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Messages; - -namespace SafeExamBrowser.Core.Communication.Messages -{ - [Serializable] - internal class DisconnectionMessage : BaseMessage, IDisconnectionMessage - { - } -} diff --git a/SafeExamBrowser.Core/Communication/Messages/SimpleMessage.cs b/SafeExamBrowser.Core/Communication/Messages/SimpleMessage.cs deleted file mode 100644 index c19849be..00000000 --- a/SafeExamBrowser.Core/Communication/Messages/SimpleMessage.cs +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Messages; - -namespace SafeExamBrowser.Core.Communication.Messages -{ - [Serializable] - internal class SimpleMessage : BaseMessage, ISimpleMessage - { - public Message Purport { get; set; } - } -} diff --git a/SafeExamBrowser.Core/Communication/Responses/ConnectionResponse.cs b/SafeExamBrowser.Core/Communication/Responses/ConnectionResponse.cs deleted file mode 100644 index b66f437b..00000000 --- a/SafeExamBrowser.Core/Communication/Responses/ConnectionResponse.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Responses; - -namespace SafeExamBrowser.Core.Communication.Responses -{ - [Serializable] - internal class ConnectionResponse : IConnectionResponse - { - public Guid? CommunicationToken { get; set; } - public bool ConnectionEstablished { get; set; } - } -} diff --git a/SafeExamBrowser.Core/Communication/Responses/DisconnectionResponse.cs b/SafeExamBrowser.Core/Communication/Responses/DisconnectionResponse.cs deleted file mode 100644 index 2465f339..00000000 --- a/SafeExamBrowser.Core/Communication/Responses/DisconnectionResponse.cs +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Responses; - -namespace SafeExamBrowser.Core.Communication.Responses -{ - [Serializable] - internal class DisconnectionResponse : IDisconnectionResponse - { - public bool ConnectionTerminated { get; set; } - } -} diff --git a/SafeExamBrowser.Core/Communication/RuntimeProxy.cs b/SafeExamBrowser.Core/Communication/RuntimeProxy.cs index 8ef224e2..3065ff90 100644 --- a/SafeExamBrowser.Core/Communication/RuntimeProxy.cs +++ b/SafeExamBrowser.Core/Communication/RuntimeProxy.cs @@ -20,14 +20,14 @@ namespace SafeExamBrowser.Core.Communication { } - public IClientConfiguration GetConfiguration() + public ClientConfiguration GetConfiguration() { - return ((IConfigurationResponse) Send(Message.ConfigurationNeeded)).Configuration; + return ((ConfigurationResponse) Send(MessagePurport.ConfigurationNeeded)).Configuration; } public void InformClientReady() { - Send(Message.ClientIsReady); + Send(MessagePurport.ClientIsReady); } } } diff --git a/SafeExamBrowser.Core/Communication/ServiceProxy.cs b/SafeExamBrowser.Core/Communication/ServiceProxy.cs index b122ae88..8e45a2e4 100644 --- a/SafeExamBrowser.Core/Communication/ServiceProxy.cs +++ b/SafeExamBrowser.Core/Communication/ServiceProxy.cs @@ -21,7 +21,7 @@ namespace SafeExamBrowser.Core.Communication { } - public override bool Connect(Guid? token) + public override bool Connect(Guid? token = null) { if (IgnoreOperation(nameof(Connect))) { @@ -41,7 +41,7 @@ namespace SafeExamBrowser.Core.Communication return base.Disconnect(); } - public void StartSession(Guid sessionId, ISettings settings) + public void StartSession(Guid sessionId, Settings settings) { if (IgnoreOperation(nameof(StartSession))) { diff --git a/SafeExamBrowser.Core/SafeExamBrowser.Core.csproj b/SafeExamBrowser.Core/SafeExamBrowser.Core.csproj index 715c98e0..cff30db6 100644 --- a/SafeExamBrowser.Core/SafeExamBrowser.Core.csproj +++ b/SafeExamBrowser.Core/SafeExamBrowser.Core.csproj @@ -62,11 +62,6 @@ - - - - - diff --git a/SafeExamBrowser.Monitoring/Keyboard/KeyboardInterceptor.cs b/SafeExamBrowser.Monitoring/Keyboard/KeyboardInterceptor.cs index 7060d811..e1f89078 100644 --- a/SafeExamBrowser.Monitoring/Keyboard/KeyboardInterceptor.cs +++ b/SafeExamBrowser.Monitoring/Keyboard/KeyboardInterceptor.cs @@ -17,10 +17,10 @@ namespace SafeExamBrowser.Monitoring.Keyboard { public class KeyboardInterceptor : IKeyboardInterceptor { - private IKeyboardSettings settings; + private KeyboardSettings settings; private ILogger logger; - public KeyboardInterceptor(IKeyboardSettings settings, ILogger logger) + public KeyboardInterceptor(KeyboardSettings settings, ILogger logger) { this.logger = logger; this.settings = settings; diff --git a/SafeExamBrowser.Monitoring/Mouse/MouseInterceptor.cs b/SafeExamBrowser.Monitoring/Mouse/MouseInterceptor.cs index e752e6a0..1dc83168 100644 --- a/SafeExamBrowser.Monitoring/Mouse/MouseInterceptor.cs +++ b/SafeExamBrowser.Monitoring/Mouse/MouseInterceptor.cs @@ -15,9 +15,9 @@ namespace SafeExamBrowser.Monitoring.Mouse public class MouseInterceptor : IMouseInterceptor { private ILogger logger; - private IMouseSettings settings; + private MouseSettings settings; - public MouseInterceptor(ILogger logger, IMouseSettings settings) + public MouseInterceptor(ILogger logger, MouseSettings settings) { this.logger = logger; this.settings = settings; diff --git a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs index 0f14dc1f..9117fba3 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs @@ -23,9 +23,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations public class ConfigurationOperationTests { private Mock logger; - private Mock info; + private Mock info; private Mock repository; - private Mock settings; + private Mock settings; private Mock text; private Mock uiFactory; private ConfigurationOperation sut; @@ -34,9 +34,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations public void Initialize() { logger = new Mock(); - info = new Mock(); + info = new Mock(); repository = new Mock(); - settings = new Mock(); + settings = new Mock(); text = new Mock(); uiFactory = new Mock(); diff --git a/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs b/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs index e54a6336..4c8fe79c 100644 --- a/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs +++ b/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs @@ -21,7 +21,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations { private IConfigurationRepository repository; private ILogger logger; - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private IUserInterfaceFactory uiFactory; private string[] commandLineArgs; @@ -32,7 +32,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations public ConfigurationOperation( IConfigurationRepository repository, ILogger logger, - IRuntimeInfo runtimeInfo, + RuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory, string[] commandLineArgs) @@ -50,7 +50,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations logger.Info("Initializing application configuration..."); ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration); - ISettings settings; + Settings settings; var isValidUri = TryGetSettingsUri(out Uri uri); if (isValidUri) diff --git a/SafeExamBrowser.Runtime/Behaviour/Operations/SessionSequenceOperation.cs b/SafeExamBrowser.Runtime/Behaviour/Operations/SessionSequenceOperation.cs index 2331e96f..92ae60ca 100644 --- a/SafeExamBrowser.Runtime/Behaviour/Operations/SessionSequenceOperation.cs +++ b/SafeExamBrowser.Runtime/Behaviour/Operations/SessionSequenceOperation.cs @@ -102,35 +102,47 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations private void StartClient() { + const int TEN_SECONDS = 10000; + var clientReady = new AutoResetEvent(false); var clientReadyHandler = new CommunicationEventHandler(() => clientReady.Set()); var clientExecutable = configuration.RuntimeInfo.ClientExecutablePath; + var clientLogFile = $"{'"' + configuration.RuntimeInfo.ClientLogFile + '"'}"; var hostUri = configuration.RuntimeInfo.RuntimeAddress; var token = session.StartupToken.ToString("D"); runtimeHost.ClientReady += clientReadyHandler; - session.ClientProcess = processFactory.StartNew(clientExecutable, hostUri, token); + session.ClientProcess = processFactory.StartNew(clientExecutable, clientLogFile, hostUri, token); + + var clientStarted = clientReady.WaitOne(TEN_SECONDS); - clientReady.WaitOne(); runtimeHost.ClientReady -= clientReadyHandler; - if (client.Connect(session.StartupToken)) + // TODO: Check if client process alive! + if (clientStarted) { - var response = client.RequestAuthentication(); - - // TODO: Further integrity checks necessary? - if (session.ClientProcess.Id == response.ProcessId) + if (client.Connect(session.StartupToken)) { - sessionRunning = true; + var response = client.RequestAuthentication(); + + // TODO: Further integrity checks necessary? + if (session.ClientProcess.Id == response.ProcessId) + { + sessionRunning = true; + } + else + { + logger.Error("Failed to verify client integrity!"); + } } else { - logger.Error("Failed to verify client integrity!"); + logger.Error("Failed to connect to client!"); } } else { - logger.Error("Failed to connect to client!"); + logger.Error($"Failed to start client within {TEN_SECONDS / 1000} seconds!"); } } } diff --git a/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs b/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs index e4818601..2d78bbbb 100644 --- a/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs +++ b/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs @@ -28,7 +28,7 @@ namespace SafeExamBrowser.Runtime.Behaviour private IOperationSequence bootstrapSequence; private IOperationSequence sessionSequence; private IRuntimeHost runtimeHost; - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IRuntimeWindow runtimeWindow; private IServiceProxy service; private ISplashScreen splashScreen; @@ -42,7 +42,7 @@ namespace SafeExamBrowser.Runtime.Behaviour IOperationSequence bootstrapSequence, IOperationSequence sessionSequence, IRuntimeHost runtimeHost, - IRuntimeInfo runtimeInfo, + RuntimeInfo runtimeInfo, IServiceProxy service, Action shutdown, IUserInterfaceFactory uiFactory) @@ -140,6 +140,7 @@ namespace SafeExamBrowser.Runtime.Behaviour } else { + // TODO: Not when user chose to terminate after reconfiguration! Probably needs IOperationSequenceResult or alike... uiFactory.Show(TextKey.MessageBox_SessionStartError, TextKey.MessageBox_SessionStartErrorTitle, icon: MessageBoxIcon.Error); if (!initial) diff --git a/SafeExamBrowser.Runtime/Communication/Responses/ConfigurationResponse.cs b/SafeExamBrowser.Runtime/Communication/Responses/ConfigurationResponse.cs deleted file mode 100644 index 5096c4e6..00000000 --- a/SafeExamBrowser.Runtime/Communication/Responses/ConfigurationResponse.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using SafeExamBrowser.Contracts.Communication.Responses; -using SafeExamBrowser.Contracts.Configuration; - -namespace SafeExamBrowser.Runtime.Communication.Responses -{ - [Serializable] - internal class ConfigurationResponse : IConfigurationResponse - { - public IClientConfiguration Configuration { get; set; } - } -} diff --git a/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs b/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs index e81b65a6..60061e66 100644 --- a/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs +++ b/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs @@ -7,13 +7,13 @@ */ using System; +using System.Threading.Tasks; using SafeExamBrowser.Contracts.Communication; using SafeExamBrowser.Contracts.Communication.Messages; using SafeExamBrowser.Contracts.Communication.Responses; using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Core.Communication; -using SafeExamBrowser.Runtime.Communication.Responses; namespace SafeExamBrowser.Runtime.Communication { @@ -40,20 +40,20 @@ namespace SafeExamBrowser.Runtime.Communication // TODO } - protected override IResponse OnReceive(IMessage message) + protected override Response OnReceive(Message message) { // TODO return null; } - protected override IResponse OnReceive(Message message) + protected override Response OnReceive(MessagePurport message) { switch (message) { - case Message.ClientIsReady: + case MessagePurport.ClientIsReady: ClientReady?.Invoke(); break; - case Message.ConfigurationNeeded: + case MessagePurport.ConfigurationNeeded: return new ConfigurationResponse { Configuration = configuration.BuildClientConfiguration() }; } diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index be19cc49..4eb5c1df 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -29,7 +29,7 @@ namespace SafeExamBrowser.Runtime internal class CompositionRoot { private ILogger logger; - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private ISystemInfo systemInfo; internal IRuntimeController RuntimeController { get; private set; } diff --git a/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj b/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj index d5759f19..91984368 100644 --- a/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj +++ b/SafeExamBrowser.Runtime/SafeExamBrowser.Runtime.csproj @@ -93,7 +93,6 @@ - diff --git a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs index 65d38c7b..15cb9ad1 100644 --- a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs @@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Classic { public partial class AboutWindow : Window, IWindow { - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -26,7 +26,7 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public AboutWindow(IRuntimeInfo runtimeInfo, IText text) + public AboutWindow(RuntimeInfo runtimeInfo, IText text) { this.runtimeInfo = runtimeInfo; this.text = text; diff --git a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs index fd0d9bb2..9084889a 100644 --- a/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/BrowserWindow.xaml.cs @@ -18,7 +18,7 @@ namespace SafeExamBrowser.UserInterface.Classic public partial class BrowserWindow : Window, IBrowserWindow { private bool isMainWindow; - private IBrowserSettings settings; + private BrowserSettings settings; public WindowClosingEventHandler closing; public bool IsMainWindow @@ -45,7 +45,7 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public BrowserWindow(IBrowserControl browserControl, IBrowserSettings settings) + public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings) { this.settings = settings; diff --git a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs index dbad843a..b30de8f0 100644 --- a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs @@ -21,7 +21,7 @@ namespace SafeExamBrowser.UserInterface.Classic { private bool allowClose; private ILogContentFormatter formatter; - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private RuntimeWindowViewModel model; private WindowClosingEventHandler closing; @@ -32,7 +32,7 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public RuntimeWindow(ILogContentFormatter formatter, IRuntimeInfo runtimeInfo, IText text) + public RuntimeWindow(ILogContentFormatter formatter, RuntimeInfo runtimeInfo, IText text) { this.formatter = formatter; this.runtimeInfo = runtimeInfo; diff --git a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs index 78d7c884..bfc502d8 100644 --- a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs @@ -19,7 +19,7 @@ namespace SafeExamBrowser.UserInterface.Classic { private bool allowClose; private ProgressIndicatorViewModel model = new ProgressIndicatorViewModel(); - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -29,7 +29,7 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public SplashScreen(IRuntimeInfo runtimeInfo, IText text) + public SplashScreen(RuntimeInfo runtimeInfo, IText text) { this.runtimeInfo = runtimeInfo; this.text = text; diff --git a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs index 1d40e0e0..e79d6ac4 100644 --- a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs @@ -29,7 +29,7 @@ namespace SafeExamBrowser.UserInterface.Classic this.text = text; } - public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo) + public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo) { return new AboutWindow(runtimeInfo, text); } @@ -39,7 +39,7 @@ namespace SafeExamBrowser.UserInterface.Classic return new ApplicationButton(info); } - public IBrowserWindow CreateBrowserWindow(IBrowserControl control, IBrowserSettings settings) + public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings) { return new BrowserWindow(control, settings); } @@ -84,7 +84,7 @@ namespace SafeExamBrowser.UserInterface.Classic return new PowerSupplyControl(); } - public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo) + public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) { RuntimeWindow runtimeWindow = null; var windowReadyEvent = new AutoResetEvent(false); @@ -108,7 +108,7 @@ namespace SafeExamBrowser.UserInterface.Classic return runtimeWindow; } - public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo) + public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); diff --git a/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs index d0d90ac1..edce6581 100644 --- a/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs @@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 { public partial class AboutWindow : Window, IWindow { - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -26,7 +26,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public AboutWindow(IRuntimeInfo runtimeInfo, IText text) + public AboutWindow(RuntimeInfo runtimeInfo, IText text) { this.runtimeInfo = runtimeInfo; this.text = text; diff --git a/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs index f4022464..29d7ca44 100644 --- a/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/BrowserWindow.xaml.cs @@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 public partial class BrowserWindow : Window, IBrowserWindow { private bool isMainWindow; - private IBrowserSettings settings; + private BrowserSettings settings; public WindowClosingEventHandler closing; public bool IsMainWindow @@ -43,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public BrowserWindow(IBrowserControl browserControl, IBrowserSettings settings) + public BrowserWindow(IBrowserControl browserControl, BrowserSettings settings) { this.settings = settings; diff --git a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs index eaae84c1..4c5e1af5 100644 --- a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs @@ -19,7 +19,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 { private bool allowClose; private SplashScreenViewModel model = new SplashScreenViewModel(); - private IRuntimeInfo runtimeInfo; + private RuntimeInfo runtimeInfo; private IText text; private WindowClosingEventHandler closing; @@ -29,7 +29,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public SplashScreen(IRuntimeInfo runtimeInfo, IText text) + public SplashScreen(RuntimeInfo runtimeInfo, IText text) { this.runtimeInfo = runtimeInfo; this.text = text; diff --git a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs index dd9b58d6..0af95856 100644 --- a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs @@ -28,7 +28,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 this.text = text; } - public IWindow CreateAboutWindow(IRuntimeInfo runtimeInfo) + public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo) { return new AboutWindow(runtimeInfo, text); } @@ -38,7 +38,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 return new ApplicationButton(info); } - public IBrowserWindow CreateBrowserWindow(IBrowserControl control, IBrowserSettings settings) + public IBrowserWindow CreateBrowserWindow(IBrowserControl control, BrowserSettings settings) { return new BrowserWindow(control, settings); } @@ -84,13 +84,13 @@ namespace SafeExamBrowser.UserInterface.Windows10 return new PowerSupplyControl(); } - public IRuntimeWindow CreateRuntimeWindow(IRuntimeInfo runtimeInfo) + public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) { // TODO throw new System.NotImplementedException(); } - public ISplashScreen CreateSplashScreen(IRuntimeInfo runtimeInfo) + public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); diff --git a/SafeExamBrowser.WindowsApi/Kernel32.cs b/SafeExamBrowser.WindowsApi/Kernel32.cs index dd5a42e3..3311cbef 100644 --- a/SafeExamBrowser.WindowsApi/Kernel32.cs +++ b/SafeExamBrowser.WindowsApi/Kernel32.cs @@ -21,14 +21,14 @@ namespace SafeExamBrowser.WindowsApi internal static extern bool CreateProcess( string lpApplicationName, string lpCommandLine, - ref SECURITY_ATTRIBUTES lpProcessAttributes, - ref SECURITY_ATTRIBUTES lpThreadAttributes, + IntPtr lpProcessAttributes, + IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, - out PROCESS_INFORMATION lpProcessInformation); + ref PROCESS_INFORMATION lpProcessInformation); [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern IntPtr GetModuleHandle(string lpModuleName); diff --git a/SafeExamBrowser.WindowsApi/ProcessFactory.cs b/SafeExamBrowser.WindowsApi/ProcessFactory.cs index 2f29cecb..d339b237 100644 --- a/SafeExamBrowser.WindowsApi/ProcessFactory.cs +++ b/SafeExamBrowser.WindowsApi/ProcessFactory.cs @@ -29,15 +29,15 @@ namespace SafeExamBrowser.WindowsApi public IProcess StartNew(string path, params string[] args) { + var commandLine = $"{'"' + path + '"'} {String.Join(" ", args)}"; var processInfo = new PROCESS_INFORMATION(); - var pAttr = new SECURITY_ATTRIBUTES(); - var tAttr = new SECURITY_ATTRIBUTES(); var startupInfo = new STARTUPINFO(); startupInfo.cb = Marshal.SizeOf(startupInfo); - startupInfo.lpDesktop = desktop.CurrentName; + // TODO: + //startupInfo.lpDesktop = desktop.CurrentName; - var success = Kernel32.CreateProcess(null, path, ref pAttr, ref tAttr, true, Constant.NORMAL_PRIORITY_CLASS, IntPtr.Zero, null, ref startupInfo, out processInfo); + var success = Kernel32.CreateProcess(null, commandLine, IntPtr.Zero, IntPtr.Zero, true, Constant.NORMAL_PRIORITY_CLASS, IntPtr.Zero, null, ref startupInfo, ref processInfo); if (!success) { diff --git a/SafeExamBrowser.WindowsApi/SafeExamBrowser.WindowsApi.csproj b/SafeExamBrowser.WindowsApi/SafeExamBrowser.WindowsApi.csproj index b974fb73..596479ef 100644 --- a/SafeExamBrowser.WindowsApi/SafeExamBrowser.WindowsApi.csproj +++ b/SafeExamBrowser.WindowsApi/SafeExamBrowser.WindowsApi.csproj @@ -74,7 +74,6 @@ - diff --git a/SafeExamBrowser.WindowsApi/Types/SECURITY_ATTRIBUTES.cs b/SafeExamBrowser.WindowsApi/Types/SECURITY_ATTRIBUTES.cs deleted file mode 100644 index dad5d43f..00000000 --- a/SafeExamBrowser.WindowsApi/Types/SECURITY_ATTRIBUTES.cs +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018 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 System; -using System.Runtime.InteropServices; - -namespace SafeExamBrowser.WindowsApi.Types -{ - /// - /// See http://pinvoke.net/default.aspx/Structures/SECURITY_ATTRIBUTES.html. - /// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa379560(v=vs.85).aspx. - /// - [StructLayout(LayoutKind.Sequential)] - internal struct SECURITY_ATTRIBUTES - { - public int nLength; - public IntPtr lpSecurityDescriptor; - public int bInheritHandle; - } -}