SEBWIN-220: Finally renamed RuntimeInfo to AppConfig.

This commit is contained in:
dbuechel 2018-06-29 09:50:20 +02:00
parent 27d2907d12
commit 9a12bbdb7d
33 changed files with 227 additions and 228 deletions

View file

@ -24,11 +24,11 @@ namespace SafeExamBrowser.Browser
{ {
public class BrowserApplicationController : IBrowserApplicationController public class BrowserApplicationController : IBrowserApplicationController
{ {
private AppConfig appConfig;
private IApplicationButton button; private IApplicationButton button;
private IList<IApplicationInstance> instances; private IList<IApplicationInstance> instances;
private ILogger logger; private ILogger logger;
private IMessageBox messageBox; private IMessageBox messageBox;
private RuntimeInfo runtimeInfo;
private BrowserSettings settings; private BrowserSettings settings;
private IText text; private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
@ -36,17 +36,17 @@ namespace SafeExamBrowser.Browser
public event DownloadRequestedEventHandler ConfigurationDownloadRequested; public event DownloadRequestedEventHandler ConfigurationDownloadRequested;
public BrowserApplicationController( public BrowserApplicationController(
AppConfig appConfig,
BrowserSettings settings, BrowserSettings settings,
RuntimeInfo runtimeInfo,
ILogger logger, ILogger logger,
IMessageBox messageBox, IMessageBox messageBox,
IText text, IText text,
IUserInterfaceFactory uiFactory) IUserInterfaceFactory uiFactory)
{ {
this.appConfig = appConfig;
this.instances = new List<IApplicationInstance>(); this.instances = new List<IApplicationInstance>();
this.logger = logger; this.logger = logger;
this.messageBox = messageBox; this.messageBox = messageBox;
this.runtimeInfo = runtimeInfo;
this.settings = settings; this.settings = settings;
this.text = text; this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
@ -82,7 +82,7 @@ namespace SafeExamBrowser.Browser
private void CreateNewInstance() 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.Initialize();
instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args); instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
@ -97,8 +97,8 @@ namespace SafeExamBrowser.Browser
{ {
var cefSettings = new CefSettings var cefSettings = new CefSettings
{ {
CachePath = runtimeInfo.BrowserCachePath, CachePath = appConfig.BrowserCachePath,
LogFile = runtimeInfo.BrowserLogFile, LogFile = appConfig.BrowserLogFile,
// TODO: Set according to current application LogLevel, but avoid verbose! // TODO: Set according to current application LogLevel, but avoid verbose!
LogSeverity = LogSeverity.Info LogSeverity = LogSeverity.Info
}; };

View file

@ -20,10 +20,10 @@ namespace SafeExamBrowser.Browser
{ {
internal class BrowserApplicationInstance : IApplicationInstance internal class BrowserApplicationInstance : IApplicationInstance
{ {
private AppConfig appConfig;
private IBrowserControl control; private IBrowserControl control;
private IBrowserWindow window; private IBrowserWindow window;
private bool isMainInstance; private bool isMainInstance;
private RuntimeInfo runtimeInfo;
private BrowserSettings settings; private BrowserSettings settings;
private IText text; private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
@ -37,14 +37,14 @@ namespace SafeExamBrowser.Browser
public event TerminatedEventHandler Terminated; public event TerminatedEventHandler Terminated;
public BrowserApplicationInstance( public BrowserApplicationInstance(
AppConfig appConfig,
BrowserSettings settings, BrowserSettings settings,
RuntimeInfo runtimeInfo,
IText text, IText text,
IUserInterfaceFactory uiFactory, IUserInterfaceFactory uiFactory,
bool isMainInstance) bool isMainInstance)
{ {
this.appConfig = appConfig;
this.isMainInstance = isMainInstance; this.isMainInstance = isMainInstance;
this.runtimeInfo = runtimeInfo;
this.settings = settings; this.settings = settings;
this.text = text; this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
@ -52,7 +52,7 @@ namespace SafeExamBrowser.Browser
internal void Initialize() internal void Initialize()
{ {
var downloadHandler = new DownloadHandler(settings, runtimeInfo); var downloadHandler = new DownloadHandler(appConfig, settings);
Id = Guid.NewGuid(); Id = Guid.NewGuid();
downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args); downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);

View file

@ -22,24 +22,24 @@ namespace SafeExamBrowser.Browser.Handlers
/// </remarks> /// </remarks>
internal class DownloadHandler : IDownloadHandler internal class DownloadHandler : IDownloadHandler
{ {
private AppConfig appConfig;
private BrowserSettings settings; private BrowserSettings settings;
private RuntimeInfo runtimeInfo;
private ConcurrentDictionary<int, DownloadFinishedCallback> callbacks; private ConcurrentDictionary<int, DownloadFinishedCallback> callbacks;
public event DownloadRequestedEventHandler ConfigurationDownloadRequested; public event DownloadRequestedEventHandler ConfigurationDownloadRequested;
public DownloadHandler(BrowserSettings settings, RuntimeInfo runtimeInfo) public DownloadHandler(AppConfig appConfig, BrowserSettings settings)
{ {
this.appConfig = appConfig;
this.callbacks = new ConcurrentDictionary<int, DownloadFinishedCallback>(); this.callbacks = new ConcurrentDictionary<int, DownloadFinishedCallback>();
this.settings = settings; this.settings = settings;
this.runtimeInfo = runtimeInfo;
} }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{ {
var uri = new Uri(downloadItem.Url); var uri = new Uri(downloadItem.Url);
var extension = Path.GetExtension(uri.AbsolutePath); 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) if (isConfigFile)
{ {

View file

@ -18,14 +18,14 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestClass] [TestClass]
public class AboutNotificationControllerTests public class AboutNotificationControllerTests
{ {
private Mock<RuntimeInfo> runtimeInfoMock; private Mock<AppConfig> appConfig;
private Mock<IUserInterfaceFactory> uiFactoryMock; private Mock<IUserInterfaceFactory> uiFactory;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
runtimeInfoMock = new Mock<RuntimeInfo>(); appConfig = new Mock<AppConfig>();
uiFactoryMock = new Mock<IUserInterfaceFactory>(); uiFactory = new Mock<IUserInterfaceFactory>();
} }
[TestMethod] [TestMethod]
@ -33,9 +33,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>())).Returns(window.Object); uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny<AppConfig>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
sut.Terminate(); sut.Terminate();
@ -48,9 +48,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var window = new Mock<IWindow>(); var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>())).Returns(window.Object); uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny<AppConfig>())).Returns(window.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);
button.Click(); button.Click();
button.Click(); button.Click();
@ -58,7 +58,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
button.Click(); button.Click();
button.Click(); button.Click();
uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>()), Times.Once); uiFactory.Verify(u => u.CreateAboutWindow(It.IsAny<AppConfig>()), Times.Once);
window.Verify(u => u.Show(), Times.Once); window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4)); window.Verify(u => u.BringToForeground(), Times.Exactly(4));
} }
@ -67,7 +67,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public void MustSubscribeToClickEvent() public void MustSubscribeToClickEvent()
{ {
var button = new NotificationButtonMock(); var button = new NotificationButtonMock();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object); var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
sut.RegisterNotification(button); sut.RegisterNotification(button);

View file

@ -39,22 +39,22 @@ namespace SafeExamBrowser.Client.Behaviour
private ITaskbar taskbar; private ITaskbar taskbar;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private IWindowMonitor windowMonitor; private IWindowMonitor windowMonitor;
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
public IBrowserApplicationController Browser { private get; set; } public IBrowserApplicationController Browser { private get; set; }
public IClientHost ClientHost { private get; set; } public IClientHost ClientHost { private get; set; }
public Guid SessionId { private get; set; } public Guid SessionId { private get; set; }
public Settings Settings { private get; set; } public Settings Settings { private get; set; }
public RuntimeInfo RuntimeInfo public AppConfig AppConfig
{ {
set set
{ {
runtimeInfo = value; appConfig = value;
if (splashScreen != null) if (splashScreen != null)
{ {
splashScreen.RuntimeInfo = value; splashScreen.AppConfig = value;
} }
} }
} }
@ -204,7 +204,7 @@ namespace SafeExamBrowser.Client.Behaviour
{ {
args.AllowDownload = true; args.AllowDownload = true;
args.Callback = Browser_ConfigurationDownloadFinished; args.Callback = Browser_ConfigurationDownloadFinished;
args.DownloadPath = Path.Combine(runtimeInfo.DownloadDirectory, fileName); args.DownloadPath = Path.Combine(appConfig.DownloadDirectory, fileName);
} }
} }
else else

View file

@ -40,13 +40,13 @@ namespace SafeExamBrowser.Client.Behaviour.Operations
{ {
var config = runtime.GetConfiguration(); var config = runtime.GetConfiguration();
configuration.RuntimeInfo = config.RuntimeInfo; configuration.AppConfig = config.AppConfig;
configuration.SessionId = config.SessionId; configuration.SessionId = config.SessionId;
configuration.Settings = config.Settings; configuration.Settings = config.Settings;
logger.Info("Successfully retrieved the application configuration from the runtime."); logger.Info("Successfully retrieved the application configuration from the runtime.");
logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}"); logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId}"); logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId}");
logger.Info($" -> Session-ID: {configuration.SessionId}"); logger.Info($" -> Session-ID: {configuration.SessionId}");
} }
catch (Exception e) catch (Exception e)

View file

@ -152,7 +152,7 @@ namespace SafeExamBrowser.Client
private IOperation BuildBrowserOperation() private IOperation BuildBrowserOperation()
{ {
var moduleLogger = new ModuleLogger(logger, typeof(BrowserApplicationController)); 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 browserInfo = new BrowserApplicationInfo();
var operation = new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory); var operation = new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory);
@ -165,7 +165,7 @@ namespace SafeExamBrowser.Client
{ {
var processId = Process.GetCurrentProcess().Id; var processId = Process.GetCurrentProcess().Id;
var factory = new HostObjectFactory(); 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); var operation = new CommunicationOperation(host, logger);
clientHost = host; clientHost = host;
@ -204,9 +204,9 @@ namespace SafeExamBrowser.Client
private void UpdateClientControllerDependencies() private void UpdateClientControllerDependencies()
{ {
ClientController.AppConfig = configuration.AppConfig;
ClientController.Browser = browserController; ClientController.Browser = browserController;
ClientController.ClientHost = clientHost; ClientController.ClientHost = clientHost;
ClientController.RuntimeInfo = configuration.RuntimeInfo;
ClientController.SessionId = configuration.SessionId; ClientController.SessionId = configuration.SessionId;
ClientController.Settings = configuration.Settings; ClientController.Settings = configuration.Settings;
} }

View file

@ -17,13 +17,13 @@ namespace SafeExamBrowser.Client.Notifications
internal class AboutNotificationController : INotificationController internal class AboutNotificationController : INotificationController
{ {
private INotificationButton notification; private INotificationButton notification;
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private IWindow window; private IWindow window;
public AboutNotificationController(RuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory) public AboutNotificationController(AppConfig appConfig, IUserInterfaceFactory uiFactory)
{ {
this.runtimeInfo = runtimeInfo; this.appConfig = appConfig;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
} }
@ -43,7 +43,7 @@ namespace SafeExamBrowser.Client.Notifications
{ {
if (window == null) if (window == null)
{ {
window = uiFactory.CreateAboutWindow(runtimeInfo); window = uiFactory.CreateAboutWindow(appConfig);
window.Closing += () => window = null; window.Closing += () => window = null;
window.Show(); window.Show();

View file

@ -19,22 +19,22 @@ namespace SafeExamBrowser.Configuration
private const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser"; private const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser";
private bool firstSession = true; private bool firstSession = true;
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
public ISessionData CurrentSession { get; private set; } public ISessionData CurrentSession { get; private set; }
public Settings CurrentSettings { get; private set; } public Settings CurrentSettings { get; private set; }
public string ReconfigurationFilePath { get; set; } public string ReconfigurationFilePath { get; set; }
public RuntimeInfo RuntimeInfo public AppConfig AppConfig
{ {
get get
{ {
if (runtimeInfo == null) if (appConfig == null)
{ {
InitializeRuntimeInfo(); InitializeAppConfig();
} }
return runtimeInfo; return appConfig;
} }
} }
@ -42,7 +42,7 @@ namespace SafeExamBrowser.Configuration
{ {
return new ClientConfiguration return new ClientConfiguration
{ {
RuntimeInfo = RuntimeInfo, AppConfig = AppConfig,
SessionId = CurrentSession.Id, SessionId = CurrentSession.Id,
Settings = CurrentSettings Settings = CurrentSettings
}; };
@ -58,7 +58,7 @@ namespace SafeExamBrowser.Configuration
if (!firstSession) if (!firstSession)
{ {
UpdateRuntimeInfo(); UpdateAppConfig();
} }
else else
{ {
@ -96,7 +96,7 @@ namespace SafeExamBrowser.Configuration
CurrentSettings.Taskbar.AllowWirelessNetwork = true; CurrentSettings.Taskbar.AllowWirelessNetwork = true;
} }
private void InitializeRuntimeInfo() private void InitializeAppConfig()
{ {
var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser)); var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser));
var executable = Assembly.GetEntryAssembly(); var executable = Assembly.GetEntryAssembly();
@ -104,32 +104,32 @@ namespace SafeExamBrowser.Configuration
var logFolder = Path.Combine(appDataFolder, "Logs"); var logFolder = Path.Combine(appDataFolder, "Logs");
var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s"); var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
runtimeInfo = new RuntimeInfo(); appConfig = new AppConfig();
runtimeInfo.ApplicationStartTime = startTime; appConfig.ApplicationStartTime = startTime;
runtimeInfo.AppDataFolder = appDataFolder; appConfig.AppDataFolder = appDataFolder;
runtimeInfo.BrowserCachePath = Path.Combine(appDataFolder, "Cache"); appConfig.BrowserCachePath = Path.Combine(appDataFolder, "Cache");
runtimeInfo.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt"); appConfig.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt");
runtimeInfo.ClientId = Guid.NewGuid(); appConfig.ClientId = Guid.NewGuid();
runtimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; appConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
runtimeInfo.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe"); appConfig.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe");
runtimeInfo.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt"); appConfig.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt");
runtimeInfo.ConfigurationFileExtension = ".seb"; appConfig.ConfigurationFileExtension = ".seb";
runtimeInfo.DefaultSettingsFileName = "SebClientSettings.seb"; appConfig.DefaultSettingsFileName = "SebClientSettings.seb";
runtimeInfo.DownloadDirectory = Path.Combine(appDataFolder, "Downloads"); appConfig.DownloadDirectory = Path.Combine(appDataFolder, "Downloads");
runtimeInfo.ProgramCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright; appConfig.ProgramCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
runtimeInfo.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser)); appConfig.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser));
runtimeInfo.ProgramTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title; appConfig.ProgramTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
runtimeInfo.ProgramVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; appConfig.ProgramVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
runtimeInfo.RuntimeId = Guid.NewGuid(); appConfig.RuntimeId = Guid.NewGuid();
runtimeInfo.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}"; appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
runtimeInfo.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt"); appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
runtimeInfo.ServiceAddress = $"{BASE_ADDRESS}/service"; appConfig.ServiceAddress = $"{BASE_ADDRESS}/service";
} }
private void UpdateRuntimeInfo() private void UpdateAppConfig()
{ {
RuntimeInfo.ClientId = Guid.NewGuid(); AppConfig.ClientId = Guid.NewGuid();
RuntimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}"; AppConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
} }
} }
} }

