diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs index b71c1755..f3035232 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationController.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs @@ -24,11 +24,11 @@ namespace SafeExamBrowser.Browser { public class BrowserApplicationController : IBrowserApplicationController { + private AppConfig appConfig; private IApplicationButton button; private IList instances; private ILogger logger; private IMessageBox messageBox; - private RuntimeInfo runtimeInfo; private BrowserSettings settings; private IText text; private IUserInterfaceFactory uiFactory; @@ -36,17 +36,17 @@ namespace SafeExamBrowser.Browser public event DownloadRequestedEventHandler ConfigurationDownloadRequested; public BrowserApplicationController( + AppConfig appConfig, BrowserSettings settings, - RuntimeInfo runtimeInfo, ILogger logger, IMessageBox messageBox, IText text, IUserInterfaceFactory uiFactory) { + this.appConfig = appConfig; this.instances = new List(); this.logger = logger; this.messageBox = messageBox; - this.runtimeInfo = runtimeInfo; this.settings = settings; this.text = text; this.uiFactory = uiFactory; @@ -82,7 +82,7 @@ namespace SafeExamBrowser.Browser private void CreateNewInstance() { - var instance = new BrowserApplicationInstance(settings, runtimeInfo, text, uiFactory, instances.Count == 0); + var instance = new BrowserApplicationInstance(appConfig, settings, text, uiFactory, instances.Count == 0); instance.Initialize(); instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args); @@ -97,8 +97,8 @@ namespace SafeExamBrowser.Browser { var cefSettings = new CefSettings { - CachePath = runtimeInfo.BrowserCachePath, - LogFile = runtimeInfo.BrowserLogFile, + CachePath = appConfig.BrowserCachePath, + LogFile = appConfig.BrowserLogFile, // TODO: Set according to current application LogLevel, but avoid verbose! LogSeverity = LogSeverity.Info }; diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index 1b9aa6e3..c136a97d 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -20,10 +20,10 @@ namespace SafeExamBrowser.Browser { internal class BrowserApplicationInstance : IApplicationInstance { + private AppConfig appConfig; private IBrowserControl control; private IBrowserWindow window; private bool isMainInstance; - private RuntimeInfo runtimeInfo; private BrowserSettings settings; private IText text; private IUserInterfaceFactory uiFactory; @@ -37,14 +37,14 @@ namespace SafeExamBrowser.Browser public event TerminatedEventHandler Terminated; public BrowserApplicationInstance( + AppConfig appConfig, BrowserSettings settings, - RuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory, bool isMainInstance) { + this.appConfig = appConfig; this.isMainInstance = isMainInstance; - this.runtimeInfo = runtimeInfo; this.settings = settings; this.text = text; this.uiFactory = uiFactory; @@ -52,7 +52,7 @@ namespace SafeExamBrowser.Browser internal void Initialize() { - var downloadHandler = new DownloadHandler(settings, runtimeInfo); + var downloadHandler = new DownloadHandler(appConfig, settings); Id = Guid.NewGuid(); downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args); diff --git a/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs b/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs index f5366503..6972d94c 100644 --- a/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs @@ -22,24 +22,24 @@ namespace SafeExamBrowser.Browser.Handlers /// internal class DownloadHandler : IDownloadHandler { + private AppConfig appConfig; private BrowserSettings settings; - private RuntimeInfo runtimeInfo; private ConcurrentDictionary callbacks; public event DownloadRequestedEventHandler ConfigurationDownloadRequested; - public DownloadHandler(BrowserSettings settings, RuntimeInfo runtimeInfo) + public DownloadHandler(AppConfig appConfig, BrowserSettings settings) { + this.appConfig = appConfig; this.callbacks = new ConcurrentDictionary(); this.settings = settings; - this.runtimeInfo = runtimeInfo; } public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var uri = new Uri(downloadItem.Url); var extension = Path.GetExtension(uri.AbsolutePath); - var isConfigFile = String.Equals(extension, runtimeInfo.ConfigurationFileExtension, StringComparison.InvariantCultureIgnoreCase); + var isConfigFile = String.Equals(extension, appConfig.ConfigurationFileExtension, StringComparison.InvariantCultureIgnoreCase); if (isConfigFile) { diff --git a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs index 01a6871f..927e3448 100644 --- a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs @@ -18,14 +18,14 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications [TestClass] public class AboutNotificationControllerTests { - private Mock runtimeInfoMock; - private Mock uiFactoryMock; + private Mock appConfig; + private Mock uiFactory; [TestInitialize] public void Initialize() { - runtimeInfoMock = new Mock(); - uiFactoryMock = new Mock(); + appConfig = new Mock(); + uiFactory = new Mock(); } [TestMethod] @@ -33,9 +33,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications { var button = new NotificationButtonMock(); var window = new Mock(); - var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); + uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); sut.RegisterNotification(button); button.Click(); sut.Terminate(); @@ -48,9 +48,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications { var button = new NotificationButtonMock(); var window = new Mock(); - var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object); - uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object); + uiFactory.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); + uiFactory.Verify(u => u.CreateAboutWindow(It.IsAny()), Times.Once); window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.BringToForeground(), Times.Exactly(4)); } @@ -67,7 +67,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications public void MustSubscribeToClickEvent() { var button = new NotificationButtonMock(); - var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); + var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object); sut.RegisterNotification(button); diff --git a/SafeExamBrowser.Client/Behaviour/ClientController.cs b/SafeExamBrowser.Client/Behaviour/ClientController.cs index 92762797..0e3bca5b 100644 --- a/SafeExamBrowser.Client/Behaviour/ClientController.cs +++ b/SafeExamBrowser.Client/Behaviour/ClientController.cs @@ -39,22 +39,22 @@ namespace SafeExamBrowser.Client.Behaviour private ITaskbar taskbar; private IUserInterfaceFactory uiFactory; private IWindowMonitor windowMonitor; - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; public IBrowserApplicationController Browser { private get; set; } public IClientHost ClientHost { private get; set; } public Guid SessionId { private get; set; } public Settings Settings { private get; set; } - public RuntimeInfo RuntimeInfo + public AppConfig AppConfig { set { - runtimeInfo = value; + appConfig = value; if (splashScreen != null) { - splashScreen.RuntimeInfo = value; + splashScreen.AppConfig = value; } } } @@ -204,7 +204,7 @@ namespace SafeExamBrowser.Client.Behaviour { args.AllowDownload = true; args.Callback = Browser_ConfigurationDownloadFinished; - args.DownloadPath = Path.Combine(runtimeInfo.DownloadDirectory, fileName); + args.DownloadPath = Path.Combine(appConfig.DownloadDirectory, fileName); } } else diff --git a/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs b/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs index d95282de..520cca18 100644 --- a/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs +++ b/SafeExamBrowser.Client/Behaviour/Operations/ConfigurationOperation.cs @@ -40,13 +40,13 @@ namespace SafeExamBrowser.Client.Behaviour.Operations { var config = runtime.GetConfiguration(); - configuration.RuntimeInfo = config.RuntimeInfo; + configuration.AppConfig = config.AppConfig; configuration.SessionId = config.SessionId; configuration.Settings = config.Settings; logger.Info("Successfully retrieved the application configuration from the runtime."); - logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}"); - logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId}"); + logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}"); + logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId}"); logger.Info($" -> Session-ID: {configuration.SessionId}"); } catch (Exception e) diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs index 1ecfc8b9..a7a8e1f7 100644 --- a/SafeExamBrowser.Client/CompositionRoot.cs +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -152,7 +152,7 @@ namespace SafeExamBrowser.Client private IOperation BuildBrowserOperation() { var moduleLogger = new ModuleLogger(logger, typeof(BrowserApplicationController)); - var browserController = new BrowserApplicationController(configuration.Settings.Browser, configuration.RuntimeInfo, moduleLogger, messageBox, text, uiFactory); + var browserController = new BrowserApplicationController(configuration.AppConfig, configuration.Settings.Browser, moduleLogger, messageBox, text, uiFactory); var browserInfo = new BrowserApplicationInfo(); var operation = new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory); @@ -165,7 +165,7 @@ namespace SafeExamBrowser.Client { var processId = Process.GetCurrentProcess().Id; var factory = new HostObjectFactory(); - var host = new ClientHost(configuration.RuntimeInfo.ClientAddress, factory, new ModuleLogger(logger, typeof(ClientHost)), processId); + var host = new ClientHost(configuration.AppConfig.ClientAddress, factory, new ModuleLogger(logger, typeof(ClientHost)), processId); var operation = new CommunicationOperation(host, logger); clientHost = host; @@ -204,9 +204,9 @@ namespace SafeExamBrowser.Client private void UpdateClientControllerDependencies() { + ClientController.AppConfig = configuration.AppConfig; ClientController.Browser = browserController; ClientController.ClientHost = clientHost; - ClientController.RuntimeInfo = configuration.RuntimeInfo; ClientController.SessionId = configuration.SessionId; ClientController.Settings = configuration.Settings; } diff --git a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs index f921701e..cb411a43 100644 --- a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs +++ b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs @@ -17,13 +17,13 @@ namespace SafeExamBrowser.Client.Notifications internal class AboutNotificationController : INotificationController { private INotificationButton notification; - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IUserInterfaceFactory uiFactory; private IWindow window; - public AboutNotificationController(RuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory) + public AboutNotificationController(AppConfig appConfig, IUserInterfaceFactory uiFactory) { - this.runtimeInfo = runtimeInfo; + this.appConfig = appConfig; this.uiFactory = uiFactory; } @@ -43,7 +43,7 @@ namespace SafeExamBrowser.Client.Notifications { if (window == null) { - window = uiFactory.CreateAboutWindow(runtimeInfo); + window = uiFactory.CreateAboutWindow(appConfig); window.Closing += () => window = null; window.Show(); diff --git a/SafeExamBrowser.Configuration/ConfigurationRepository.cs b/SafeExamBrowser.Configuration/ConfigurationRepository.cs index 83a6b693..1139d8d5 100644 --- a/SafeExamBrowser.Configuration/ConfigurationRepository.cs +++ b/SafeExamBrowser.Configuration/ConfigurationRepository.cs @@ -19,22 +19,22 @@ namespace SafeExamBrowser.Configuration private const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser"; private bool firstSession = true; - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; public ISessionData CurrentSession { get; private set; } public Settings CurrentSettings { get; private set; } public string ReconfigurationFilePath { get; set; } - public RuntimeInfo RuntimeInfo + public AppConfig AppConfig { get { - if (runtimeInfo == null) + if (appConfig == null) { - InitializeRuntimeInfo(); + InitializeAppConfig(); } - return runtimeInfo; + return appConfig; } } @@ -42,7 +42,7 @@ namespace SafeExamBrowser.Configuration { return new ClientConfiguration { - RuntimeInfo = RuntimeInfo, + AppConfig = AppConfig, SessionId = CurrentSession.Id, Settings = CurrentSettings }; @@ -58,7 +58,7 @@ namespace SafeExamBrowser.Configuration if (!firstSession) { - UpdateRuntimeInfo(); + UpdateAppConfig(); } else { @@ -96,7 +96,7 @@ namespace SafeExamBrowser.Configuration CurrentSettings.Taskbar.AllowWirelessNetwork = true; } - private void InitializeRuntimeInfo() + private void InitializeAppConfig() { var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser)); var executable = Assembly.GetEntryAssembly(); @@ -104,32 +104,32 @@ namespace SafeExamBrowser.Configuration var logFolder = Path.Combine(appDataFolder, "Logs"); var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s"); - runtimeInfo = new RuntimeInfo(); - runtimeInfo.ApplicationStartTime = startTime; - runtimeInfo.AppDataFolder = appDataFolder; - runtimeInfo.BrowserCachePath = Path.Combine(appDataFolder, "Cache"); - runtimeInfo.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt"); - runtimeInfo.ClientId = Guid.NewGuid(); - runtimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; - runtimeInfo.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe"); - runtimeInfo.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt"); - runtimeInfo.ConfigurationFileExtension = ".seb"; - runtimeInfo.DefaultSettingsFileName = "SebClientSettings.seb"; - runtimeInfo.DownloadDirectory = Path.Combine(appDataFolder, "Downloads"); - runtimeInfo.ProgramCopyright = executable.GetCustomAttribute().Copyright; - runtimeInfo.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser)); - runtimeInfo.ProgramTitle = executable.GetCustomAttribute().Title; - runtimeInfo.ProgramVersion = executable.GetCustomAttribute().InformationalVersion; - runtimeInfo.RuntimeId = Guid.NewGuid(); - runtimeInfo.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}"; - runtimeInfo.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt"); - runtimeInfo.ServiceAddress = $"{BASE_ADDRESS}/service"; + appConfig = new AppConfig(); + appConfig.ApplicationStartTime = startTime; + appConfig.AppDataFolder = appDataFolder; + appConfig.BrowserCachePath = Path.Combine(appDataFolder, "Cache"); + appConfig.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt"); + appConfig.ClientId = Guid.NewGuid(); + appConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; + appConfig.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe"); + appConfig.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt"); + appConfig.ConfigurationFileExtension = ".seb"; + appConfig.DefaultSettingsFileName = "SebClientSettings.seb"; + appConfig.DownloadDirectory = Path.Combine(appDataFolder, "Downloads"); + appConfig.ProgramCopyright = executable.GetCustomAttribute().Copyright; + appConfig.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser)); + appConfig.ProgramTitle = executable.GetCustomAttribute().Title; + appConfig.ProgramVersion = executable.GetCustomAttribute().InformationalVersion; + appConfig.RuntimeId = Guid.NewGuid(); + appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}"; + appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt"); + appConfig.ServiceAddress = $"{BASE_ADDRESS}/service"; } - private void UpdateRuntimeInfo() + private void UpdateAppConfig() { - RuntimeInfo.ClientId = Guid.NewGuid(); - RuntimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; + AppConfig.ClientId = Guid.NewGuid(); + AppConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; } } } diff --git a/SafeExamBrowser.Contracts/Behaviour/IClientController.cs b/SafeExamBrowser.Contracts/Behaviour/IClientController.cs index c56377f0..cb12b680 100644 --- a/SafeExamBrowser.Contracts/Behaviour/IClientController.cs +++ b/SafeExamBrowser.Contracts/Behaviour/IClientController.cs @@ -19,6 +19,11 @@ namespace SafeExamBrowser.Contracts.Behaviour /// public interface IClientController { + /// + /// The global configuration information to be used during application execution. + /// + AppConfig AppConfig { set; } + /// /// The controller for the browser application. /// @@ -29,11 +34,6 @@ namespace SafeExamBrowser.Contracts.Behaviour /// IClientHost ClientHost { set; } - /// - /// The runtime information to be used during application execution. - /// - RuntimeInfo RuntimeInfo { set; } - /// /// The session identifier of the currently running session. /// diff --git a/SafeExamBrowser.Contracts/Browser/DownloadEventArgs.cs b/SafeExamBrowser.Contracts/Browser/DownloadEventArgs.cs index ddda083a..09c45e18 100644 --- a/SafeExamBrowser.Contracts/Browser/DownloadEventArgs.cs +++ b/SafeExamBrowser.Contracts/Browser/DownloadEventArgs.cs @@ -9,7 +9,7 @@ namespace SafeExamBrowser.Contracts.Browser { /// - /// TODO + /// The event arguments used for all download events fired by the . /// public class DownloadEventArgs { diff --git a/SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs b/SafeExamBrowser.Contracts/Configuration/AppConfig.cs similarity index 97% rename from SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs rename to SafeExamBrowser.Contracts/Configuration/AppConfig.cs index 87c305b6..8ac71cd7 100644 --- a/SafeExamBrowser.Contracts/Configuration/RuntimeInfo.cs +++ b/SafeExamBrowser.Contracts/Configuration/AppConfig.cs @@ -12,10 +12,9 @@ namespace SafeExamBrowser.Contracts.Configuration { /// /// Defines the fundamental, global configuration information for all application components. - /// TODO: Rename to Globals or GlobalConfiguration or alike! /// [Serializable] - public class RuntimeInfo + public class AppConfig { /// /// The path of the application data folder. diff --git a/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs b/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs index 02fe277e..dc98c060 100644 --- a/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs +++ b/SafeExamBrowser.Contracts/Configuration/ClientConfiguration.cs @@ -16,6 +16,11 @@ namespace SafeExamBrowser.Contracts.Configuration [Serializable] public class ClientConfiguration { + /// + /// The global application configuration. + /// + public AppConfig AppConfig { get; set; } + /// /// The unique identifier for the current session. /// @@ -25,10 +30,5 @@ namespace SafeExamBrowser.Contracts.Configuration /// The application settings to be used by the client. /// public Settings.Settings Settings { get; set; } - - /// - /// The information about the current runtime. - /// - public RuntimeInfo RuntimeInfo { get; set; } } } diff --git a/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs b/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs index 0e8f7f94..670ac24e 100644 --- a/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs +++ b/SafeExamBrowser.Contracts/Configuration/IConfigurationRepository.cs @@ -15,6 +15,11 @@ namespace SafeExamBrowser.Contracts.Configuration /// public interface IConfigurationRepository { + /// + /// The global configuration information for the currently running application instance. + /// + AppConfig AppConfig { get; } + /// /// Retrieves the current session data, i.e. the last one which was initialized. If no session has been initialized yet, this /// property will be null! @@ -32,11 +37,6 @@ namespace SafeExamBrowser.Contracts.Configuration /// string ReconfigurationFilePath { get; set; } - /// - /// The runtime information for the currently running application instance. - /// - RuntimeInfo RuntimeInfo { get; } - /// /// Builds a configuration for the client component, given the currently loaded settings, session and runtime information. /// diff --git a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj index 9957f64b..c8a2a291 100644 --- a/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj +++ b/SafeExamBrowser.Contracts/SafeExamBrowser.Contracts.csproj @@ -96,7 +96,7 @@ - + diff --git a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs index 1555e823..410e0215 100644 --- a/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs +++ b/SafeExamBrowser.Contracts/UserInterface/IUserInterfaceFactory.cs @@ -25,7 +25,7 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Creates a new about window displaying information about the currently running application version. /// - IWindow CreateAboutWindow(RuntimeInfo runtimeInfo); + IWindow CreateAboutWindow(AppConfig appConfig); /// /// Creates a taskbar button, initialized with the given application information. @@ -66,12 +66,12 @@ namespace SafeExamBrowser.Contracts.UserInterface /// Creates a new runtime window which runs on its own thread. /// /// - IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo); + IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig); /// /// Creates a new splash screen which runs on its own thread. /// - ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null); + ISplashScreen CreateSplashScreen(AppConfig appConfig = null); /// /// Creates a system control which allows to change the wireless network connection of the computer. diff --git a/SafeExamBrowser.Contracts/UserInterface/Windows/ISplashScreen.cs b/SafeExamBrowser.Contracts/UserInterface/Windows/ISplashScreen.cs index bf62ed3c..43cbb0cc 100644 --- a/SafeExamBrowser.Contracts/UserInterface/Windows/ISplashScreen.cs +++ b/SafeExamBrowser.Contracts/UserInterface/Windows/ISplashScreen.cs @@ -16,8 +16,8 @@ namespace SafeExamBrowser.Contracts.UserInterface.Windows public interface ISplashScreen : IProgressIndicator, IWindow { /// - /// The runtime information used to display version and copyright information. Can be updated during the execution of a procedure. + /// The global configuration used to display version and copyright information. Can be updated during the execution of a procedure. /// - RuntimeInfo RuntimeInfo { set; } + AppConfig AppConfig { set; } } } diff --git a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientOperationTests.cs index 50bb559b..cd31681e 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientOperationTests.cs @@ -25,6 +25,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations { private Action clientReady; private Action terminated; + private AppConfig appConfig; private Mock configuration; private Mock proxy; private Mock logger; @@ -32,13 +33,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations private Mock processFactory; private Mock proxyFactory; private Mock runtimeHost; - private RuntimeInfo runtimeInfo; private Mock session; private ClientOperation sut; [TestInitialize] public void Initialize() { + appConfig = new AppConfig(); configuration = new Mock(); clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null)); logger = new Mock(); @@ -47,7 +48,6 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations proxy = new Mock(); proxyFactory = new Mock(); runtimeHost = new Mock(); - runtimeInfo = new RuntimeInfo(); session = new Mock(); terminated = new Action(() => { @@ -56,7 +56,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations }); configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); - configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo); + configuration.SetupGet(c => c.AppConfig).Returns(appConfig); proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); sut = new ClientOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0); diff --git a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientTerminationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientTerminationOperationTests.cs index 5084ff68..404f67b0 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientTerminationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ClientTerminationOperationTests.cs @@ -22,6 +22,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations public class ClientTerminationOperationTests { private Action clientReady; + private AppConfig appConfig; private Mock configuration; private Mock proxy; private Mock logger; @@ -29,13 +30,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations private Mock processFactory; private Mock proxyFactory; private Mock runtimeHost; - private RuntimeInfo runtimeInfo; private Mock session; private ClientTerminationOperation sut; [TestInitialize] public void Initialize() { + appConfig = new AppConfig(); configuration = new Mock(); clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null)); logger = new Mock(); @@ -44,11 +45,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations proxy = new Mock(); proxyFactory = new Mock(); runtimeHost = new Mock(); - runtimeInfo = new RuntimeInfo(); session = new Mock(); configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); - configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo); + configuration.SetupGet(c => c.AppConfig).Returns(appConfig); proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); sut = new ClientTerminationOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0); diff --git a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs index ae6e7c5e..b0de0a62 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/ConfigurationOperationTests.cs @@ -29,13 +29,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations [TestClass] public class ConfigurationOperationTests { + private AppConfig appConfig; private Mock logger; private Mock messageBox; private Mock passwordDialog; private Mock repository; private Mock resourceLoader; private Mock runtimeHost; - private RuntimeInfo runtimeInfo; private Settings settings; private Mock text; private Mock uiFactory; @@ -44,22 +44,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations [TestInitialize] public void Initialize() { + appConfig = new AppConfig(); logger = new Mock(); messageBox = new Mock(); passwordDialog = new Mock(); repository = new Mock(); resourceLoader = new Mock(); runtimeHost = new Mock(); - runtimeInfo = new RuntimeInfo(); settings = new Settings(); text = new Mock(); uiFactory = new Mock(); - repository.SetupGet(r => r.CurrentSettings).Returns(settings); + appConfig.AppDataFolder = @"C:\Not\Really\AppData"; + appConfig.DefaultSettingsFileName = "SettingsDummy.txt"; + appConfig.ProgramDataFolder = @"C:\Not\Really\ProgramData"; - runtimeInfo.AppDataFolder = @"C:\Not\Really\AppData"; - runtimeInfo.DefaultSettingsFileName = "SettingsDummy.txt"; - runtimeInfo.ProgramDataFolder = @"C:\Not\Really\ProgramData"; + repository.SetupGet(r => r.CurrentSettings).Returns(settings); uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny(), It.IsAny())).Returns(passwordDialog.Object); } @@ -70,12 +70,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations var url = @"http://www.safeexambrowser.org/whatever.seb"; var location = Path.GetDirectoryName(GetType().Assembly.Location); - runtimeInfo.ProgramDataFolder = location; - runtimeInfo.AppDataFolder = location; + appConfig.ProgramDataFolder = location; + appConfig.AppDataFolder = location; repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); var resource = new Uri(url); @@ -88,12 +88,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations { var location = Path.GetDirectoryName(GetType().Assembly.Location); - runtimeInfo.ProgramDataFolder = location; - runtimeInfo.AppDataFolder = $@"{location}\WRONG"; + appConfig.ProgramDataFolder = location; + appConfig.AppDataFolder = $@"{location}\WRONG"; repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); sut.Perform(); var resource = new Uri(Path.Combine(location, "SettingsDummy.txt")); @@ -106,11 +106,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations { var location = Path.GetDirectoryName(GetType().Assembly.Location); - runtimeInfo.AppDataFolder = location; + appConfig.AppDataFolder = location; repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); sut.Perform(); var resource = new Uri(Path.Combine(location, "SettingsDummy.txt")); @@ -121,7 +121,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations [TestMethod] public void MustFallbackToDefaultsAsLastPrio() { - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); sut.Perform(); repository.Verify(r => r.LoadDefaultSettings(), Times.Once); @@ -130,11 +130,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations [TestMethod] public void MustAbortIfWishedByUser() { - runtimeInfo.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location); + appConfig.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location); messageBox.Setup(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).Returns(MessageBoxResult.Yes); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); var result = sut.Perform(); @@ -147,7 +147,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations messageBox.Setup(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).Returns(MessageBoxResult.No); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); var result = sut.Perform(); @@ -160,7 +160,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations settings.ConfigurationMode = ConfigurationMode.Exam; repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); sut.Perform(); messageBox.Verify(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); @@ -171,10 +171,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations { repository.Setup(r => r.LoadDefaultSettings()); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); sut.Perform(); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new string[] { }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new string[] { }); sut.Perform(); repository.Verify(r => r.LoadDefaultSettings(), Times.Exactly(2)); @@ -185,7 +185,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations { var uri = @"an/invalid\uri.'*%yolo/()你好"; - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", uri }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", uri }); sut.Perform(); } @@ -198,7 +198,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations passwordDialog.Setup(d => d.Show(null)).Returns(result); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); repository.Verify(r => r.LoadSettings(It.IsAny(), null, null), Times.Exactly(5)); @@ -213,7 +213,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations passwordDialog.Setup(d => d.Show(null)).Returns(result); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); repository.Verify(r => r.LoadSettings(It.IsAny(), null, null), Times.Exactly(5)); @@ -230,7 +230,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny(), password, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); repository.Verify(r => r.LoadSettings(It.IsAny(), null, null), Times.Once); @@ -248,7 +248,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny(), null, password)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); repository.Verify(r => r.LoadSettings(It.IsAny(), null, null), Times.Once); @@ -264,7 +264,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); var result = sut.Perform(); @@ -280,7 +280,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); var result = sut.Perform(); @@ -302,7 +302,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations repository.Setup(r => r.LoadSettings(It.IsAny(), null, settingsPassword)).Returns(LoadStatus.AdminPasswordNeeded).Callback(adminCallback); repository.Setup(r => r.LoadSettings(It.IsAny(), adminPassword, settingsPassword)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); repository.Verify(r => r.LoadSettings(It.IsAny(), null, null), Times.Once); @@ -323,7 +323,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); settings.KioskMode = KioskMode.DisableExplorerShell; - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); clientProxy.Verify(c => c.RequestPassword(It.IsAny(), It.IsAny()), Times.Never); @@ -349,7 +349,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); settings.KioskMode = KioskMode.CreateNewDesktop; - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); sut.Perform(); clientProxy.Verify(c => c.RequestPassword(It.IsAny(), It.IsAny()), Times.AtLeastOnce); @@ -375,7 +375,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); settings.KioskMode = KioskMode.CreateNewDesktop; - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); var result = sut.Perform(); @@ -390,7 +390,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny())).Returns(false); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.InvalidData); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); var result = sut.Perform(); @@ -405,7 +405,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny())).Returns(true); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.InvalidData); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url }); var result = sut.Perform(); @@ -422,7 +422,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations repository.SetupGet(r => r.ReconfigurationFilePath).Returns(resource.AbsolutePath); repository.Setup(r => r.LoadSettings(It.Is(u => u.Equals(resource)), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); var result = sut.Repeat(); @@ -439,7 +439,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations repository.SetupGet(r => r.ReconfigurationFilePath).Returns(null as string); repository.Setup(r => r.LoadSettings(It.IsAny(), null, null)).Returns(LoadStatus.Success); - sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null); + sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null); var result = sut.Repeat(); diff --git a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/SessionInitializationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/SessionInitializationOperationTests.cs index 2fe62512..c2bb8cc9 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/SessionInitializationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Behaviour/Operations/SessionInitializationOperationTests.cs @@ -19,24 +19,24 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations [TestClass] public class SessionInitializationOperationTests { - private SessionInitializationOperation sut; + private AppConfig appConfig; private Mock configuration; private Mock logger; private Mock runtimeHost; - private RuntimeInfo runtimeInfo; private Mock session; + private SessionInitializationOperation sut; [TestInitialize] public void Initialize() { + appConfig = new AppConfig(); configuration = new Mock(); logger = new Mock(); runtimeHost = new Mock(); - runtimeInfo = new RuntimeInfo(); session = new Mock(); configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); - configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo); + configuration.SetupGet(c => c.AppConfig).Returns(appConfig); sut = new SessionInitializationOperation(configuration.Object, logger.Object, runtimeHost.Object); } diff --git a/SafeExamBrowser.Runtime/Behaviour/Operations/ClientOperation.cs b/SafeExamBrowser.Runtime/Behaviour/Operations/ClientOperation.cs index 1622ac55..4869dd55 100644 --- a/SafeExamBrowser.Runtime/Behaviour/Operations/ClientOperation.cs +++ b/SafeExamBrowser.Runtime/Behaviour/Operations/ClientOperation.cs @@ -87,9 +87,9 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations var clientReadyEvent = new AutoResetEvent(false); var clientReadyEventHandler = new CommunicationEventHandler(() => clientReadyEvent.Set()); - var clientExecutable = configuration.RuntimeInfo.ClientExecutablePath; - var clientLogFile = $"{'"' + configuration.RuntimeInfo.ClientLogFile + '"'}"; - var hostUri = configuration.RuntimeInfo.RuntimeAddress; + var clientExecutable = configuration.AppConfig.ClientExecutablePath; + var clientLogFile = $"{'"' + configuration.AppConfig.ClientLogFile + '"'}"; + var hostUri = configuration.AppConfig.RuntimeAddress; var token = configuration.CurrentSession.StartupToken.ToString("D"); logger.Info("Starting new client process..."); @@ -108,7 +108,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations } logger.Info("Client has been successfully started and initialized. Creating communication proxy for client host..."); - ClientProxy = proxyFactory.CreateClientProxy(configuration.RuntimeInfo.ClientAddress); + ClientProxy = proxyFactory.CreateClientProxy(configuration.AppConfig.ClientAddress); if (!ClientProxy.Connect(configuration.CurrentSession.StartupToken)) { diff --git a/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs b/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs index 1c4c5dec..cfcf0db5 100644 --- a/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs +++ b/SafeExamBrowser.Runtime/Behaviour/Operations/ConfigurationOperation.cs @@ -24,12 +24,12 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations { internal class ConfigurationOperation : IOperation { - private IConfigurationRepository repository; + private IConfigurationRepository configuration; private ILogger logger; private IMessageBox messageBox; private IResourceLoader resourceLoader; private IRuntimeHost runtimeHost; - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IText text; private IUserInterfaceFactory uiFactory; private string[] commandLineArgs; @@ -37,22 +37,22 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations public IProgressIndicator ProgressIndicator { private get; set; } public ConfigurationOperation( - IConfigurationRepository repository, + AppConfig appConfig, + IConfigurationRepository configuration, ILogger logger, IMessageBox messageBox, IResourceLoader resourceLoader, IRuntimeHost runtimeHost, - RuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory, string[] commandLineArgs) { - this.repository = repository; + this.appConfig = appConfig; this.logger = logger; this.messageBox = messageBox; + this.configuration = configuration; this.resourceLoader = resourceLoader; this.runtimeHost = runtimeHost; - this.runtimeInfo = runtimeInfo; this.text = text; this.uiFactory = uiFactory; this.commandLineArgs = commandLineArgs; @@ -78,7 +78,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations } logger.Info("No valid settings resource specified nor found in PROGRAMDATA or APPDATA - loading default settings..."); - repository.LoadDefaultSettings(); + configuration.LoadDefaultSettings(); return OperationResult.Success; } @@ -88,7 +88,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations logger.Info("Initializing new application configuration..."); ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration); - var isValidUri = TryValidateSettingsUri(repository.ReconfigurationFilePath, out Uri uri); + var isValidUri = TryValidateSettingsUri(configuration.ReconfigurationFilePath, out Uri uri); if (isValidUri) { @@ -119,7 +119,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations for (int adminAttempts = 0, settingsAttempts = 0; adminAttempts < 5 && settingsAttempts < 5;) { - status = repository.LoadSettings(uri, adminPassword, settingsPassword); + status = configuration.LoadSettings(uri, adminPassword, settingsPassword); if (status == LoadStatus.AdminPasswordNeeded || status == LoadStatus.SettingsPasswordNeeded) { @@ -152,8 +152,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations private bool TryGetPassword(PasswordRequestPurpose purpose, out string password) { - var isStartup = repository.CurrentSession == null; - var isRunningOnDefaultDesktop = repository.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell; + var isStartup = configuration.CurrentSession == null; + var isRunningOnDefaultDesktop = configuration.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell; if (isStartup || isRunningOnDefaultDesktop) { @@ -200,7 +200,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations }); runtimeHost.PasswordReceived += responseEventHandler; - repository.CurrentSession.ClientProxy.RequestPassword(purpose, requestId); + configuration.CurrentSession.ClientProxy.RequestPassword(purpose, requestId); responseEvent.WaitOne(); runtimeHost.PasswordReceived -= responseEventHandler; @@ -220,8 +220,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations { if (resourceLoader.IsHtmlResource(uri)) { - repository.LoadDefaultSettings(); - repository.CurrentSettings.Browser.StartUrl = uri.AbsoluteUri; + configuration.LoadDefaultSettings(); + configuration.CurrentSettings.Browser.StartUrl = uri.AbsoluteUri; logger.Info($"The specified URI '{uri.AbsoluteUri}' appears to point to a HTML resource, setting it as startup URL."); status = LoadStatus.Success; @@ -236,8 +236,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations { var path = string.Empty; var isValidUri = false; - var programDataSettings = Path.Combine(runtimeInfo.ProgramDataFolder, runtimeInfo.DefaultSettingsFileName); - var appDataSettings = Path.Combine(runtimeInfo.AppDataFolder, runtimeInfo.DefaultSettingsFileName); + var programDataSettings = Path.Combine(appConfig.ProgramDataFolder, appConfig.DefaultSettingsFileName); + var appDataSettings = Path.Combine(appConfig.AppDataFolder, appConfig.DefaultSettingsFileName); uri = null; @@ -277,7 +277,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations private void HandleClientConfiguration(ref OperationResult result) { - if (result == OperationResult.Success && repository.CurrentSettings.ConfigurationMode == ConfigurationMode.ConfigureClient) + if (result == OperationResult.Success && configuration.CurrentSettings.ConfigurationMode == ConfigurationMode.ConfigureClient) { var abort = IsConfigurationSufficient(); diff --git a/SafeExamBrowser.Runtime/Behaviour/Operations/SessionInitializationOperation.cs b/SafeExamBrowser.Runtime/Behaviour/Operations/SessionInitializationOperation.cs index b6acf632..b75d0912 100644 --- a/SafeExamBrowser.Runtime/Behaviour/Operations/SessionInitializationOperation.cs +++ b/SafeExamBrowser.Runtime/Behaviour/Operations/SessionInitializationOperation.cs @@ -57,8 +57,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations configuration.InitializeSessionConfiguration(); runtimeHost.StartupToken = configuration.CurrentSession.StartupToken; - logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}"); - logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId} (as reference, does not change)"); + logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}"); + logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId} (as reference, does not change)"); logger.Info($" -> Session-ID: {configuration.CurrentSession.Id}"); } } diff --git a/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs b/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs index c1e038f8..8e1a01b3 100644 --- a/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs +++ b/SafeExamBrowser.Runtime/Behaviour/RuntimeController.cs @@ -26,13 +26,13 @@ namespace SafeExamBrowser.Runtime.Behaviour { private bool sessionRunning; + private AppConfig appConfig; private IConfigurationRepository configuration; private ILogger logger; private IMessageBox messageBox; private IOperationSequence bootstrapSequence; private IOperationSequence sessionSequence; private IRuntimeHost runtimeHost; - private RuntimeInfo runtimeInfo; private IRuntimeWindow runtimeWindow; private IServiceProxy service; private ISplashScreen splashScreen; @@ -40,23 +40,23 @@ namespace SafeExamBrowser.Runtime.Behaviour private IUserInterfaceFactory uiFactory; public RuntimeController( + AppConfig appConfig, IConfigurationRepository configuration, ILogger logger, IMessageBox messageBox, IOperationSequence bootstrapSequence, IOperationSequence sessionSequence, IRuntimeHost runtimeHost, - RuntimeInfo runtimeInfo, IServiceProxy service, Action shutdown, IUserInterfaceFactory uiFactory) { + this.appConfig = appConfig; this.configuration = configuration; this.bootstrapSequence = bootstrapSequence; this.logger = logger; this.messageBox = messageBox; this.runtimeHost = runtimeHost; - this.runtimeInfo = runtimeInfo; this.sessionSequence = sessionSequence; this.service = service; this.shutdown = shutdown; @@ -67,8 +67,8 @@ namespace SafeExamBrowser.Runtime.Behaviour { logger.Info("--- Initiating startup procedure ---"); - runtimeWindow = uiFactory.CreateRuntimeWindow(runtimeInfo); - splashScreen = uiFactory.CreateSplashScreen(runtimeInfo); + runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig); + splashScreen = uiFactory.CreateSplashScreen(appConfig); bootstrapSequence.ProgressIndicator = splashScreen; sessionSequence.ProgressIndicator = runtimeWindow; diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index 735174ed..31f50298 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -28,8 +28,8 @@ namespace SafeExamBrowser.Runtime { internal class CompositionRoot { + private AppConfig appConfig; private ILogger logger; - private RuntimeInfo runtimeInfo; private ISystemInfo systemInfo; internal IRuntimeController RuntimeController { get; private set; } @@ -43,7 +43,7 @@ namespace SafeExamBrowser.Runtime var nativeMethods = new NativeMethods(); logger = new Logger(); - runtimeInfo = configuration.RuntimeInfo; + appConfig = configuration.AppConfig; systemInfo = new SystemInfo(); InitializeLogging(); @@ -55,8 +55,8 @@ namespace SafeExamBrowser.Runtime var processFactory = new ProcessFactory(desktop, new ModuleLogger(logger, typeof(ProcessFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), logger); var resourceLoader = new ResourceLoader(); - var runtimeHost = new RuntimeHost(runtimeInfo.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost))); - var serviceProxy = new ServiceProxy(runtimeInfo.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy))); + var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost))); + var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy))); var bootstrapOperations = new Queue(); var sessionOperations = new Queue(); @@ -64,7 +64,7 @@ namespace SafeExamBrowser.Runtime bootstrapOperations.Enqueue(new I18nOperation(logger, text)); bootstrapOperations.Enqueue(new CommunicationOperation(runtimeHost, logger)); - sessionOperations.Enqueue(new ConfigurationOperation(configuration, logger, messageBox, resourceLoader, runtimeHost, runtimeInfo, text, uiFactory, args)); + sessionOperations.Enqueue(new ConfigurationOperation(appConfig, configuration, logger, messageBox, resourceLoader, runtimeHost, text, uiFactory, args)); sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost)); sessionOperations.Enqueue(new ServiceOperation(configuration, logger, serviceProxy, text)); sessionOperations.Enqueue(new ClientTerminationOperation(configuration, logger, processFactory, proxyFactory, runtimeHost, TEN_SECONDS)); @@ -74,19 +74,19 @@ namespace SafeExamBrowser.Runtime var bootstrapSequence = new OperationSequence(logger, bootstrapOperations); var sessionSequence = new OperationSequence(logger, sessionOperations); - RuntimeController = new RuntimeController(configuration, logger, messageBox, bootstrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, shutdown, uiFactory); + RuntimeController = new RuntimeController(appConfig, configuration, logger, messageBox, bootstrapSequence, sessionSequence, runtimeHost, serviceProxy, shutdown, uiFactory); } internal void LogStartupInformation() { - logger.Log($"/* {runtimeInfo.ProgramTitle}, Version {runtimeInfo.ProgramVersion}"); - logger.Log($"/* {runtimeInfo.ProgramCopyright}"); + logger.Log($"/* {appConfig.ProgramTitle}, Version {appConfig.ProgramVersion}"); + logger.Log($"/* {appConfig.ProgramCopyright}"); logger.Log($"/* "); logger.Log($"/* Please visit https://www.github.com/SafeExamBrowser for more information."); logger.Log(string.Empty); - logger.Log($"# Application started at {runtimeInfo.ApplicationStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}"); + logger.Log($"# Application started at {appConfig.ApplicationStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}"); logger.Log($"# Running on {systemInfo.OperatingSystemInfo}"); - logger.Log($"# Runtime-ID: {runtimeInfo.RuntimeId}"); + logger.Log($"# Runtime-ID: {appConfig.RuntimeId}"); logger.Log(string.Empty); } @@ -97,7 +97,7 @@ namespace SafeExamBrowser.Runtime private void InitializeLogging() { - var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeInfo.RuntimeLogFile); + var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), appConfig.RuntimeLogFile); logFileWriter.Initialize(); logger.Subscribe(logFileWriter); diff --git a/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/AboutWindow.xaml.cs index 0a6d2f5c..9fe78b49 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 RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IText text; private WindowClosingEventHandler closing; @@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public AboutWindow(RuntimeInfo runtimeInfo, IText text) + public AboutWindow(AppConfig appConfig, IText text) { - this.runtimeInfo = runtimeInfo; + this.appConfig = appConfig; this.text = text; InitializeComponent(); @@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Classic private void InitializeAboutWindow() { Closing += (o, args) => closing?.Invoke(); - VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic }); VersionInfo.Inlines.Add(new LineBreak()); VersionInfo.Inlines.Add(new LineBreak()); - VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs index bd9343e6..cd92edf6 100644 --- a/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/RuntimeWindow.xaml.cs @@ -20,8 +20,8 @@ namespace SafeExamBrowser.UserInterface.Classic public partial class RuntimeWindow : Window, IRuntimeWindow { private bool allowClose; + private AppConfig appConfig; private ILogContentFormatter formatter; - private RuntimeInfo runtimeInfo; private IText text; private RuntimeWindowViewModel model; private WindowClosingEventHandler closing; @@ -38,10 +38,10 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public RuntimeWindow(ILogContentFormatter formatter, RuntimeInfo runtimeInfo, IText text) + public RuntimeWindow(AppConfig appConfig, ILogContentFormatter formatter, IText text) { + this.appConfig = appConfig; this.formatter = formatter; - this.runtimeInfo = runtimeInfo; this.text = text; InitializeComponent(); @@ -129,12 +129,12 @@ namespace SafeExamBrowser.UserInterface.Classic private void InitializeRuntimeWindow() { - Title = $"{runtimeInfo.ProgramTitle} - Version {runtimeInfo.ProgramVersion}"; + Title = $"{appConfig.ProgramTitle} - Version {appConfig.ProgramVersion}"; - InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic }); InfoTextBlock.Inlines.Add(new LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak()); - InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 }); model = new RuntimeWindowViewModel(); AnimatedBorder.DataContext = model; diff --git a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs index 25fbba24..e0c98a8a 100644 --- a/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Classic/SplashScreen.xaml.cs @@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Classic { private bool allowClose; private ProgressIndicatorViewModel model = new ProgressIndicatorViewModel(); - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IText text; private WindowClosingEventHandler closing; - public RuntimeInfo RuntimeInfo + public AppConfig AppConfig { set { Dispatcher.Invoke(() => { - runtimeInfo = value; - UpdateRuntimeInfo(); + appConfig = value; + UpdateAppInfo(); }); } } @@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Classic remove { closing -= value; } } - public SplashScreen(IText text, RuntimeInfo runtimeInfo = null) + public SplashScreen(IText text, AppConfig appConfig = null) { - this.runtimeInfo = runtimeInfo; + this.appConfig = appConfig; this.text = text; InitializeComponent(); @@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Classic private void InitializeSplashScreen() { - UpdateRuntimeInfo(); + UpdateAppInfo(); StatusTextBlock.DataContext = model; ProgressBar.DataContext = model; @@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Classic Closing += (o, args) => args.Cancel = !allowClose; } - private void UpdateRuntimeInfo() + private void UpdateAppInfo() { - if (runtimeInfo != null) + if (appConfig != null) { - InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic }); InfoTextBlock.Inlines.Add(new LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak()); - InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs index f450929c..96402594 100644 --- a/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Classic/UserInterfaceFactory.cs @@ -29,9 +29,9 @@ namespace SafeExamBrowser.UserInterface.Classic this.text = text; } - public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo) + public IWindow CreateAboutWindow(AppConfig appConfig) { - return new AboutWindow(runtimeInfo, text); + return new AboutWindow(appConfig, text); } public IApplicationButton CreateApplicationButton(IApplicationInfo info) @@ -89,13 +89,13 @@ namespace SafeExamBrowser.UserInterface.Classic return new PowerSupplyControl(); } - public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) + public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig) { RuntimeWindow runtimeWindow = null; var windowReadyEvent = new AutoResetEvent(false); var runtimeWindowThread = new Thread(() => { - runtimeWindow = new RuntimeWindow(new RuntimeWindowLogFormatter(), runtimeInfo, text); + runtimeWindow = new RuntimeWindow(appConfig, new RuntimeWindowLogFormatter(), text); runtimeWindow.Closed += (o, args) => runtimeWindow.Dispatcher.InvokeShutdown(); windowReadyEvent.Set(); @@ -113,13 +113,13 @@ namespace SafeExamBrowser.UserInterface.Classic return runtimeWindow; } - public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null) + public ISplashScreen CreateSplashScreen(AppConfig appConfig = null) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); var splashScreenThread = new Thread(() => { - splashScreen = new SplashScreen(text, runtimeInfo); + splashScreen = new SplashScreen(text, appConfig); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Show(); diff --git a/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/AboutWindow.xaml.cs index 235aa8bb..6cd28ec3 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 RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IText text; private WindowClosingEventHandler closing; @@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public AboutWindow(RuntimeInfo runtimeInfo, IText text) + public AboutWindow(AppConfig appConfig, IText text) { - this.runtimeInfo = runtimeInfo; + this.appConfig = appConfig; this.text = text; InitializeComponent(); @@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Windows10 private void InitializeAboutWindow() { Closing += (o, args) => closing?.Invoke(); - VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic }); VersionInfo.Inlines.Add(new LineBreak()); VersionInfo.Inlines.Add(new LineBreak()); - VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs index aa57e34d..34b48577 100644 --- a/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs +++ b/SafeExamBrowser.UserInterface.Windows10/SplashScreen.xaml.cs @@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Windows10 { private bool allowClose; private SplashScreenViewModel model = new SplashScreenViewModel(); - private RuntimeInfo runtimeInfo; + private AppConfig appConfig; private IText text; private WindowClosingEventHandler closing; - public RuntimeInfo RuntimeInfo + public AppConfig AppConfig { set { Dispatcher.Invoke(() => { - runtimeInfo = value; - UpdateRuntimeInfo(); + appConfig = value; + UpdateAppInfo(); }); } } @@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 remove { closing -= value; } } - public SplashScreen(IText text, RuntimeInfo runtimeInfo = null) + public SplashScreen(IText text, AppConfig appConfig = null) { - this.runtimeInfo = runtimeInfo; + this.appConfig = appConfig; this.text = text; InitializeComponent(); @@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Windows10 private void InitializeSplashScreen() { - UpdateRuntimeInfo(); + UpdateAppInfo(); StatusTextBlock.DataContext = model; ProgressBar.DataContext = model; @@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Windows10 Closing += (o, args) => args.Cancel = !allowClose; } - private void UpdateRuntimeInfo() + private void UpdateAppInfo() { - if (runtimeInfo != null) + if (appConfig != null) { - InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic }); + InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic }); InfoTextBlock.Inlines.Add(new LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak()); - InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); + InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 }); } } } diff --git a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs index 5e0d5828..7c524531 100644 --- a/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs +++ b/SafeExamBrowser.UserInterface.Windows10/UserInterfaceFactory.cs @@ -28,9 +28,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 this.text = text; } - public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo) + public IWindow CreateAboutWindow(AppConfig appConfig) { - return new AboutWindow(runtimeInfo, text); + return new AboutWindow(appConfig, text); } public IApplicationButton CreateApplicationButton(IApplicationInfo info) @@ -92,19 +92,19 @@ namespace SafeExamBrowser.UserInterface.Windows10 return new PowerSupplyControl(); } - public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) + public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig) { // TODO throw new System.NotImplementedException(); } - public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null) + public ISplashScreen CreateSplashScreen(AppConfig appConfig = null) { SplashScreen splashScreen = null; var splashReadyEvent = new AutoResetEvent(false); var splashScreenThread = new Thread(() => { - splashScreen = new SplashScreen(text, runtimeInfo); + splashScreen = new SplashScreen(text, appConfig); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Show();