SEBWIN-219: Separated existing functionality between runtime and client.
This commit is contained in:
parent
84a3f5cd84
commit
e1a0e9b3d6
39 changed files with 824 additions and 240 deletions
|
@ -12,10 +12,10 @@ using System.Linq;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
using SafeExamBrowser.Contracts.UserInterface;
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||||
|
using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Browser
|
namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
|
@ -23,11 +23,11 @@ namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
private IApplicationButton button;
|
private IApplicationButton button;
|
||||||
private IList<IApplicationInstance> instances = new List<IApplicationInstance>();
|
private IList<IApplicationInstance> instances = new List<IApplicationInstance>();
|
||||||
private ISettings settings;
|
private IBrowserSettings settings;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
private IText text;
|
private IText text;
|
||||||
|
|
||||||
public BrowserApplicationController(ISettings settings, IText text, IUserInterfaceFactory uiFactory)
|
public BrowserApplicationController(IBrowserSettings settings, IText text, IUserInterfaceFactory uiFactory)
|
||||||
{
|
{
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
@ -38,8 +38,8 @@ namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
var cefSettings = new CefSettings
|
var cefSettings = new CefSettings
|
||||||
{
|
{
|
||||||
CachePath = settings.Browser.CachePath,
|
CachePath = settings.CachePath,
|
||||||
LogFile = settings.Browser.LogFile
|
LogFile = settings.LogFile
|
||||||
};
|
};
|
||||||
|
|
||||||
var success = Cef.Initialize(cefSettings, true, null);
|
var success = Cef.Initialize(cefSettings, true, null);
|
||||||
|
@ -69,7 +69,7 @@ namespace SafeExamBrowser.Browser
|
||||||
|
|
||||||
private void CreateNewInstance()
|
private void CreateNewInstance()
|
||||||
{
|
{
|
||||||
var instance = new BrowserApplicationInstance(settings.Browser, text, uiFactory, instances.Count == 0);
|
var instance = new BrowserApplicationInstance(settings, text, uiFactory, instances.Count == 0);
|
||||||
|
|
||||||
button.RegisterInstance(instance);
|
button.RegisterInstance(instance);
|
||||||
instances.Add(instance);
|
instances.Add(instance);
|
||||||
|
|
|
@ -9,16 +9,15 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Client;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.Monitoring;
|
using SafeExamBrowser.Contracts.Monitoring;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||||
using SafeExamBrowser.Core.Behaviour;
|
|
||||||
|
|
||||||
namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
namespace SafeExamBrowser.Client.UnitTests
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class RuntimeControllerTests
|
public class ClientControllerTests
|
||||||
{
|
{
|
||||||
private Mock<IDisplayMonitor> displayMonitorMock;
|
private Mock<IDisplayMonitor> displayMonitorMock;
|
||||||
private Mock<ILogger> loggerMock;
|
private Mock<ILogger> loggerMock;
|
||||||
|
@ -26,7 +25,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
||||||
private Mock<ITaskbar> taskbarMock;
|
private Mock<ITaskbar> taskbarMock;
|
||||||
private Mock<IWindowMonitor> windowMonitorMock;
|
private Mock<IWindowMonitor> windowMonitorMock;
|
||||||
|
|
||||||
private IRuntimeController sut;
|
private IClientController sut;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
|
@ -37,7 +36,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour
|
||||||
taskbarMock = new Mock<ITaskbar>();
|
taskbarMock = new Mock<ITaskbar>();
|
||||||
windowMonitorMock= new Mock<IWindowMonitor>();
|
windowMonitorMock= new Mock<IWindowMonitor>();
|
||||||
|
|
||||||
sut = new RuntimeController(
|
sut = new ClientController(
|
||||||
displayMonitorMock.Object,
|
displayMonitorMock.Object,
|
||||||
loggerMock.Object,
|
loggerMock.Object,
|
||||||
processMonitorMock.Object,
|
processMonitorMock.Object,
|
16
SafeExamBrowser.Client.UnitTests/Properties/AssemblyInfo.cs
Normal file
16
SafeExamBrowser.Client.UnitTests/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("SafeExamBrowser.Client.UnitTests")]
|
||||||
|
[assembly: AssemblyDescription("Safe Exam Browser")]
|
||||||
|
[assembly: AssemblyCompany("ETH Zürich")]
|
||||||
|
[assembly: AssemblyProduct("SafeExamBrowser.Client.UnitTests")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018 ETH Zürich, Educational Development and Technology (LET)")]
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: Guid("15684416-fadf-4c51-85de-4f343bfab752")]
|
||||||
|
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{15684416-FADF-4C51-85DE-4F343BFAB752}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>SafeExamBrowser.Client.UnitTests</RootNamespace>
|
||||||
|
<AssemblyName>SafeExamBrowser.Client.UnitTests</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||||
|
<IsCodedUITest>False</IsCodedUITest>
|
||||||
|
<TestProjectType>UnitTest</TestProjectType>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Moq, Version=4.8.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Moq.4.8.1\lib\net45\Moq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ClientControllerTests.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Client\SafeExamBrowser.Client.csproj">
|
||||||
|
<Project>{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}</Project>
|
||||||
|
<Name>SafeExamBrowser.Client</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
|
||||||
|
<Project>{47DA5933-BEF8-4729-94E6-ABDE2DB12262}</Project>
|
||||||
|
<Name>SafeExamBrowser.Contracts</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
|
</Project>
|
11
SafeExamBrowser.Client.UnitTests/app.config
Normal file
11
SafeExamBrowser.Client.UnitTests/app.config
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
9
SafeExamBrowser.Client.UnitTests/packages.config
Normal file
9
SafeExamBrowser.Client.UnitTests/packages.config
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Castle.Core" version="4.2.1" targetFramework="net461" />
|
||||||
|
<package id="Moq" version="4.8.1" targetFramework="net461" />
|
||||||
|
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net461" />
|
||||||
|
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net461" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net461" />
|
||||||
|
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
|
||||||
|
</packages>
|
|
@ -7,14 +7,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Client;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.Monitoring;
|
using SafeExamBrowser.Contracts.Monitoring;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Core.Behaviour
|
namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
public class RuntimeController : IRuntimeController
|
public class ClientController : IClientController
|
||||||
{
|
{
|
||||||
private IDisplayMonitor displayMonitor;
|
private IDisplayMonitor displayMonitor;
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
|
@ -22,7 +22,7 @@ namespace SafeExamBrowser.Core.Behaviour
|
||||||
private ITaskbar taskbar;
|
private ITaskbar taskbar;
|
||||||
private IWindowMonitor windowMonitor;
|
private IWindowMonitor windowMonitor;
|
||||||
|
|
||||||
public RuntimeController(
|
public ClientController(
|
||||||
IDisplayMonitor displayMonitor,
|
IDisplayMonitor displayMonitor,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IProcessMonitor processMonitor,
|
IProcessMonitor processMonitor,
|
|
@ -7,21 +7,103 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using SafeExamBrowser.Browser;
|
||||||
|
using SafeExamBrowser.Configuration;
|
||||||
|
using SafeExamBrowser.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
|
using SafeExamBrowser.Contracts.Client;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.Monitoring;
|
||||||
|
using SafeExamBrowser.Contracts.SystemComponents;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||||
|
using SafeExamBrowser.Contracts.WindowsApi;
|
||||||
|
using SafeExamBrowser.Core.Behaviour;
|
||||||
|
using SafeExamBrowser.Core.Behaviour.Operations;
|
||||||
|
using SafeExamBrowser.Core.I18n;
|
||||||
|
using SafeExamBrowser.Core.Logging;
|
||||||
|
using SafeExamBrowser.Monitoring.Display;
|
||||||
|
using SafeExamBrowser.Monitoring.Keyboard;
|
||||||
|
using SafeExamBrowser.Monitoring.Mouse;
|
||||||
|
using SafeExamBrowser.Monitoring.Processes;
|
||||||
|
using SafeExamBrowser.Monitoring.Windows;
|
||||||
|
using SafeExamBrowser.SystemComponents;
|
||||||
using SafeExamBrowser.UserInterface.Classic;
|
using SafeExamBrowser.UserInterface.Classic;
|
||||||
|
using SafeExamBrowser.WindowsApi;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client
|
namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
internal class CompositionRoot
|
internal class CompositionRoot
|
||||||
{
|
{
|
||||||
public IShutdownController ShutdownController { get; private set; }
|
private IApplicationController browserController;
|
||||||
public IStartupController StartupController { get; private set; }
|
private IApplicationInfo browserInfo;
|
||||||
public Queue<IOperation> StartupOperations { get; private set; }
|
private IClientController clientController;
|
||||||
public Taskbar Taskbar { get; private set; }
|
private IDisplayMonitor displayMonitor;
|
||||||
|
private IKeyboardInterceptor keyboardInterceptor;
|
||||||
|
private ILogger logger;
|
||||||
|
private IMouseInterceptor mouseInterceptor;
|
||||||
|
private IProcessMonitor processMonitor;
|
||||||
|
private INativeMethods nativeMethods;
|
||||||
|
private ISettings settings;
|
||||||
|
private ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout;
|
||||||
|
private ISystemComponent<ISystemPowerSupplyControl> powerSupply;
|
||||||
|
private ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork;
|
||||||
|
private ISystemInfo systemInfo;
|
||||||
|
private IText text;
|
||||||
|
private IUserInterfaceFactory uiFactory;
|
||||||
|
private IWindowMonitor windowMonitor;
|
||||||
|
|
||||||
public void BuildObjectGraph()
|
internal IShutdownController ShutdownController { get; private set; }
|
||||||
|
internal IStartupController StartupController { get; private set; }
|
||||||
|
internal Queue<IOperation> StartupOperations { get; private set; }
|
||||||
|
internal Taskbar Taskbar { get; private set; }
|
||||||
|
|
||||||
|
internal void BuildObjectGraph()
|
||||||
{
|
{
|
||||||
|
browserInfo = new BrowserApplicationInfo();
|
||||||
|
nativeMethods = new NativeMethods();
|
||||||
|
settings = new SettingsRepository().LoadDefaults();
|
||||||
|
systemInfo = new SystemInfo();
|
||||||
|
uiFactory = new UserInterfaceFactory();
|
||||||
|
|
||||||
|
InitializeLogger();
|
||||||
|
|
||||||
|
text = new Text(logger);
|
||||||
|
Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar)));
|
||||||
|
browserController = new BrowserApplicationController(settings.Browser, text, uiFactory);
|
||||||
|
displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods);
|
||||||
|
keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor)));
|
||||||
|
keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text);
|
||||||
|
mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, typeof(MouseInterceptor)), settings.Mouse);
|
||||||
|
powerSupply = new PowerSupply(new ModuleLogger(logger, typeof(PowerSupply)), text);
|
||||||
|
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
|
||||||
|
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
||||||
|
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, typeof(WirelessNetwork)), text);
|
||||||
|
|
||||||
|
clientController = new ClientController(displayMonitor, new ModuleLogger(logger, typeof(ClientController)), processMonitor, Taskbar, windowMonitor);
|
||||||
|
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
|
||||||
|
StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory);
|
||||||
|
|
||||||
|
StartupOperations = new Queue<IOperation>();
|
||||||
|
StartupOperations.Enqueue(new I18nOperation(logger, text));
|
||||||
|
StartupOperations.Enqueue(new KeyboardInterceptorOperation(keyboardInterceptor, logger, nativeMethods));
|
||||||
|
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
||||||
|
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
||||||
|
StartupOperations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, Taskbar));
|
||||||
|
StartupOperations.Enqueue(new TaskbarOperation(logger, settings.Taskbar, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, text, uiFactory));
|
||||||
|
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
||||||
|
StartupOperations.Enqueue(new ClientControllerOperation(clientController, logger));
|
||||||
|
StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods));
|
||||||
|
StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeLogger()
|
||||||
|
{
|
||||||
|
logger = new Logger();
|
||||||
|
logger.Subscribe(new LogFileWriter(new DefaultLogFormatter(), settings.Logging.ClientLogFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,29 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
@ -46,6 +69,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="App.cs" />
|
<Compile Include="App.cs" />
|
||||||
|
<Compile Include="ClientController.cs" />
|
||||||
<Compile Include="CompositionRoot.cs" />
|
<Compile Include="CompositionRoot.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
@ -64,6 +88,7 @@
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<None Include="app.manifest" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
@ -73,14 +98,38 @@
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Browser\SafeExamBrowser.Browser.csproj">
|
||||||
|
<Project>{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}</Project>
|
||||||
|
<Name>SafeExamBrowser.Browser</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Configuration\SafeExamBrowser.Configuration.csproj">
|
||||||
|
<Project>{C388C4DD-A159-457D-AF92-89F7AD185109}</Project>
|
||||||
|
<Name>SafeExamBrowser.Configuration</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
|
||||||
<Project>{47DA5933-BEF8-4729-94E6-ABDE2DB12262}</Project>
|
<Project>{47DA5933-BEF8-4729-94E6-ABDE2DB12262}</Project>
|
||||||
<Name>SafeExamBrowser.Contracts</Name>
|
<Name>SafeExamBrowser.Contracts</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Core\SafeExamBrowser.Core.csproj">
|
||||||
|
<Project>{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}</Project>
|
||||||
|
<Name>SafeExamBrowser.Core</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Monitoring\SafeExamBrowser.Monitoring.csproj">
|
||||||
|
<Project>{EF563531-4EB5-44B9-A5EC-D6D6F204469B}</Project>
|
||||||
|
<Name>SafeExamBrowser.Monitoring</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.SystemComponents\SafeExamBrowser.SystemComponents.csproj">
|
||||||
|
<Project>{ACEE2EF1-14D2-4B52-8994-5C053055BB51}</Project>
|
||||||
|
<Name>SafeExamBrowser.SystemComponents</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.UserInterface.Classic\SafeExamBrowser.UserInterface.Classic.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.UserInterface.Classic\SafeExamBrowser.UserInterface.Classic.csproj">
|
||||||
<Project>{A502DF54-7169-4647-94BD-18B192924866}</Project>
|
<Project>{A502DF54-7169-4647-94BD-18B192924866}</Project>
|
||||||
<Name>SafeExamBrowser.UserInterface.Classic</Name>
|
<Name>SafeExamBrowser.UserInterface.Classic</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.WindowsApi\SafeExamBrowser.WindowsApi.csproj">
|
||||||
|
<Project>{73724659-4150-4792-A94E-42F5F3C1B696}</Project>
|
||||||
|
<Name>SafeExamBrowser.WindowsApi</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
76
SafeExamBrowser.Client/app.manifest
Normal file
76
SafeExamBrowser.Client/app.manifest
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<!-- UAC Manifest Options
|
||||||
|
If you want to change the Windows User Account Control level replace the
|
||||||
|
requestedExecutionLevel node with one of the following.
|
||||||
|
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||||
|
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||||
|
|
||||||
|
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||||
|
Remove this element if your application requires this virtualization for backwards
|
||||||
|
compatibility.
|
||||||
|
-->
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- A list of the Windows versions that this application has been tested on and is
|
||||||
|
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||||
|
automatically selected the most compatible environment. -->
|
||||||
|
|
||||||
|
<!-- Windows Vista -->
|
||||||
|
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||||
|
|
||||||
|
<!-- Windows 7 -->
|
||||||
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
||||||
|
|
||||||
|
<!-- Windows 8 -->
|
||||||
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||||
|
|
||||||
|
<!-- Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
|
||||||
|
|
||||||
|
<!-- Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
|
||||||
|
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||||
|
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||||
|
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||||
|
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||||
|
<!--
|
||||||
|
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<windowsSettings>
|
||||||
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||||
|
</windowsSettings>
|
||||||
|
</application>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||||
|
<!--
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity
|
||||||
|
type="win32"
|
||||||
|
name="Microsoft.Windows.Common-Controls"
|
||||||
|
version="6.0.0.0"
|
||||||
|
processorArchitecture="*"
|
||||||
|
publicKeyToken="6595b64144ccf1df"
|
||||||
|
language="*"
|
||||||
|
/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
|
-->
|
||||||
|
|
||||||
|
</assembly>
|
|
@ -53,13 +53,15 @@
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BrowserSettings.cs" />
|
<Compile Include="Settings\BrowserSettings.cs" />
|
||||||
<Compile Include="KeyboardSettings.cs" />
|
<Compile Include="Settings\KeyboardSettings.cs" />
|
||||||
<Compile Include="MouseSettings.cs" />
|
<Compile Include="Settings\LoggingSettings.cs" />
|
||||||
<Compile Include="Settings.cs" />
|
<Compile Include="Settings\MouseSettings.cs" />
|
||||||
|
<Compile Include="Settings\Settings.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Settings\SettingsRepository.cs" />
|
||||||
<Compile Include="SystemInfo.cs" />
|
<Compile Include="SystemInfo.cs" />
|
||||||
<Compile Include="TaskbarSettings.cs" />
|
<Compile Include="Settings\TaskbarSettings.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj">
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
|
||||||
{
|
|
||||||
/// <remarks>
|
|
||||||
/// TODO: Replace with proper implementation once configuration aspects are clear...
|
|
||||||
/// </remarks>
|
|
||||||
public class Settings : ISettings
|
|
||||||
{
|
|
||||||
private static readonly string LogFileDate = DateTime.Now.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
|
|
||||||
|
|
||||||
public Settings()
|
|
||||||
{
|
|
||||||
Browser = new BrowserSettings(this);
|
|
||||||
Keyboard = new KeyboardSettings();
|
|
||||||
Mouse = new MouseSettings();
|
|
||||||
Taskbar = new TaskbarSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string AppDataFolderName => nameof(SafeExamBrowser);
|
|
||||||
|
|
||||||
public IBrowserSettings Browser { get; private set; }
|
|
||||||
public IKeyboardSettings Keyboard { get; private set; }
|
|
||||||
public IMouseSettings Mouse { get; private set; }
|
|
||||||
public ITaskbarSettings Taskbar { get; private set; }
|
|
||||||
|
|
||||||
public string ApplicationLogFile
|
|
||||||
{
|
|
||||||
get { return Path.Combine(LogFolderPath, $"{RuntimeIdentifier}_Application.txt"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string LogFolderPath
|
|
||||||
{
|
|
||||||
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolderName, "Logs"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ProgramCopyright
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var executable = Assembly.GetEntryAssembly();
|
|
||||||
var copyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
|
|
||||||
|
|
||||||
return copyright;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ProgramTitle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var executable = Assembly.GetEntryAssembly();
|
|
||||||
var title = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ProgramVersion
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var executable = Assembly.GetEntryAssembly();
|
|
||||||
var version = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string RuntimeIdentifier => LogFileDate;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,42 +7,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
{
|
{
|
||||||
public class BrowserSettings : IBrowserSettings
|
[Serializable]
|
||||||
|
internal class BrowserSettings : IBrowserSettings
|
||||||
{
|
{
|
||||||
private ISettings settings;
|
|
||||||
|
|
||||||
public BrowserSettings(ISettings settings)
|
|
||||||
{
|
|
||||||
this.settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowAddressBar => true;
|
public bool AllowAddressBar => true;
|
||||||
|
|
||||||
public bool AllowBackwardNavigation => true;
|
public bool AllowBackwardNavigation => true;
|
||||||
|
|
||||||
public bool AllowDeveloperConsole => true;
|
public bool AllowDeveloperConsole => true;
|
||||||
|
|
||||||
public bool AllowForwardNavigation => true;
|
public bool AllowForwardNavigation => true;
|
||||||
|
|
||||||
public bool AllowReloading => true;
|
public bool AllowReloading => true;
|
||||||
|
public string CachePath { get; set; }
|
||||||
public string CachePath
|
|
||||||
{
|
|
||||||
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), settings.AppDataFolderName, "Cache"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FullScreenMode => false;
|
public bool FullScreenMode => false;
|
||||||
|
public string LogFile { get; set; }
|
||||||
public string LogFile
|
|
||||||
{
|
|
||||||
get { return Path.Combine(settings.LogFolderPath, $"{settings.RuntimeIdentifier}_Browser.txt"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string StartUrl => "www.duckduckgo.com";
|
public string StartUrl => "www.duckduckgo.com";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,11 +6,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
{
|
{
|
||||||
public class KeyboardSettings : IKeyboardSettings
|
[Serializable]
|
||||||
|
internal class KeyboardSettings : IKeyboardSettings
|
||||||
{
|
{
|
||||||
public bool AllowAltTab => false;
|
public bool AllowAltTab => false;
|
||||||
|
|
22
SafeExamBrowser.Configuration/Settings/LoggingSettings.cs
Normal file
22
SafeExamBrowser.Configuration/Settings/LoggingSettings.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class LoggingSettings : ILoggingSettings
|
||||||
|
{
|
||||||
|
public DateTime ApplicationStartTime { get; set; }
|
||||||
|
public string BrowserLogFile { get; set; }
|
||||||
|
public string ClientLogFile { get; set; }
|
||||||
|
public string RuntimeLogFile { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,11 +6,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
{
|
{
|
||||||
public class MouseSettings : IMouseSettings
|
[Serializable]
|
||||||
|
internal class MouseSettings : IMouseSettings
|
||||||
{
|
{
|
||||||
public bool AllowMiddleButton => false;
|
public bool AllowMiddleButton => false;
|
||||||
|
|
37
SafeExamBrowser.Configuration/Settings/Settings.cs
Normal file
37
SafeExamBrowser.Configuration/Settings/Settings.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class Settings : ISettings
|
||||||
|
{
|
||||||
|
public string AppDataFolder { get; set; }
|
||||||
|
public string ProgramCopyright { get; set; }
|
||||||
|
public string ProgramTitle { get; set; }
|
||||||
|
public string ProgramVersion { get; set; }
|
||||||
|
|
||||||
|
public IBrowserSettings Browser { get; private set; }
|
||||||
|
public IKeyboardSettings Keyboard { get; private set; }
|
||||||
|
public ILoggingSettings Logging { get; private set; }
|
||||||
|
public IMouseSettings Mouse { get; private set; }
|
||||||
|
public ITaskbarSettings Taskbar { get; private set; }
|
||||||
|
|
||||||
|
public Settings(BrowserSettings browser, KeyboardSettings keyboard, LoggingSettings logging, MouseSettings mouse, TaskbarSettings taskbar)
|
||||||
|
{
|
||||||
|
Browser = browser;
|
||||||
|
Keyboard = keyboard;
|
||||||
|
Logging = logging;
|
||||||
|
Mouse = mouse;
|
||||||
|
Taskbar = taskbar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
SafeExamBrowser.Configuration/Settings/SettingsRepository.cs
Normal file
52
SafeExamBrowser.Configuration/Settings/SettingsRepository.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
|
{
|
||||||
|
public class SettingsRepository : ISettingsRepository
|
||||||
|
{
|
||||||
|
public ISettings Load(Uri path)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISettings LoadDefaults()
|
||||||
|
{
|
||||||
|
var browser = new BrowserSettings();
|
||||||
|
var keyboard = new KeyboardSettings();
|
||||||
|
var logging = new LoggingSettings();
|
||||||
|
var mouse = new MouseSettings();
|
||||||
|
var taskbar = new TaskbarSettings();
|
||||||
|
var settings = new Settings(browser, keyboard, logging, mouse, taskbar);
|
||||||
|
var executable = Assembly.GetEntryAssembly();
|
||||||
|
var startTime = DateTime.Now;
|
||||||
|
var logFolderName = "Logs";
|
||||||
|
var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
|
||||||
|
|
||||||
|
settings.AppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser));
|
||||||
|
settings.ProgramCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
|
||||||
|
settings.ProgramTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
||||||
|
settings.ProgramVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
|
|
||||||
|
browser.CachePath = Path.Combine(settings.AppDataFolder, "Cache");
|
||||||
|
|
||||||
|
logging.ApplicationStartTime = DateTime.Now;
|
||||||
|
logging.BrowserLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Browser.txt");
|
||||||
|
logging.ClientLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Client.txt");
|
||||||
|
logging.RuntimeLogFile = Path.Combine(settings.AppDataFolder, logFolderName, $"{logFilePrefix}_Runtime.txt");
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,11 +6,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Configuration
|
namespace SafeExamBrowser.Configuration.Settings
|
||||||
{
|
{
|
||||||
public class TaskbarSettings : ITaskbarSettings
|
[Serializable]
|
||||||
|
internal class TaskbarSettings : ITaskbarSettings
|
||||||
{
|
{
|
||||||
public bool AllowApplicationLog => true;
|
public bool AllowApplicationLog => true;
|
||||||
public bool AllowKeyboardLayout => true;
|
public bool AllowKeyboardLayout => true;
|
23
SafeExamBrowser.Contracts/Client/IClientController.cs
Normal file
23
SafeExamBrowser.Contracts/Client/IClientController.cs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Contracts.Client
|
||||||
|
{
|
||||||
|
public interface IClientController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Wires up and starts the application event handling.
|
||||||
|
/// </summary>
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops the event handling and removes all event subscriptions.
|
||||||
|
/// </summary>
|
||||||
|
void Stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
|
{
|
||||||
|
public interface ILoggingSettings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The point in time when the application was started.
|
||||||
|
/// </summary>
|
||||||
|
DateTime ApplicationStartTime { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The file path under which the log of the browser component is to be stored.
|
||||||
|
/// </summary>
|
||||||
|
string BrowserLogFile { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The file path under which the log of the client component is to be stored.
|
||||||
|
/// </summary>
|
||||||
|
string ClientLogFile { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The file path under which the log of the runtime component is to be stored.
|
||||||
|
/// </summary>
|
||||||
|
string RuntimeLogFile { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,14 +11,9 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
public interface ISettings
|
public interface ISettings
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name used for the application data folder.
|
/// The path of the application data folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string AppDataFolderName { get; }
|
string AppDataFolder { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The file path under which the application log is to be stored.
|
|
||||||
/// </summary>
|
|
||||||
string ApplicationLogFile { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All browser-related settings.
|
/// All browser-related settings.
|
||||||
|
@ -31,9 +26,9 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
IKeyboardSettings Keyboard { get; }
|
IKeyboardSettings Keyboard { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path where the log files are to be stored.
|
/// All logging-related settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string LogFolderPath { get; }
|
ILoggingSettings Logging { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All mouse-related settings.
|
/// All mouse-related settings.
|
||||||
|
@ -55,11 +50,6 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ProgramVersion { get; }
|
string ProgramVersion { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A string uniquely identifying the runtime of the application, used e.g. for the log file names.
|
|
||||||
/// </summary>
|
|
||||||
string RuntimeIdentifier { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All taskbar-related settings.
|
/// All taskbar-related settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
|
{
|
||||||
|
public interface ISettingsRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to load settings from the specified path.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="System.ArgumentException">Thrown if the given path cannot be resolved to a settings file.</exception>
|
||||||
|
ISettings Load(Uri path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the default settings.
|
||||||
|
/// </summary>
|
||||||
|
ISettings LoadDefaults();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,17 +6,17 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace SafeExamBrowser.Contracts.Behaviour
|
namespace SafeExamBrowser.Contracts.Runtime
|
||||||
{
|
{
|
||||||
public interface IRuntimeController
|
public interface IRuntimeController
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wires up the event handling, i.e. subscribes to all relevant application events.
|
/// Wires up and starts the application event handling.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes all event subscriptions.
|
/// Stops the event handling and removes all event subscriptions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Stop();
|
void Stop();
|
||||||
}
|
}
|
|
@ -53,9 +53,10 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Behaviour\IApplicationController.cs" />
|
<Compile Include="Behaviour\IApplicationController.cs" />
|
||||||
<Compile Include="Behaviour\IRuntimeController.cs" />
|
<Compile Include="Runtime\IRuntimeController.cs" />
|
||||||
<Compile Include="Behaviour\INotificationController.cs" />
|
<Compile Include="Behaviour\INotificationController.cs" />
|
||||||
<Compile Include="Behaviour\IOperation.cs" />
|
<Compile Include="Behaviour\IOperation.cs" />
|
||||||
|
<Compile Include="Client\IClientController.cs" />
|
||||||
<Compile Include="Configuration\IIconResource.cs" />
|
<Compile Include="Configuration\IIconResource.cs" />
|
||||||
<Compile Include="Configuration\IApplicationInfo.cs" />
|
<Compile Include="Configuration\IApplicationInfo.cs" />
|
||||||
<Compile Include="Configuration\IApplicationInstance.cs" />
|
<Compile Include="Configuration\IApplicationInstance.cs" />
|
||||||
|
@ -64,10 +65,12 @@
|
||||||
<Compile Include="Configuration\OperatingSystem.cs" />
|
<Compile Include="Configuration\OperatingSystem.cs" />
|
||||||
<Compile Include="Configuration\Settings\IBrowserSettings.cs" />
|
<Compile Include="Configuration\Settings\IBrowserSettings.cs" />
|
||||||
<Compile Include="Configuration\Settings\IKeyboardSettings.cs" />
|
<Compile Include="Configuration\Settings\IKeyboardSettings.cs" />
|
||||||
|
<Compile Include="Configuration\Settings\ILoggingSettings.cs" />
|
||||||
<Compile Include="Configuration\Settings\IMouseSettings.cs" />
|
<Compile Include="Configuration\Settings\IMouseSettings.cs" />
|
||||||
<Compile Include="Configuration\Settings\ISettings.cs" />
|
<Compile Include="Configuration\Settings\ISettings.cs" />
|
||||||
<Compile Include="Behaviour\IShutdownController.cs" />
|
<Compile Include="Behaviour\IShutdownController.cs" />
|
||||||
<Compile Include="Behaviour\IStartupController.cs" />
|
<Compile Include="Behaviour\IStartupController.cs" />
|
||||||
|
<Compile Include="Configuration\Settings\ISettingsRepository.cs" />
|
||||||
<Compile Include="Configuration\Settings\ITaskbarSettings.cs" />
|
<Compile Include="Configuration\Settings\ITaskbarSettings.cs" />
|
||||||
<Compile Include="I18n\IText.cs" />
|
<Compile Include="I18n\IText.cs" />
|
||||||
<Compile Include="I18n\TextKey.cs" />
|
<Compile Include="I18n\TextKey.cs" />
|
||||||
|
@ -112,5 +115,6 @@
|
||||||
<Compile Include="WindowsApi\IBounds.cs" />
|
<Compile Include="WindowsApi\IBounds.cs" />
|
||||||
<Compile Include="WindowsApi\INativeMethods.cs" />
|
<Compile Include="WindowsApi\INativeMethods.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Moq;
|
||||||
|
using SafeExamBrowser.Contracts.Client;
|
||||||
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
using SafeExamBrowser.Core.Behaviour.Operations;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Core.UnitTests.Behaviour.Operations
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class ClientControllerOperationTests
|
||||||
|
{
|
||||||
|
private Mock<ILogger> loggerMock;
|
||||||
|
private Mock<IClientController> clientControllerMock;
|
||||||
|
private Mock<ISplashScreen> splashScreenMock;
|
||||||
|
|
||||||
|
private ClientControllerOperation sut;
|
||||||
|
|
||||||
|
[TestInitialize]
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
loggerMock = new Mock<ILogger>();
|
||||||
|
clientControllerMock = new Mock<IClientController>();
|
||||||
|
splashScreenMock = new Mock<ISplashScreen>();
|
||||||
|
|
||||||
|
sut = new ClientControllerOperation(clientControllerMock.Object, loggerMock.Object)
|
||||||
|
{
|
||||||
|
SplashScreen = splashScreenMock.Object
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustPerformCorrectly()
|
||||||
|
{
|
||||||
|
sut.Perform();
|
||||||
|
|
||||||
|
clientControllerMock.Verify(r => r.Start(), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustRevertCorrectly()
|
||||||
|
{
|
||||||
|
sut.Revert();
|
||||||
|
|
||||||
|
clientControllerMock.Verify(r => r.Stop(), Times.Once);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.Runtime;
|
||||||
using SafeExamBrowser.Contracts.UserInterface;
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
using SafeExamBrowser.Core.Behaviour.Operations;
|
using SafeExamBrowser.Core.Behaviour.Operations;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" />
|
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
@ -56,19 +56,25 @@
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Castle.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Castle.Core.4.1.0\lib\net45\Castle.Core.dll</HintPath>
|
<HintPath>..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Moq, Version=4.7.63.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
<Reference Include="Moq, Version=4.8.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Moq.4.7.63\lib\net45\Moq.dll</HintPath>
|
<HintPath>..\packages\Moq.4.8.1\lib\net45\Moq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -79,10 +85,10 @@
|
||||||
<Compile Include="Behaviour\Operations\KeyboardInterceptorOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\KeyboardInterceptorOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\Operations\MouseInterceptorOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\MouseInterceptorOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\Operations\ProcessMonitorOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\ProcessMonitorOperationTests.cs" />
|
||||||
|
<Compile Include="Behaviour\Operations\ClientControllerOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\Operations\RuntimeControllerOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\RuntimeControllerOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\Operations\TaskbarOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\TaskbarOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\Operations\WindowMonitorOperationTests.cs" />
|
<Compile Include="Behaviour\Operations\WindowMonitorOperationTests.cs" />
|
||||||
<Compile Include="Behaviour\RuntimeControllerTests.cs" />
|
|
||||||
<Compile Include="Behaviour\StartupControllerTests.cs" />
|
<Compile Include="Behaviour\StartupControllerTests.cs" />
|
||||||
<Compile Include="Behaviour\ShutdownControllerTests.cs" />
|
<Compile Include="Behaviour\ShutdownControllerTests.cs" />
|
||||||
<Compile Include="I18n\TextTests.cs" />
|
<Compile Include="I18n\TextTests.cs" />
|
||||||
|
@ -106,9 +112,6 @@
|
||||||
<Name>SafeExamBrowser.Core</Name>
|
<Name>SafeExamBrowser.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="I18n\Text_Invalid.txt">
|
<Content Include="I18n\Text_Invalid.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
@ -120,14 +123,18 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" />
|
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
</Project>
|
</Project>
|
15
SafeExamBrowser.Core.UnitTests/app.config
Normal file
15
SafeExamBrowser.Core.UnitTests/app.config
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Castle.Core" version="4.1.0" targetFramework="net452" />
|
<package id="Castle.Core" version="4.2.1" targetFramework="net452" />
|
||||||
<package id="Moq" version="4.7.63" targetFramework="net452" />
|
<package id="Moq" version="4.8.1" targetFramework="net452" />
|
||||||
<package id="MSTest.TestAdapter" version="1.1.11" targetFramework="net452" />
|
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net452" />
|
||||||
<package id="MSTest.TestFramework" version="1.1.11" targetFramework="net452" />
|
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net452" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net452" />
|
||||||
|
<package id="System.ValueTuple" version="4.4.0" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
|
using SafeExamBrowser.Contracts.Client;
|
||||||
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||||
|
{
|
||||||
|
public class ClientControllerOperation : IOperation
|
||||||
|
{
|
||||||
|
private ILogger logger;
|
||||||
|
private IClientController controller;
|
||||||
|
|
||||||
|
public ISplashScreen SplashScreen { private get; set; }
|
||||||
|
|
||||||
|
public ClientControllerOperation(IClientController controller, ILogger logger)
|
||||||
|
{
|
||||||
|
this.controller = controller;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Perform()
|
||||||
|
{
|
||||||
|
logger.Info("Starting event handling...");
|
||||||
|
SplashScreen.UpdateText(TextKey.SplashScreen_StartEventHandling);
|
||||||
|
|
||||||
|
controller.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Revert()
|
||||||
|
{
|
||||||
|
logger.Info("Stopping event handling...");
|
||||||
|
SplashScreen.UpdateText(TextKey.SplashScreen_StopEventHandling);
|
||||||
|
|
||||||
|
controller.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.Runtime;
|
||||||
using SafeExamBrowser.Contracts.UserInterface;
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Core.Behaviour.Operations
|
namespace SafeExamBrowser.Core.Behaviour.Operations
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Core.Logging
|
namespace SafeExamBrowser.Core.Logging
|
||||||
|
@ -19,14 +18,9 @@ namespace SafeExamBrowser.Core.Logging
|
||||||
private readonly string filePath;
|
private readonly string filePath;
|
||||||
private readonly ILogContentFormatter formatter;
|
private readonly ILogContentFormatter formatter;
|
||||||
|
|
||||||
public LogFileWriter(ILogContentFormatter formatter, ISettings settings)
|
public LogFileWriter(ILogContentFormatter formatter, string filePath)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(settings.LogFolderPath))
|
this.filePath = filePath;
|
||||||
{
|
|
||||||
Directory.CreateDirectory(settings.LogFolderPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.filePath = settings.ApplicationLogFile;
|
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,11 @@
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Behaviour\Operations\ClientControllerOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\ClipboardOperation.cs" />
|
<Compile Include="Behaviour\Operations\ClipboardOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\I18nOperation.cs" />
|
<Compile Include="Behaviour\Operations\I18nOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\KeyboardInterceptorOperation.cs" />
|
<Compile Include="Behaviour\Operations\KeyboardInterceptorOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\MouseInterceptorOperation.cs" />
|
<Compile Include="Behaviour\Operations\MouseInterceptorOperation.cs" />
|
||||||
<Compile Include="Behaviour\RuntimeController.cs" />
|
|
||||||
<Compile Include="Behaviour\Operations\BrowserOperation.cs" />
|
<Compile Include="Behaviour\Operations\BrowserOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\RuntimeControllerOperation.cs" />
|
<Compile Include="Behaviour\Operations\RuntimeControllerOperation.cs" />
|
||||||
<Compile Include="Behaviour\Operations\ProcessMonitorOperation.cs" />
|
<Compile Include="Behaviour\Operations\ProcessMonitorOperation.cs" />
|
||||||
|
|
|
@ -37,6 +37,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Client", "SafeExamBrowser.Client\SafeExamBrowser.Client.csproj", "{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Client", "SafeExamBrowser.Client\SafeExamBrowser.Client.csproj", "{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Client.UnitTests", "SafeExamBrowser.Client.UnitTests\SafeExamBrowser.Client.UnitTests.csproj", "{15684416-FADF-4C51-85DE-4F343BFAB752}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -135,12 +137,20 @@ Global
|
||||||
{A502DF54-7169-4647-94BD-18B192924866}.Release|x86.Build.0 = Release|Any CPU
|
{A502DF54-7169-4647-94BD-18B192924866}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.Build.0 = Debug|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.Build.0 = Debug|x86
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.ActiveCfg = Release|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.Build.0 = Release|Any CPU
|
{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{15684416-FADF-4C51-85DE-4F343BFAB752}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -65,7 +65,8 @@ namespace SafeExamBrowser
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
MainWindow = instances.Taskbar;
|
// TODO: Probably needs new window to display status of running application...
|
||||||
|
MainWindow = instances.SplashScreen;
|
||||||
MainWindow.Closing += MainWindow_Closing;
|
MainWindow.Closing += MainWindow_Closing;
|
||||||
MainWindow.Show();
|
MainWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,29 +6,23 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SafeExamBrowser.Browser;
|
using System.IO;
|
||||||
using SafeExamBrowser.Configuration;
|
using SafeExamBrowser.Configuration;
|
||||||
|
using SafeExamBrowser.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.Behaviour;
|
using SafeExamBrowser.Contracts.Behaviour;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.I18n;
|
using SafeExamBrowser.Contracts.I18n;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.Monitoring;
|
using SafeExamBrowser.Contracts.Runtime;
|
||||||
using SafeExamBrowser.Contracts.SystemComponents;
|
|
||||||
using SafeExamBrowser.Contracts.UserInterface;
|
using SafeExamBrowser.Contracts.UserInterface;
|
||||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
|
||||||
using SafeExamBrowser.Contracts.WindowsApi;
|
using SafeExamBrowser.Contracts.WindowsApi;
|
||||||
using SafeExamBrowser.Core.Behaviour;
|
using SafeExamBrowser.Core.Behaviour;
|
||||||
using SafeExamBrowser.Core.Behaviour.Operations;
|
using SafeExamBrowser.Core.Behaviour.Operations;
|
||||||
using SafeExamBrowser.Core.I18n;
|
using SafeExamBrowser.Core.I18n;
|
||||||
using SafeExamBrowser.Core.Logging;
|
using SafeExamBrowser.Core.Logging;
|
||||||
using SafeExamBrowser.Monitoring.Display;
|
|
||||||
using SafeExamBrowser.Monitoring.Keyboard;
|
|
||||||
using SafeExamBrowser.Monitoring.Mouse;
|
|
||||||
using SafeExamBrowser.Monitoring.Processes;
|
|
||||||
using SafeExamBrowser.Monitoring.Windows;
|
|
||||||
using SafeExamBrowser.SystemComponents;
|
|
||||||
using SafeExamBrowser.UserInterface.Classic;
|
using SafeExamBrowser.UserInterface.Classic;
|
||||||
using SafeExamBrowser.WindowsApi;
|
using SafeExamBrowser.WindowsApi;
|
||||||
|
|
||||||
|
@ -36,69 +30,50 @@ namespace SafeExamBrowser
|
||||||
{
|
{
|
||||||
internal class CompositionRoot
|
internal class CompositionRoot
|
||||||
{
|
{
|
||||||
private IApplicationController browserController;
|
|
||||||
private IApplicationInfo browserInfo;
|
|
||||||
private IDisplayMonitor displayMonitor;
|
|
||||||
private IKeyboardInterceptor keyboardInterceptor;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private ILogContentFormatter logFormatter;
|
|
||||||
private IMouseInterceptor mouseInterceptor;
|
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
private IProcessMonitor processMonitor;
|
|
||||||
private IRuntimeController runtimeController;
|
private IRuntimeController runtimeController;
|
||||||
private ISettings settings;
|
private ISettings settings;
|
||||||
private ISystemComponent<ISystemKeyboardLayoutControl> keyboardLayout;
|
|
||||||
private ISystemComponent<ISystemPowerSupplyControl> powerSupply;
|
|
||||||
private ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork;
|
|
||||||
private ISystemInfo systemInfo;
|
private ISystemInfo systemInfo;
|
||||||
private IText text;
|
private IText text;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
private IWindowMonitor windowMonitor;
|
|
||||||
|
|
||||||
public IShutdownController ShutdownController { get; private set; }
|
internal IShutdownController ShutdownController { get; private set; }
|
||||||
public IStartupController StartupController { get; private set; }
|
internal IStartupController StartupController { get; private set; }
|
||||||
public Queue<IOperation> StartupOperations { get; private set; }
|
internal Queue<IOperation> StartupOperations { get; private set; }
|
||||||
public Taskbar Taskbar { get; private set; }
|
internal SplashScreen SplashScreen { get; private set; }
|
||||||
|
|
||||||
public void BuildObjectGraph()
|
internal void BuildObjectGraph()
|
||||||
{
|
{
|
||||||
browserInfo = new BrowserApplicationInfo();
|
|
||||||
logger = new Logger();
|
|
||||||
logFormatter = new DefaultLogFormatter();
|
|
||||||
nativeMethods = new NativeMethods();
|
nativeMethods = new NativeMethods();
|
||||||
settings = new Settings();
|
settings = new SettingsRepository().LoadDefaults();
|
||||||
systemInfo = new SystemInfo();
|
systemInfo = new SystemInfo();
|
||||||
uiFactory = new UserInterfaceFactory();
|
uiFactory = new UserInterfaceFactory();
|
||||||
|
|
||||||
logger.Subscribe(new LogFileWriter(logFormatter, settings));
|
InitializeLogger();
|
||||||
|
|
||||||
text = new Text(logger);
|
text = new Text(logger);
|
||||||
Taskbar = new Taskbar(new ModuleLogger(logger, typeof(Taskbar)));
|
|
||||||
browserController = new BrowserApplicationController(settings, text, uiFactory);
|
|
||||||
displayMonitor = new DisplayMonitor(new ModuleLogger(logger, typeof(DisplayMonitor)), nativeMethods);
|
|
||||||
keyboardInterceptor = new KeyboardInterceptor(settings.Keyboard, new ModuleLogger(logger, typeof(KeyboardInterceptor)));
|
|
||||||
keyboardLayout = new KeyboardLayout(new ModuleLogger(logger, typeof(KeyboardLayout)), text);
|
|
||||||
mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, typeof(MouseInterceptor)), settings.Mouse);
|
|
||||||
powerSupply = new PowerSupply(new ModuleLogger(logger, typeof(PowerSupply)), text);
|
|
||||||
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)), nativeMethods);
|
|
||||||
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)), nativeMethods);
|
|
||||||
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, typeof(WirelessNetwork)), text);
|
|
||||||
|
|
||||||
runtimeController = new RuntimeController(displayMonitor, new ModuleLogger(logger, typeof(RuntimeController)), processMonitor, Taskbar, windowMonitor);
|
runtimeController = new RuntimeController(new ModuleLogger(logger, typeof(RuntimeController)));
|
||||||
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
|
ShutdownController = new ShutdownController(logger, settings, text, uiFactory);
|
||||||
StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory);
|
StartupController = new StartupController(logger, settings, systemInfo, text, uiFactory);
|
||||||
|
|
||||||
StartupOperations = new Queue<IOperation>();
|
StartupOperations = new Queue<IOperation>();
|
||||||
StartupOperations.Enqueue(new I18nOperation(logger, text));
|
StartupOperations.Enqueue(new I18nOperation(logger, text));
|
||||||
StartupOperations.Enqueue(new KeyboardInterceptorOperation(keyboardInterceptor, logger, nativeMethods));
|
|
||||||
StartupOperations.Enqueue(new WindowMonitorOperation(logger, windowMonitor));
|
|
||||||
StartupOperations.Enqueue(new ProcessMonitorOperation(logger, processMonitor));
|
|
||||||
StartupOperations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, Taskbar));
|
|
||||||
StartupOperations.Enqueue(new TaskbarOperation(logger, settings.Taskbar, keyboardLayout, powerSupply, wirelessNetwork, systemInfo, Taskbar, text, uiFactory));
|
|
||||||
StartupOperations.Enqueue(new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory));
|
|
||||||
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
|
StartupOperations.Enqueue(new RuntimeControllerOperation(runtimeController, logger));
|
||||||
StartupOperations.Enqueue(new ClipboardOperation(logger, nativeMethods));
|
}
|
||||||
StartupOperations.Enqueue(new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods));
|
|
||||||
|
private void InitializeLogger()
|
||||||
|
{
|
||||||
|
var logFolder = Path.GetDirectoryName(settings.Logging.RuntimeLogFile);
|
||||||
|
|
||||||
|
if (!Directory.Exists(logFolder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(logFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger = new Logger();
|
||||||
|
logger.Subscribe(new LogFileWriter(new DefaultLogFormatter(), settings.Logging.RuntimeLogFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
SafeExamBrowser/RuntimeController.cs
Normal file
33
SafeExamBrowser/RuntimeController.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
|
using SafeExamBrowser.Contracts.Runtime;
|
||||||
|
|
||||||
|
namespace SafeExamBrowser
|
||||||
|
{
|
||||||
|
public class RuntimeController : IRuntimeController
|
||||||
|
{
|
||||||
|
private ILogger logger;
|
||||||
|
|
||||||
|
public RuntimeController(ILogger logger)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -101,6 +101,7 @@
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="RuntimeController.cs" />
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
|
Loading…
Reference in a new issue