View file

@ -19,6 +19,11 @@ namespace SafeExamBrowser.Contracts.Behaviour
/// </summary> /// </summary>
public interface IClientController public interface IClientController
{ {
/// <summary>
/// The global configuration information to be used during application execution.
/// </summary>
AppConfig AppConfig { set; }
/// <summary> /// <summary>
/// The controller for the browser application. /// The controller for the browser application.
/// </summary> /// </summary>
@ -29,11 +34,6 @@ namespace SafeExamBrowser.Contracts.Behaviour
/// </summary> /// </summary>
IClientHost ClientHost { set; } IClientHost ClientHost { set; }
/// <summary>
/// The runtime information to be used during application execution.
/// </summary>
RuntimeInfo RuntimeInfo { set; }
/// <summary> /// <summary>
/// The session identifier of the currently running session. /// The session identifier of the currently running session.
/// </summary> /// </summary>

View file

@ -9,7 +9,7 @@
namespace SafeExamBrowser.Contracts.Browser namespace SafeExamBrowser.Contracts.Browser
{ {
/// <summary> /// <summary>
/// TODO /// The event arguments used for all download events fired by the <see cref="IBrowserApplicationController"/>.
/// </summary> /// </summary>
public class DownloadEventArgs public class DownloadEventArgs
{ {

View file

@ -12,10 +12,9 @@ namespace SafeExamBrowser.Contracts.Configuration
{ {
/// <summary> /// <summary>
/// Defines the fundamental, global configuration information for all application components. /// Defines the fundamental, global configuration information for all application components.
/// TODO: Rename to Globals or GlobalConfiguration or alike!
/// </summary> /// </summary>
[Serializable] [Serializable]
public class RuntimeInfo public class AppConfig
{ {
/// <summary> /// <summary>
/// The path of the application data folder. /// The path of the application data folder.

View file

@ -16,6 +16,11 @@ namespace SafeExamBrowser.Contracts.Configuration
[Serializable] [Serializable]
public class ClientConfiguration public class ClientConfiguration
{ {
/// <summary>
/// The global application configuration.
/// </summary>
public AppConfig AppConfig { get; set; }
/// <summary> /// <summary>
/// The unique identifier for the current session. /// The unique identifier for the current session.
/// </summary> /// </summary>
@ -25,10 +30,5 @@ namespace SafeExamBrowser.Contracts.Configuration
/// The application settings to be used by the client. /// The application settings to be used by the client.
/// </summary> /// </summary>
public Settings.Settings Settings { get; set; } public Settings.Settings Settings { get; set; }
/// <summary>
/// The information about the current runtime.
/// </summary>
public RuntimeInfo RuntimeInfo { get; set; }
} }
} }

View file

@ -15,6 +15,11 @@ namespace SafeExamBrowser.Contracts.Configuration
/// </summary> /// </summary>
public interface IConfigurationRepository public interface IConfigurationRepository
{ {
/// <summary>
/// The global configuration information for the currently running application instance.
/// </summary>
AppConfig AppConfig { get; }
/// <summary> /// <summary>
/// Retrieves the current session data, i.e. the last one which was initialized. If no session has been initialized yet, this /// Retrieves the current session data, i.e. the last one which was initialized. If no session has been initialized yet, this
/// property will be <c>null</c>! /// property will be <c>null</c>!
@ -32,11 +37,6 @@ namespace SafeExamBrowser.Contracts.Configuration
/// </summary> /// </summary>
string ReconfigurationFilePath { get; set; } string ReconfigurationFilePath { get; set; }
/// <summary>
/// The runtime information for the currently running application instance.
/// </summary>
RuntimeInfo RuntimeInfo { get; }
/// <summary> /// <summary>
/// Builds a configuration for the client component, given the currently loaded settings, session and runtime information. /// Builds a configuration for the client component, given the currently loaded settings, session and runtime information.
/// </summary> /// </summary>

View file

@ -96,7 +96,7 @@
<Compile Include="Configuration\ClientConfiguration.cs" /> <Compile Include="Configuration\ClientConfiguration.cs" />
<Compile Include="Configuration\IResourceLoader.cs" /> <Compile Include="Configuration\IResourceLoader.cs" />
<Compile Include="Configuration\LoadStatus.cs" /> <Compile Include="Configuration\LoadStatus.cs" />
<Compile Include="Configuration\RuntimeInfo.cs" /> <Compile Include="Configuration\AppConfig.cs" />
<Compile Include="Configuration\ISessionData.cs" /> <Compile Include="Configuration\ISessionData.cs" />
<Compile Include="Configuration\Settings\ConfigurationMode.cs" /> <Compile Include="Configuration\Settings\ConfigurationMode.cs" />
<Compile Include="Behaviour\INotificationController.cs" /> <Compile Include="Behaviour\INotificationController.cs" />

View file

@ -25,7 +25,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// <summary> /// <summary>
/// Creates a new about window displaying information about the currently running application version. /// Creates a new about window displaying information about the currently running application version.
/// </summary> /// </summary>
IWindow CreateAboutWindow(RuntimeInfo runtimeInfo); IWindow CreateAboutWindow(AppConfig appConfig);
/// <summary> /// <summary>
/// Creates a taskbar button, initialized with the given application information. /// 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. /// Creates a new runtime window which runs on its own thread.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo); IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig);
/// <summary> /// <summary>
/// Creates a new splash screen which runs on its own thread. /// Creates a new splash screen which runs on its own thread.
/// </summary> /// </summary>
ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null); ISplashScreen CreateSplashScreen(AppConfig appConfig = null);
/// <summary> /// <summary>
/// Creates a system control which allows to change the wireless network connection of the computer. /// Creates a system control which allows to change the wireless network connection of the computer.

View file

@ -16,8 +16,8 @@ namespace SafeExamBrowser.Contracts.UserInterface.Windows
public interface ISplashScreen : IProgressIndicator, IWindow public interface ISplashScreen : IProgressIndicator, IWindow
{ {
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
RuntimeInfo RuntimeInfo { set; } AppConfig AppConfig { set; }
} }
} }

View file

@ -25,6 +25,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{ {
private Action clientReady; private Action clientReady;
private Action terminated; private Action terminated;
private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration; private Mock<IConfigurationRepository> configuration;
private Mock<IClientProxy> proxy; private Mock<IClientProxy> proxy;
private Mock<ILogger> logger; private Mock<ILogger> logger;
@ -32,13 +33,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
private Mock<IProcessFactory> processFactory; private Mock<IProcessFactory> processFactory;
private Mock<IProxyFactory> proxyFactory; private Mock<IProxyFactory> proxyFactory;
private Mock<IRuntimeHost> runtimeHost; private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session; private Mock<ISessionData> session;
private ClientOperation sut; private ClientOperation sut;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>(); configuration = new Mock<IConfigurationRepository>();
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null)); clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
logger = new Mock<ILogger>(); logger = new Mock<ILogger>();
@ -47,7 +48,6 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
proxy = new Mock<IClientProxy>(); proxy = new Mock<IClientProxy>();
proxyFactory = new Mock<IProxyFactory>(); proxyFactory = new Mock<IProxyFactory>();
runtimeHost = new Mock<IRuntimeHost>(); runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>(); session = new Mock<ISessionData>();
terminated = new Action(() => 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.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<string>())).Returns(proxy.Object); proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
sut = new ClientOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0); sut = new ClientOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);

View file

@ -22,6 +22,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
public class ClientTerminationOperationTests public class ClientTerminationOperationTests
{ {
private Action clientReady; private Action clientReady;
private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration; private Mock<IConfigurationRepository> configuration;
private Mock<IClientProxy> proxy; private Mock<IClientProxy> proxy;
private Mock<ILogger> logger; private Mock<ILogger> logger;
@ -29,13 +30,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
private Mock<IProcessFactory> processFactory; private Mock<IProcessFactory> processFactory;
private Mock<IProxyFactory> proxyFactory; private Mock<IProxyFactory> proxyFactory;
private Mock<IRuntimeHost> runtimeHost; private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session; private Mock<ISessionData> session;
private ClientTerminationOperation sut; private ClientTerminationOperation sut;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>(); configuration = new Mock<IConfigurationRepository>();
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null)); clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
logger = new Mock<ILogger>(); logger = new Mock<ILogger>();
@ -44,11 +45,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
proxy = new Mock<IClientProxy>(); proxy = new Mock<IClientProxy>();
proxyFactory = new Mock<IProxyFactory>(); proxyFactory = new Mock<IProxyFactory>();
runtimeHost = new Mock<IRuntimeHost>(); runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>(); session = new Mock<ISessionData>();
configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); 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<string>())).Returns(proxy.Object); proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
sut = new ClientTerminationOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0); sut = new ClientTerminationOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);

