2017-07-05 11:41:19 +02:00
|
|
|
|
/*
|
2018-01-16 08:24:00 +01:00
|
|
|
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
2017-07-28 14:52:15 +02:00
|
|
|
|
*
|
2017-07-05 11:41:19 +02:00
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-07-21 12:05:31 +02:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-12 15:36:30 +02:00
|
|
|
|
using SafeExamBrowser.Browser;
|
2017-07-20 14:16:47 +02:00
|
|
|
|
using SafeExamBrowser.Configuration;
|
2017-07-12 15:36:30 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Behaviour;
|
2017-07-13 08:51:00 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
2017-07-28 14:52:15 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
2017-07-13 08:51:00 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Monitoring;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.SystemComponents;
|
2017-07-13 08:51:00 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
2017-07-27 11:46:31 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.WindowsApi;
|
2017-07-12 15:36:30 +02:00
|
|
|
|
using SafeExamBrowser.Core.Behaviour;
|
2017-07-21 12:05:31 +02:00
|
|
|
|
using SafeExamBrowser.Core.Behaviour.Operations;
|
2017-07-05 17:21:52 +02:00
|
|
|
|
using SafeExamBrowser.Core.I18n;
|
2017-07-06 18:18:39 +02:00
|
|
|
|
using SafeExamBrowser.Core.Logging;
|
2017-08-11 08:28:17 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Display;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Keyboard;
|
2017-08-04 15:20:33 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Mouse;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Processes;
|
2017-07-24 08:56:39 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Windows;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
using SafeExamBrowser.SystemComponents;
|
2017-08-22 09:37:17 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Classic;
|
2017-07-27 11:46:31 +02:00
|
|
|
|
using SafeExamBrowser.WindowsApi;
|
2017-07-05 17:21:52 +02:00
|
|
|
|
|
2017-07-06 10:56:03 +02:00
|
|
|
|
namespace SafeExamBrowser
|
2017-07-05 11:41:19 +02:00
|
|
|
|
{
|
2017-07-07 15:46:32 +02:00
|
|
|
|
internal class CompositionRoot
|
2017-07-05 11:41:19 +02:00
|
|
|
|
{
|
2017-07-14 10:28:59 +02:00
|
|
|
|
private IApplicationController browserController;
|
2017-07-13 08:51:00 +02:00
|
|
|
|
private IApplicationInfo browserInfo;
|
2017-08-11 08:28:17 +02:00
|
|
|
|
private IDisplayMonitor displayMonitor;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
private IKeyboardInterceptor keyboardInterceptor;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
private ILogger logger;
|
2017-08-07 12:23:56 +02:00
|
|
|
|
private ILogContentFormatter logFormatter;
|
2017-08-04 15:20:33 +02:00
|
|
|
|
private IMouseInterceptor mouseInterceptor;
|
2017-07-27 11:46:31 +02:00
|
|
|
|
private INativeMethods nativeMethods;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
private IProcessMonitor processMonitor;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
private IRuntimeController runtimeController;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
private ISettings settings;
|
2017-09-13 08:33:12 +02:00
|
|
|
|
private ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
private ISystemComponent<ISystemPowerSupplyControl> powerSupply;
|
2017-11-13 10:26:30 +01:00
|
|
|
|
private ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork;
|
2017-08-14 17:44:16 +02:00
|
|
|
|
private ISystemInfo systemInfo;
|
2017-07-19 14:43:54 +02:00
|
|
|
|
private IText text;
|
2017-07-27 14:45:54 +02:00
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
2017-07-24 08:56:39 +02:00
|
|
|
|
private IWindowMonitor windowMonitor;
|
2017-07-12 15:36:30 +02:00
|
|
|
|
|
2017-07-13 08:51:00 +02:00
|
|
|
|
public IShutdownController ShutdownController { get; private set; }
|
|
|
|
|
public IStartupController StartupController { get; private set; }
|
2017-07-21 12:05:31 +02:00
|
|
|
|
public Queue<IOperation> StartupOperations { get; private set; }
|
2017-07-10 15:47:12 +02:00
|
|
|
|
public Taskbar Taskbar { get; private set; }
|
2017-07-13 08:51:00 +02:00
|
|
|
|
|
2017-07-07 15:46:32 +02:00
|
|
|
|
public void BuildObjectGraph()
|
2017-07-06 10:56:03 +02:00
|
|
|
|
{
|
2017-07-14 10:28:59 +02:00
|
|
|
|
browserInfo = new BrowserApplicationInfo();
|
|
|
|
|
logger = new Logger();
|
2017-08-07 12:23:56 +02:00
|
|
|
|
logFormatter = new DefaultLogFormatter();
|
2017-07-27 11:46:31 +02:00
|
|
|
|
nativeMethods = new NativeMethods();
|
2017-08-11 08:28:17 +02:00
|
|
|
|
settings = new Settings();
|
2017-08-14 17:44:16 +02:00
|
|
|
|
systemInfo = new SystemInfo();
|
2017-07-27 14:45:54 +02:00
|
|
|
|
uiFactory = new UserInterfaceFactory();
|
2017-07-14 10:28:59 +02:00
|
|
|
|
|
2017-08-07 12:23:56 +02:00
|
|
|
|
logger.Subscribe(new LogFileWriter(logFormatter, settings));
|
2017-07-06 10:56:03 +02:00
|
|
|
|
|
2017-10-10 10:17:28 +02:00
|
|
|
|
text = new Text(logger);
|
2017-08-11 08:28:17 +02:00
|
|
|
|
Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar)));
|
2017-07-31 20:22:53 +02:00
|
|
|
|
browserController = new BrowserApplicationController(settings, text, uiFactory);
|
2017-08-11 08:28:17 +02:00
|
|
|
|
displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods);
|
2017-08-04 12:19:56 +02:00
|
|
|
|
keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor)));
|
2017-09-13 08:33:12 +02:00
|
|
|
|
keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text);
|
2017-08-04 15:20:33 +02:00
|
|
|
|
mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, typeof(MouseInterceptor)), settings.Mouse);
|
2017-08-17 12:17:58 +02:00
|
|
|
|
powerSupply = new PowerSupply(new ModuleLogger(logger, typeof(PowerSupply)), text);
|
2017-07-27 11:46:31 +02:00
|
|
|
|
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
|
|
|
|
|
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
2017-11-14 15:43:13 +01:00
|
|
|
|
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, typeof(WirelessNetwork)), text);
|
2017-07-31 20:22:53 +02:00
|
|
|
|
|
2017-08-11 08:28:17 +02:00
|
|
|
|
runtimeController = new RuntimeController(displayMonitor, new ModuleLogger(logger, typeof(RuntimeController)), processMonitor, Taskbar, windowMonitor);
|
2017-07-24 15:29:17 +02:00
|
|
|
|
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
|
2017-08-14 17:44:16 +02:00
|
|
|
|
StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory);
|
2017-07-21 12:05:31 +02:00
|
|
|
|
|
|
|
|
|
StartupOperations = new Queue<IOperation>();
|
2017-10-10 10:17:28 +02:00
|
|
|
|
StartupOperations.Enqueue(new I18nOperation(logger, text));
|
2017-08-07 09:42:12 +02:00
|
|
|
|
StartupOperations.Enqueue(new KeyboardInterceptorOperation(keyboardInterceptor, logger, nativeMethods));
|
2017-07-26 14:36:20 +02:00
|
|
|
|
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
|
|
|
|
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
2017-08-11 08:28:17 +02:00
|
|
|
|
StartupOperations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, Taskbar));
|
2017-11-13 10:26:30 +01:00
|
|
|
|
StartupOperations.Enqueue(new TaskbarOperation(logger, settings.Taskbar, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, text, uiFactory));
|
2017-07-26 14:36:20 +02:00
|
|
|
|
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
2017-08-07 09:42:12 +02:00
|
|
|
|
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
|
2017-08-07 18:08:55 +02:00
|
|
|
|
StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods));
|
2017-08-07 09:42:12 +02:00
|
|
|
|
StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods));
|
2017-07-06 10:56:03 +02:00
|
|
|
|
}
|
2017-07-05 11:41:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|