View file

@ -29,13 +29,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestClass] [TestClass]
public class ConfigurationOperationTests public class ConfigurationOperationTests
{ {
private AppConfig appConfig;
private Mock<ILogger> logger; private Mock<ILogger> logger;
private Mock<IMessageBox> messageBox; private Mock<IMessageBox> messageBox;
private Mock<IPasswordDialog> passwordDialog; private Mock<IPasswordDialog> passwordDialog;
private Mock<IConfigurationRepository> repository; private Mock<IConfigurationRepository> repository;
private Mock<IResourceLoader> resourceLoader; private Mock<IResourceLoader> resourceLoader;
private Mock<IRuntimeHost> runtimeHost; private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Settings settings; private Settings settings;
private Mock<IText> text; private Mock<IText> text;
private Mock<IUserInterfaceFactory> uiFactory; private Mock<IUserInterfaceFactory> uiFactory;
@ -44,22 +44,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
appConfig = new AppConfig();
logger = new Mock<ILogger>(); logger = new Mock<ILogger>();
messageBox = new Mock<IMessageBox>(); messageBox = new Mock<IMessageBox>();
passwordDialog = new Mock<IPasswordDialog>(); passwordDialog = new Mock<IPasswordDialog>();
repository = new Mock<IConfigurationRepository>(); repository = new Mock<IConfigurationRepository>();
resourceLoader = new Mock<IResourceLoader>(); resourceLoader = new Mock<IResourceLoader>();
runtimeHost = new Mock<IRuntimeHost>(); runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
settings = new Settings(); settings = new Settings();
text = new Mock<IText>(); text = new Mock<IText>();
uiFactory = new Mock<IUserInterfaceFactory>(); uiFactory = new Mock<IUserInterfaceFactory>();
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"; repository.SetupGet(r => r.CurrentSettings).Returns(settings);
runtimeInfo.DefaultSettingsFileName = "SettingsDummy.txt";
runtimeInfo.ProgramDataFolder = @"C:\Not\Really\ProgramData";
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(passwordDialog.Object); uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(passwordDialog.Object);
} }
@ -70,12 +70,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
var url = @"http://www.safeexambrowser.org/whatever.seb"; var url = @"http://www.safeexambrowser.org/whatever.seb";
var location = Path.GetDirectoryName(GetType().Assembly.Location); var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.ProgramDataFolder = location; appConfig.ProgramDataFolder = location;
runtimeInfo.AppDataFolder = location; appConfig.AppDataFolder = location;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
var resource = new Uri(url); var resource = new Uri(url);
@ -88,12 +88,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{ {
var location = Path.GetDirectoryName(GetType().Assembly.Location); var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.ProgramDataFolder = location; appConfig.ProgramDataFolder = location;
runtimeInfo.AppDataFolder = $@"{location}\WRONG"; appConfig.AppDataFolder = $@"{location}\WRONG";
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
var resource = new Uri(Path.Combine(location, "SettingsDummy.txt")); 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); var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.AppDataFolder = location; appConfig.AppDataFolder = location;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
var resource = new Uri(Path.Combine(location, "SettingsDummy.txt")); var resource = new Uri(Path.Combine(location, "SettingsDummy.txt"));
@ -121,7 +121,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestMethod] [TestMethod]
public void MustFallbackToDefaultsAsLastPrio() 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(); sut.Perform();
repository.Verify(r => r.LoadDefaultSettings(), Times.Once); repository.Verify(r => r.LoadDefaultSettings(), Times.Once);
@ -130,11 +130,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestMethod] [TestMethod]
public void MustAbortIfWishedByUser() public void MustAbortIfWishedByUser()
{ {
runtimeInfo.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location); appConfig.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location);
messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes); messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -147,7 +147,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No); messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -160,7 +160,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
settings.ConfigurationMode = ConfigurationMode.Exam; settings.ConfigurationMode = ConfigurationMode.Exam;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>()), Times.Never); messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>()), Times.Never);
@ -171,10 +171,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{ {
repository.Setup(r => r.LoadDefaultSettings()); 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.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(); sut.Perform();
repository.Verify(r => r.LoadDefaultSettings(), Times.Exactly(2)); repository.Verify(r => r.LoadDefaultSettings(), Times.Exactly(2));
@ -185,7 +185,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{ {
var uri = @"an/invalid\uri.'*%yolo/()你好"; 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(); sut.Perform();
} }
@ -198,7 +198,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(result); passwordDialog.Setup(d => d.Show(null)).Returns(result);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5)); repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5));
@ -213,7 +213,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(result); passwordDialog.Setup(d => d.Show(null)).Returns(result);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5)); repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5));
@ -230,7 +230,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), password, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once); repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -248,7 +248,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, password)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once); repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -264,7 +264,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult); passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -280,7 +280,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult); passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -302,7 +302,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, settingsPassword)).Returns(LoadStatus.AdminPasswordNeeded).Callback(adminCallback); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, settingsPassword)).Returns(LoadStatus.AdminPasswordNeeded).Callback(adminCallback);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), adminPassword, settingsPassword)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once); repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -323,7 +323,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.DisableExplorerShell; 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(); sut.Perform();
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Never); clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Never);
@ -349,7 +349,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.CreateNewDesktop; 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(); sut.Perform();
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.AtLeastOnce); clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.AtLeastOnce);
@ -375,7 +375,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object); session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.CreateNewDesktop; 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(); var result = sut.Perform();
@ -390,7 +390,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(false); resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(false);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.InvalidData); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -405,7 +405,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(true); resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(true);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.InvalidData); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Perform();
@ -422,7 +422,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.SetupGet(r => r.ReconfigurationFilePath).Returns(resource.AbsolutePath); repository.SetupGet(r => r.ReconfigurationFilePath).Returns(resource.AbsolutePath);
repository.Setup(r => r.LoadSettings(It.Is<Uri>(u => u.Equals(resource)), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.Is<Uri>(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(); var result = sut.Repeat();
@ -439,7 +439,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.SetupGet(r => r.ReconfigurationFilePath).Returns(null as string); repository.SetupGet(r => r.ReconfigurationFilePath).Returns(null as string);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success); repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), 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(); var result = sut.Repeat();

View file

@ -19,24 +19,24 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestClass] [TestClass]
public class SessionInitializationOperationTests public class SessionInitializationOperationTests
{ {
private SessionInitializationOperation sut; private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration; private Mock<IConfigurationRepository> configuration;
private Mock<ILogger> logger; private Mock<ILogger> logger;
private Mock<IRuntimeHost> runtimeHost; private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session; private Mock<ISessionData> session;
private SessionInitializationOperation sut;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
{ {
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>(); configuration = new Mock<IConfigurationRepository>();
logger = new Mock<ILogger>(); logger = new Mock<ILogger>();
runtimeHost = new Mock<IRuntimeHost>(); runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>(); session = new Mock<ISessionData>();
configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); 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); sut = new SessionInitializationOperation(configuration.Object, logger.Object, runtimeHost.Object);
} }

View file

@ -87,9 +87,9 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
var clientReadyEvent = new AutoResetEvent(false); var clientReadyEvent = new AutoResetEvent(false);
var clientReadyEventHandler = new CommunicationEventHandler(() => clientReadyEvent.Set()); var clientReadyEventHandler = new CommunicationEventHandler(() => clientReadyEvent.Set());
var clientExecutable = configuration.RuntimeInfo.ClientExecutablePath; var clientExecutable = configuration.AppConfig.ClientExecutablePath;
var clientLogFile = $"{'"' + configuration.RuntimeInfo.ClientLogFile + '"'}"; var clientLogFile = $"{'"' + configuration.AppConfig.ClientLogFile + '"'}";
var hostUri = configuration.RuntimeInfo.RuntimeAddress; var hostUri = configuration.AppConfig.RuntimeAddress;
var token = configuration.CurrentSession.StartupToken.ToString("D"); var token = configuration.CurrentSession.StartupToken.ToString("D");
logger.Info("Starting new client process..."); 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..."); 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)) if (!ClientProxy.Connect(configuration.CurrentSession.StartupToken))
{ {

View file

@ -24,12 +24,12 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{ {
internal class ConfigurationOperation : IOperation internal class ConfigurationOperation : IOperation
{ {
private IConfigurationRepository repository; private IConfigurationRepository configuration;
private ILogger logger; private ILogger logger;
private IMessageBox messageBox; private IMessageBox messageBox;
private IResourceLoader resourceLoader; private IResourceLoader resourceLoader;
private IRuntimeHost runtimeHost; private IRuntimeHost runtimeHost;
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IText text; private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private string[] commandLineArgs; private string[] commandLineArgs;
@ -37,22 +37,22 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
public IProgressIndicator ProgressIndicator { private get; set; } public IProgressIndicator ProgressIndicator { private get; set; }
public ConfigurationOperation( public ConfigurationOperation(
IConfigurationRepository repository, AppConfig appConfig,
IConfigurationRepository configuration,
ILogger logger, ILogger logger,
IMessageBox messageBox, IMessageBox messageBox,
IResourceLoader resourceLoader, IResourceLoader resourceLoader,
IRuntimeHost runtimeHost, IRuntimeHost runtimeHost,
RuntimeInfo runtimeInfo,
IText text, IText text,
IUserInterfaceFactory uiFactory, IUserInterfaceFactory uiFactory,
string[] commandLineArgs) string[] commandLineArgs)
{ {
this.repository = repository; this.appConfig = appConfig;
this.logger = logger; this.logger = logger;
this.messageBox = messageBox; this.messageBox = messageBox;
this.configuration = configuration;
this.resourceLoader = resourceLoader; this.resourceLoader = resourceLoader;
this.runtimeHost = runtimeHost; this.runtimeHost = runtimeHost;
this.runtimeInfo = runtimeInfo;
this.text = text; this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
this.commandLineArgs = commandLineArgs; 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..."); logger.Info("No valid settings resource specified nor found in PROGRAMDATA or APPDATA - loading default settings...");
repository.LoadDefaultSettings(); configuration.LoadDefaultSettings();
return OperationResult.Success; return OperationResult.Success;
} }
@ -88,7 +88,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
logger.Info("Initializing new application configuration..."); logger.Info("Initializing new application configuration...");
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration); ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration);
var isValidUri = TryValidateSettingsUri(repository.ReconfigurationFilePath, out Uri uri); var isValidUri = TryValidateSettingsUri(configuration.ReconfigurationFilePath, out Uri uri);
if (isValidUri) if (isValidUri)
{ {
@ -119,7 +119,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
for (int adminAttempts = 0, settingsAttempts = 0; adminAttempts < 5 && settingsAttempts < 5;) 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) if (status == LoadStatus.AdminPasswordNeeded || status == LoadStatus.SettingsPasswordNeeded)
{ {
@ -152,8 +152,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
private bool TryGetPassword(PasswordRequestPurpose purpose, out string password) private bool TryGetPassword(PasswordRequestPurpose purpose, out string password)
{ {
var isStartup = repository.CurrentSession == null; var isStartup = configuration.CurrentSession == null;
var isRunningOnDefaultDesktop = repository.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell; var isRunningOnDefaultDesktop = configuration.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell;
if (isStartup || isRunningOnDefaultDesktop) if (isStartup || isRunningOnDefaultDesktop)
{ {
@ -200,7 +200,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
}); });
runtimeHost.PasswordReceived += responseEventHandler; runtimeHost.PasswordReceived += responseEventHandler;
repository.CurrentSession.ClientProxy.RequestPassword(purpose, requestId); configuration.CurrentSession.ClientProxy.RequestPassword(purpose, requestId);
responseEvent.WaitOne(); responseEvent.WaitOne();
runtimeHost.PasswordReceived -= responseEventHandler; runtimeHost.PasswordReceived -= responseEventHandler;
@ -220,8 +220,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{ {
if (resourceLoader.IsHtmlResource(uri)) if (resourceLoader.IsHtmlResource(uri))
{ {
repository.LoadDefaultSettings(); configuration.LoadDefaultSettings();
repository.CurrentSettings.Browser.StartUrl = uri.AbsoluteUri; 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."); logger.Info($"The specified URI '{uri.AbsoluteUri}' appears to point to a HTML resource, setting it as startup URL.");
status = LoadStatus.Success; status = LoadStatus.Success;
@ -236,8 +236,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{ {
var path = string.Empty; var path = string.Empty;
var isValidUri = false; var isValidUri = false;
var programDataSettings = Path.Combine(runtimeInfo.ProgramDataFolder, runtimeInfo.DefaultSettingsFileName); var programDataSettings = Path.Combine(appConfig.ProgramDataFolder, appConfig.DefaultSettingsFileName);
var appDataSettings = Path.Combine(runtimeInfo.AppDataFolder, runtimeInfo.DefaultSettingsFileName); var appDataSettings = Path.Combine(appConfig.AppDataFolder, appConfig.DefaultSettingsFileName);
uri = null; uri = null;
@ -277,7 +277,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
private void HandleClientConfiguration(ref OperationResult result) 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(); var abort = IsConfigurationSufficient();

View file

@ -57,8 +57,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
configuration.InitializeSessionConfiguration(); configuration.InitializeSessionConfiguration();
runtimeHost.StartupToken = configuration.CurrentSession.StartupToken; runtimeHost.StartupToken = configuration.CurrentSession.StartupToken;
logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}"); logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId} (as reference, does not change)"); logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId} (as reference, does not change)");
logger.Info($" -> Session-ID: {configuration.CurrentSession.Id}"); logger.Info($" -> Session-ID: {configuration.CurrentSession.Id}");
} }
} }

View file

@ -26,13 +26,13 @@ namespace SafeExamBrowser.Runtime.Behaviour
{ {
private bool sessionRunning; private bool sessionRunning;
private AppConfig appConfig;
private IConfigurationRepository configuration; private IConfigurationRepository configuration;
private ILogger logger; private ILogger logger;
private IMessageBox messageBox; private IMessageBox messageBox;
private IOperationSequence bootstrapSequence; private IOperationSequence bootstrapSequence;
private IOperationSequence sessionSequence; private IOperationSequence sessionSequence;
private IRuntimeHost runtimeHost; private IRuntimeHost runtimeHost;
private RuntimeInfo runtimeInfo;
private IRuntimeWindow runtimeWindow; private IRuntimeWindow runtimeWindow;
private IServiceProxy service; private IServiceProxy service;
private ISplashScreen splashScreen; private ISplashScreen splashScreen;
@ -40,23 +40,23 @@ namespace SafeExamBrowser.Runtime.Behaviour
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
public RuntimeController( public RuntimeController(
AppConfig appConfig,
IConfigurationRepository configuration, IConfigurationRepository configuration,
ILogger logger, ILogger logger,
IMessageBox messageBox, IMessageBox messageBox,
IOperationSequence bootstrapSequence, IOperationSequence bootstrapSequence,
IOperationSequence sessionSequence, IOperationSequence sessionSequence,
IRuntimeHost runtimeHost, IRuntimeHost runtimeHost,
RuntimeInfo runtimeInfo,
IServiceProxy service, IServiceProxy service,
Action shutdown, Action shutdown,
IUserInterfaceFactory uiFactory) IUserInterfaceFactory uiFactory)
{ {
this.appConfig = appConfig;
this.configuration = configuration; this.configuration = configuration;
this.bootstrapSequence = bootstrapSequence; this.bootstrapSequence = bootstrapSequence;
this.logger = logger; this.logger = logger;
this.messageBox = messageBox; this.messageBox = messageBox;
this.runtimeHost = runtimeHost; this.runtimeHost = runtimeHost;
this.runtimeInfo = runtimeInfo;
this.sessionSequence = sessionSequence; this.sessionSequence = sessionSequence;
this.service = service; this.service = service;
this.shutdown = shutdown; this.shutdown = shutdown;
@ -67,8 +67,8 @@ namespace SafeExamBrowser.Runtime.Behaviour
{ {
logger.Info("--- Initiating startup procedure ---"); logger.Info("--- Initiating startup procedure ---");
runtimeWindow = uiFactory.CreateRuntimeWindow(runtimeInfo); runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
splashScreen = uiFactory.CreateSplashScreen(runtimeInfo); splashScreen = uiFactory.CreateSplashScreen(appConfig);
bootstrapSequence.ProgressIndicator = splashScreen; bootstrapSequence.ProgressIndicator = splashScreen;
sessionSequence.ProgressIndicator = runtimeWindow; sessionSequence.ProgressIndicator = runtimeWindow;

View file

@ -28,8 +28,8 @@ namespace SafeExamBrowser.Runtime
{ {
internal class CompositionRoot internal class CompositionRoot
{ {
private AppConfig appConfig;
private ILogger logger; private ILogger logger;
private RuntimeInfo runtimeInfo;
private ISystemInfo systemInfo; private ISystemInfo systemInfo;
internal IRuntimeController RuntimeController { get; private set; } internal IRuntimeController RuntimeController { get; private set; }
@ -43,7 +43,7 @@ namespace SafeExamBrowser.Runtime
var nativeMethods = new NativeMethods(); var nativeMethods = new NativeMethods();
logger = new Logger(); logger = new Logger();
runtimeInfo = configuration.RuntimeInfo; appConfig = configuration.AppConfig;
systemInfo = new SystemInfo(); systemInfo = new SystemInfo();
InitializeLogging(); InitializeLogging();
@ -55,8 +55,8 @@ namespace SafeExamBrowser.Runtime
var processFactory = new ProcessFactory(desktop, new ModuleLogger(logger, typeof(ProcessFactory))); var processFactory = new ProcessFactory(desktop, new ModuleLogger(logger, typeof(ProcessFactory)));
var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), logger); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), logger);
var resourceLoader = new ResourceLoader(); var resourceLoader = new ResourceLoader();
var runtimeHost = new RuntimeHost(runtimeInfo.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost))); var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost)));
var serviceProxy = new ServiceProxy(runtimeInfo.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy))); var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy)));
var bootstrapOperations = new Queue<IOperation>(); var bootstrapOperations = new Queue<IOperation>();
var sessionOperations = new Queue<IOperation>(); var sessionOperations = new Queue<IOperation>();
@ -64,7 +64,7 @@ namespace SafeExamBrowser.Runtime
bootstrapOperations.Enqueue(new I18nOperation(logger, text)); bootstrapOperations.Enqueue(new I18nOperation(logger, text));
bootstrapOperations.Enqueue(new CommunicationOperation(runtimeHost, logger)); 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 SessionInitializationOperation(configuration, logger, runtimeHost));
sessionOperations.Enqueue(new ServiceOperation(configuration, logger, serviceProxy, text)); sessionOperations.Enqueue(new ServiceOperation(configuration, logger, serviceProxy, text));
sessionOperations.Enqueue(new ClientTerminationOperation(configuration, logger, processFactory, proxyFactory, runtimeHost, TEN_SECONDS)); 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 bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
var sessionSequence = new OperationSequence(logger, sessionOperations); 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() internal void LogStartupInformation()
{ {
logger.Log($"/* {runtimeInfo.ProgramTitle}, Version {runtimeInfo.ProgramVersion}"); logger.Log($"/* {appConfig.ProgramTitle}, Version {appConfig.ProgramVersion}");
logger.Log($"/* {runtimeInfo.ProgramCopyright}"); logger.Log($"/* {appConfig.ProgramCopyright}");
logger.Log($"/* "); logger.Log($"/* ");
logger.Log($"/* Please visit https://www.github.com/SafeExamBrowser for more information."); logger.Log($"/* Please visit https://www.github.com/SafeExamBrowser for more information.");
logger.Log(string.Empty); 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($"# Running on {systemInfo.OperatingSystemInfo}");
logger.Log($"# Runtime-ID: {runtimeInfo.RuntimeId}"); logger.Log($"# Runtime-ID: {appConfig.RuntimeId}");
logger.Log(string.Empty); logger.Log(string.Empty);
} }
@ -97,7 +97,7 @@ namespace SafeExamBrowser.Runtime
private void InitializeLogging() private void InitializeLogging()
{ {
var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeInfo.RuntimeLogFile); var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), appConfig.RuntimeLogFile);
logFileWriter.Initialize(); logFileWriter.Initialize();
logger.Subscribe(logFileWriter); logger.Subscribe(logFileWriter);

View file

@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Classic
{ {
public partial class AboutWindow : Window, IWindow public partial class AboutWindow : Window, IWindow
{ {
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IText text; private IText text;
private WindowClosingEventHandler closing; private WindowClosingEventHandler closing;
@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; } remove { closing -= value; }
} }
public AboutWindow(RuntimeInfo runtimeInfo, IText text) public AboutWindow(AppConfig appConfig, IText text)
{ {
this.runtimeInfo = runtimeInfo; this.appConfig = appConfig;
this.text = text; this.text = text;
InitializeComponent(); InitializeComponent();
@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeAboutWindow() private void InitializeAboutWindow()
{ {
Closing += (o, args) => closing?.Invoke(); 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 LineBreak()); VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
} }
} }
} }

View file

@ -20,8 +20,8 @@ namespace SafeExamBrowser.UserInterface.Classic
public partial class RuntimeWindow : Window, IRuntimeWindow public partial class RuntimeWindow : Window, IRuntimeWindow
{ {
private bool allowClose; private bool allowClose;
private AppConfig appConfig;
private ILogContentFormatter formatter; private ILogContentFormatter formatter;
private RuntimeInfo runtimeInfo;
private IText text; private IText text;
private RuntimeWindowViewModel model; private RuntimeWindowViewModel model;
private WindowClosingEventHandler closing; private WindowClosingEventHandler closing;
@ -38,10 +38,10 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; } 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.formatter = formatter;
this.runtimeInfo = runtimeInfo;
this.text = text; this.text = text;
InitializeComponent(); InitializeComponent();
@ -129,12 +129,12 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeRuntimeWindow() 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 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(); model = new RuntimeWindowViewModel();
AnimatedBorder.DataContext = model; AnimatedBorder.DataContext = model;

View file

@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Classic
{ {
private bool allowClose; private bool allowClose;
private ProgressIndicatorViewModel model = new ProgressIndicatorViewModel(); private ProgressIndicatorViewModel model = new ProgressIndicatorViewModel();
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IText text; private IText text;
private WindowClosingEventHandler closing; private WindowClosingEventHandler closing;
public RuntimeInfo RuntimeInfo public AppConfig AppConfig
{ {
set set
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
runtimeInfo = value; appConfig = value;
UpdateRuntimeInfo(); UpdateAppInfo();
}); });
} }
} }
@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; } 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; this.text = text;
InitializeComponent(); InitializeComponent();
@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeSplashScreen() private void InitializeSplashScreen()
{ {
UpdateRuntimeInfo(); UpdateAppInfo();
StatusTextBlock.DataContext = model; StatusTextBlock.DataContext = model;
ProgressBar.DataContext = model; ProgressBar.DataContext = model;
@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Classic
Closing += (o, args) => args.Cancel = !allowClose; 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 LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
} }
} }
} }

View file

@ -29,9 +29,9 @@ namespace SafeExamBrowser.UserInterface.Classic
this.text = text; 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) public IApplicationButton CreateApplicationButton(IApplicationInfo info)
@ -89,13 +89,13 @@ namespace SafeExamBrowser.UserInterface.Classic
return new PowerSupplyControl(); return new PowerSupplyControl();
} }
public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig)
{ {
RuntimeWindow runtimeWindow = null; RuntimeWindow runtimeWindow = null;
var windowReadyEvent = new AutoResetEvent(false); var windowReadyEvent = new AutoResetEvent(false);
var runtimeWindowThread = new Thread(() => 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(); runtimeWindow.Closed += (o, args) => runtimeWindow.Dispatcher.InvokeShutdown();
windowReadyEvent.Set(); windowReadyEvent.Set();
@ -113,13 +113,13 @@ namespace SafeExamBrowser.UserInterface.Classic
return runtimeWindow; return runtimeWindow;
} }
public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null) public ISplashScreen CreateSplashScreen(AppConfig appConfig = null)
{ {
SplashScreen splashScreen = null; SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false); var splashReadyEvent = new AutoResetEvent(false);
var splashScreenThread = new Thread(() => var splashScreenThread = new Thread(() =>
{ {
splashScreen = new SplashScreen(text, runtimeInfo); splashScreen = new SplashScreen(text, appConfig);
splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown();
splashScreen.Show(); splashScreen.Show();

View file

@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Windows10
{ {
public partial class AboutWindow : Window, IWindow public partial class AboutWindow : Window, IWindow
{ {
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IText text; private IText text;
private WindowClosingEventHandler closing; private WindowClosingEventHandler closing;
@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
remove { closing -= value; } remove { closing -= value; }
} }
public AboutWindow(RuntimeInfo runtimeInfo, IText text) public AboutWindow(AppConfig appConfig, IText text)
{ {
this.runtimeInfo = runtimeInfo; this.appConfig = appConfig;
this.text = text; this.text = text;
InitializeComponent(); InitializeComponent();
@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Windows10
private void InitializeAboutWindow() private void InitializeAboutWindow()
{ {
Closing += (o, args) => closing?.Invoke(); 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 LineBreak()); VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
} }
} }
} }

View file

@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Windows10
{ {
private bool allowClose; private bool allowClose;
private SplashScreenViewModel model = new SplashScreenViewModel(); private SplashScreenViewModel model = new SplashScreenViewModel();
private RuntimeInfo runtimeInfo; private AppConfig appConfig;
private IText text; private IText text;
private WindowClosingEventHandler closing; private WindowClosingEventHandler closing;
public RuntimeInfo RuntimeInfo public AppConfig AppConfig
{ {
set set
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
runtimeInfo = value; appConfig = value;
UpdateRuntimeInfo(); UpdateAppInfo();
}); });
} }
} }
@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
remove { closing -= value; } 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; this.text = text;
InitializeComponent(); InitializeComponent();
@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Windows10
private void InitializeSplashScreen() private void InitializeSplashScreen()
{ {
UpdateRuntimeInfo(); UpdateAppInfo();
StatusTextBlock.DataContext = model; StatusTextBlock.DataContext = model;
ProgressBar.DataContext = model; ProgressBar.DataContext = model;
@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Windows10
Closing += (o, args) => args.Cancel = !allowClose; 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 LineBreak()); InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 }); InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
} }
} }
} }

View file

@ -28,9 +28,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
this.text = text; 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) public IApplicationButton CreateApplicationButton(IApplicationInfo info)
@ -92,19 +92,19 @@ namespace SafeExamBrowser.UserInterface.Windows10
return new PowerSupplyControl(); return new PowerSupplyControl();
} }
public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo) public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig)
{ {
// TODO // TODO
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null) public ISplashScreen CreateSplashScreen(AppConfig appConfig = null)
{ {
SplashScreen splashScreen = null; SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false); var splashReadyEvent = new AutoResetEvent(false);
var splashScreenThread = new Thread(() => var splashScreenThread = new Thread(() =>
{ {
splashScreen = new SplashScreen(text, runtimeInfo); splashScreen = new SplashScreen(text, appConfig);
splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown(); splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown();
splashScreen.Show(); splashScreen.Show();