SEBWIN-311: Moved all client controller dependencies to the client context and made context available to all client operations.
This commit is contained in:
parent
8fd22032b6
commit
3efd7fbbd0
27 changed files with 244 additions and 303 deletions
|
@ -6,12 +6,6 @@
|
||||||
* 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.Browser.Contracts;
|
|
||||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
|
||||||
using SafeExamBrowser.Settings;
|
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Contracts
|
namespace SafeExamBrowser.Client.Contracts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -19,31 +13,6 @@ namespace SafeExamBrowser.Client.Contracts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IClientController
|
public interface IClientController
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The global configuration information to be used during application execution.
|
|
||||||
/// </summary>
|
|
||||||
AppConfig AppConfig { set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The browser application.
|
|
||||||
/// </summary>
|
|
||||||
IBrowserApplication Browser { set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The client host used for communication handling.
|
|
||||||
/// </summary>
|
|
||||||
IClientHost ClientHost { set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The session identifier of the currently running session.
|
|
||||||
/// </summary>
|
|
||||||
Guid SessionId { set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The settings to be used during application execution.
|
|
||||||
/// </summary>
|
|
||||||
AppSettings Settings { set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reverts any changes, releases all used resources and terminates the client.
|
/// Reverts any changes, releases all used resources and terminates the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,5 +22,10 @@ namespace SafeExamBrowser.Client.Contracts
|
||||||
/// Tries to start the client. Returns <c>true</c> if successful, otherwise <c>false</c>.
|
/// Tries to start the client. Returns <c>true</c> if successful, otherwise <c>false</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool TryStart();
|
bool TryStart();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instructs the controller to update the application configuration.
|
||||||
|
/// </summary>
|
||||||
|
void UpdateAppConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,26 +59,10 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Browser.Contracts\SafeExamBrowser.Browser.Contracts.csproj">
|
|
||||||
<Project>{5fb5273d-277c-41dd-8593-a25ce1aff2e9}</Project>
|
|
||||||
<Name>SafeExamBrowser.Browser.Contracts</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Communication.Contracts\SafeExamBrowser.Communication.Contracts.csproj">
|
|
||||||
<Project>{0cd2c5fe-711a-4c32-afe0-bb804fe8b220}</Project>
|
|
||||||
<Name>SafeExamBrowser.Communication.Contracts</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Configuration.Contracts\SafeExamBrowser.Configuration.Contracts.csproj">
|
|
||||||
<Project>{7d74555e-63e1-4c46-bd0a-8580552368c8}</Project>
|
|
||||||
<Name>SafeExamBrowser.Configuration.Contracts</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Core.Contracts\SafeExamBrowser.Core.Contracts.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.Core.Contracts\SafeExamBrowser.Core.Contracts.csproj">
|
||||||
<Project>{fe0e1224-b447-4b14-81e7-ed7d84822aa0}</Project>
|
<Project>{fe0e1224-b447-4b14-81e7-ed7d84822aa0}</Project>
|
||||||
<Name>SafeExamBrowser.Core.Contracts</Name>
|
<Name>SafeExamBrowser.Core.Contracts</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Settings\SafeExamBrowser.Settings.csproj">
|
|
||||||
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
|
|
||||||
<Name>SafeExamBrowser.Settings</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -40,6 +40,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
private Mock<IApplicationMonitor> applicationMonitor;
|
private Mock<IApplicationMonitor> applicationMonitor;
|
||||||
private Mock<IBrowserApplication> browserController;
|
private Mock<IBrowserApplication> browserController;
|
||||||
private Mock<IClientHost> clientHost;
|
private Mock<IClientHost> clientHost;
|
||||||
|
private ClientContext context;
|
||||||
private Mock<IDisplayMonitor> displayMonitor;
|
private Mock<IDisplayMonitor> displayMonitor;
|
||||||
private Mock<IExplorerShell> explorerShell;
|
private Mock<IExplorerShell> explorerShell;
|
||||||
private Mock<IHashAlgorithm> hashAlgorithm;
|
private Mock<IHashAlgorithm> hashAlgorithm;
|
||||||
|
@ -65,6 +66,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
applicationMonitor = new Mock<IApplicationMonitor>();
|
applicationMonitor = new Mock<IApplicationMonitor>();
|
||||||
browserController = new Mock<IBrowserApplication>();
|
browserController = new Mock<IBrowserApplication>();
|
||||||
clientHost = new Mock<IClientHost>();
|
clientHost = new Mock<IClientHost>();
|
||||||
|
context = new ClientContext();
|
||||||
displayMonitor = new Mock<IDisplayMonitor>();
|
displayMonitor = new Mock<IDisplayMonitor>();
|
||||||
explorerShell = new Mock<IExplorerShell>();
|
explorerShell = new Mock<IExplorerShell>();
|
||||||
hashAlgorithm = new Mock<IHashAlgorithm>();
|
hashAlgorithm = new Mock<IHashAlgorithm>();
|
||||||
|
@ -87,6 +89,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
sut = new ClientController(
|
sut = new ClientController(
|
||||||
actionCenter.Object,
|
actionCenter.Object,
|
||||||
applicationMonitor.Object,
|
applicationMonitor.Object,
|
||||||
|
context,
|
||||||
displayMonitor.Object,
|
displayMonitor.Object,
|
||||||
explorerShell.Object,
|
explorerShell.Object,
|
||||||
hashAlgorithm.Object,
|
hashAlgorithm.Object,
|
||||||
|
@ -100,11 +103,11 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
text.Object,
|
text.Object,
|
||||||
uiFactory.Object);
|
uiFactory.Object);
|
||||||
|
|
||||||
sut.AppConfig = appConfig;
|
context.AppConfig = appConfig;
|
||||||
sut.Browser = browserController.Object;
|
context.Browser = browserController.Object;
|
||||||
sut.ClientHost = clientHost.Object;
|
context.ClientHost = clientHost.Object;
|
||||||
sut.SessionId = sessionId;
|
context.SessionId = sessionId;
|
||||||
sut.Settings = settings;
|
context.Settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -540,8 +543,8 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Shutdown_MustNotFailIfDependenciesAreNull()
|
public void Shutdown_MustNotFailIfDependenciesAreNull()
|
||||||
{
|
{
|
||||||
sut.Browser = null;
|
context.Browser = null;
|
||||||
sut.ClientHost = null;
|
context.ClientHost = null;
|
||||||
|
|
||||||
sut.Terminate();
|
sut.Terminate();
|
||||||
}
|
}
|
||||||
|
@ -591,7 +594,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
uiFactory.Setup(u => u.CreateSplashScreen(It.IsAny<AppConfig>())).Returns(splashScreen.Object);
|
uiFactory.Setup(u => u.CreateSplashScreen(It.IsAny<AppConfig>())).Returns(splashScreen.Object);
|
||||||
|
|
||||||
sut.TryStart();
|
sut.TryStart();
|
||||||
sut.AppConfig = appConfig;
|
sut.UpdateAppConfig();
|
||||||
|
|
||||||
splashScreen.VerifySet(s => s.AppConfig = appConfig, Times.Once);
|
splashScreen.VerifySet(s => s.AppConfig = appConfig, Times.Once);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Applications.Contracts;
|
using SafeExamBrowser.Browser.Contracts;
|
||||||
using SafeExamBrowser.Client.Operations;
|
using SafeExamBrowser.Client.Operations;
|
||||||
using SafeExamBrowser.Logging.Contracts;
|
using SafeExamBrowser.Logging.Contracts;
|
||||||
using SafeExamBrowser.UserInterface.Contracts;
|
using SafeExamBrowser.UserInterface.Contracts;
|
||||||
|
@ -20,7 +20,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
public class BrowserOperationTests
|
public class BrowserOperationTests
|
||||||
{
|
{
|
||||||
private Mock<IActionCenter> actionCenter;
|
private Mock<IActionCenter> actionCenter;
|
||||||
private Mock<IApplication> application;
|
private Mock<IBrowserApplication> browser;
|
||||||
|
private ClientContext context;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
private Mock<ITaskbar> taskbar;
|
private Mock<ITaskbar> taskbar;
|
||||||
private Mock<IUserInterfaceFactory> uiFactory;
|
private Mock<IUserInterfaceFactory> uiFactory;
|
||||||
|
@ -31,12 +32,15 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
actionCenter = new Mock<IActionCenter>();
|
actionCenter = new Mock<IActionCenter>();
|
||||||
application = new Mock<IApplication>();
|
browser = new Mock<IBrowserApplication>();
|
||||||
|
context = new ClientContext();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
taskbar = new Mock<ITaskbar>();
|
taskbar = new Mock<ITaskbar>();
|
||||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||||
|
|
||||||
sut = new BrowserOperation(actionCenter.Object, application.Object, logger.Object, taskbar.Object, uiFactory.Object);
|
context.Browser = browser.Object;
|
||||||
|
|
||||||
|
sut = new BrowserOperation(actionCenter.Object, context, logger.Object, taskbar.Object, uiFactory.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -44,7 +48,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
{
|
{
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
|
|
||||||
application.Verify(c => c.Initialize(), Times.Once);
|
browser.Verify(c => c.Initialize(), Times.Once);
|
||||||
actionCenter.Verify(a => a.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
actionCenter.Verify(a => a.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
||||||
taskbar.Verify(t => t.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
taskbar.Verify(t => t.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +57,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
public void MustRevertCorrectly()
|
public void MustRevertCorrectly()
|
||||||
{
|
{
|
||||||
sut.Revert();
|
sut.Revert();
|
||||||
application.Verify(c => c.Terminate(), Times.Once);
|
browser.Verify(c => c.Terminate(), Times.Once);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -22,6 +21,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
public class ClientHostDisconnectionOperationTests
|
public class ClientHostDisconnectionOperationTests
|
||||||
{
|
{
|
||||||
private Mock<IClientHost> clientHost;
|
private Mock<IClientHost> clientHost;
|
||||||
|
private ClientContext context;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
|
|
||||||
private ClientHostDisconnectionOperation sut;
|
private ClientHostDisconnectionOperation sut;
|
||||||
|
@ -30,9 +30,12 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
clientHost = new Mock<IClientHost>();
|
clientHost = new Mock<IClientHost>();
|
||||||
|
context = new ClientContext();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
|
|
||||||
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, 0);
|
context.ClientHost = clientHost.Object;
|
||||||
|
|
||||||
|
sut = new ClientHostDisconnectionOperation(context, logger.Object, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -42,7 +45,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
var before = default(DateTime);
|
var before = default(DateTime);
|
||||||
var timeout_ms = 200;
|
var timeout_ms = 200;
|
||||||
|
|
||||||
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
sut = new ClientHostDisconnectionOperation(context, logger.Object, timeout_ms);
|
||||||
|
|
||||||
clientHost.SetupGet(h => h.IsConnected).Returns(true).Callback(() => Task.Delay(10).ContinueWith((_) =>
|
clientHost.SetupGet(h => h.IsConnected).Returns(true).Callback(() => Task.Delay(10).ContinueWith((_) =>
|
||||||
{
|
{
|
||||||
|
@ -66,7 +69,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
var before = default(DateTime);
|
var before = default(DateTime);
|
||||||
var timeout_ms = 200;
|
var timeout_ms = 200;
|
||||||
|
|
||||||
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
sut = new ClientHostDisconnectionOperation(context, logger.Object, timeout_ms);
|
||||||
|
|
||||||
clientHost.SetupGet(h => h.IsConnected).Returns(true);
|
clientHost.SetupGet(h => h.IsConnected).Returns(true);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class ClipboardOperationTests
|
public class ClipboardOperationTests
|
||||||
{
|
{
|
||||||
|
private ClientContext context;
|
||||||
private Mock<ILogger> loggerMock;
|
private Mock<ILogger> loggerMock;
|
||||||
private Mock<INativeMethods> nativeMethodsMock;
|
private Mock<INativeMethods> nativeMethodsMock;
|
||||||
|
|
||||||
|
@ -25,10 +26,11 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
context = new ClientContext();
|
||||||
loggerMock = new Mock<ILogger>();
|
loggerMock = new Mock<ILogger>();
|
||||||
nativeMethodsMock = new Mock<INativeMethods>();
|
nativeMethodsMock = new Mock<INativeMethods>();
|
||||||
|
|
||||||
sut = new ClipboardOperation(loggerMock.Object, nativeMethodsMock.Object);
|
sut = new ClipboardOperation(context, loggerMock.Object, nativeMethodsMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class ConfigurationOperationTests
|
public class ConfigurationOperationTests
|
||||||
{
|
{
|
||||||
private ClientConfiguration configuration;
|
|
||||||
private ClientContext context;
|
private ClientContext context;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
private Mock<IRuntimeProxy> runtime;
|
private Mock<IRuntimeProxy> runtime;
|
||||||
|
@ -31,12 +30,11 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
configuration = new ClientConfiguration();
|
|
||||||
context = new ClientContext();
|
context = new ClientContext();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
runtime = new Mock<IRuntimeProxy>();
|
runtime = new Mock<IRuntimeProxy>();
|
||||||
|
|
||||||
sut = new ConfigurationOperation(configuration, context, logger.Object, runtime.Object);
|
sut = new ConfigurationOperation(context, logger.Object, runtime.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -56,9 +54,9 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
|
|
||||||
var result = sut.Perform();
|
var result = sut.Perform();
|
||||||
|
|
||||||
Assert.AreSame(configuration.AppConfig, response.Configuration.AppConfig);
|
Assert.AreSame(context.AppConfig, response.Configuration.AppConfig);
|
||||||
Assert.AreEqual(configuration.SessionId, response.Configuration.SessionId);
|
Assert.AreEqual(context.SessionId, response.Configuration.SessionId);
|
||||||
Assert.AreSame(configuration.Settings, response.Configuration.Settings);
|
Assert.AreSame(context.Settings, response.Configuration.Settings);
|
||||||
Assert.AreEqual(OperationResult.Success, result);
|
Assert.AreEqual(OperationResult.Success, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class DisplayMonitorOperationTests
|
public class DisplayMonitorOperationTests
|
||||||
{
|
{
|
||||||
|
private ClientContext context;
|
||||||
private Mock<IDisplayMonitor> displayMonitorMock;
|
private Mock<IDisplayMonitor> displayMonitorMock;
|
||||||
private Mock<ILogger> loggerMock;
|
private Mock<ILogger> loggerMock;
|
||||||
private Mock<ITaskbar> taskbarMock;
|
private Mock<ITaskbar> taskbarMock;
|
||||||
|
@ -27,11 +28,12 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
loggerMock = new Mock<ILogger>();
|
context = new ClientContext();
|
||||||
displayMonitorMock = new Mock<IDisplayMonitor>();
|
displayMonitorMock = new Mock<IDisplayMonitor>();
|
||||||
|
loggerMock = new Mock<ILogger>();
|
||||||
taskbarMock = new Mock<ITaskbar>();
|
taskbarMock = new Mock<ITaskbar>();
|
||||||
|
|
||||||
sut = new DisplayMonitorOperation(displayMonitorMock.Object, loggerMock.Object, taskbarMock.Object);
|
sut = new DisplayMonitorOperation(context, displayMonitorMock.Object, loggerMock.Object, taskbarMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class KeyboardInterceptorOperationTests
|
public class KeyboardInterceptorOperationTests
|
||||||
{
|
{
|
||||||
|
private ClientContext context;
|
||||||
private Mock<IKeyboardInterceptor> keyboardInterceptorMock;
|
private Mock<IKeyboardInterceptor> keyboardInterceptorMock;
|
||||||
private Mock<ILogger> loggerMock;
|
private Mock<ILogger> loggerMock;
|
||||||
|
|
||||||
|
@ -25,10 +26,11 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
context = new ClientContext();
|
||||||
keyboardInterceptorMock = new Mock<IKeyboardInterceptor>();
|
keyboardInterceptorMock = new Mock<IKeyboardInterceptor>();
|
||||||
loggerMock = new Mock<ILogger>();
|
loggerMock = new Mock<ILogger>();
|
||||||
|
|
||||||
sut = new KeyboardInterceptorOperation(keyboardInterceptorMock.Object, loggerMock.Object);
|
sut = new KeyboardInterceptorOperation(context, keyboardInterceptorMock.Object, loggerMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class MouseInterceptorOperationTests
|
public class MouseInterceptorOperationTests
|
||||||
{
|
{
|
||||||
|
private ClientContext context;
|
||||||
private Mock<IMouseInterceptor> mouseInterceptorMock;
|
private Mock<IMouseInterceptor> mouseInterceptorMock;
|
||||||
private Mock<ILogger> loggerMock;
|
private Mock<ILogger> loggerMock;
|
||||||
|
|
||||||
|
@ -25,10 +26,11 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
context = new ClientContext();
|
||||||
mouseInterceptorMock = new Mock<IMouseInterceptor>();
|
mouseInterceptorMock = new Mock<IMouseInterceptor>();
|
||||||
loggerMock = new Mock<ILogger>();
|
loggerMock = new Mock<ILogger>();
|
||||||
|
|
||||||
sut = new MouseInterceptorOperation(loggerMock.Object, mouseInterceptorMock.Object);
|
sut = new MouseInterceptorOperation(context, loggerMock.Object, mouseInterceptorMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class RuntimeConnectionOperationTests
|
public class RuntimeConnectionOperationTests
|
||||||
{
|
{
|
||||||
|
private ClientContext context;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
private Mock<IRuntimeProxy> runtime;
|
private Mock<IRuntimeProxy> runtime;
|
||||||
private Guid token;
|
private Guid token;
|
||||||
|
@ -27,11 +28,12 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
context = new ClientContext();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
runtime = new Mock<IRuntimeProxy>();
|
runtime = new Mock<IRuntimeProxy>();
|
||||||
token = Guid.NewGuid();
|
token = Guid.NewGuid();
|
||||||
|
|
||||||
sut = new RuntimeConnectionOperation(logger.Object, runtime.Object, token);
|
sut = new RuntimeConnectionOperation(context, logger.Object, runtime.Object, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -11,9 +11,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Client.Contracts;
|
using SafeExamBrowser.Client.Contracts;
|
||||||
using SafeExamBrowser.Client.Operations;
|
using SafeExamBrowser.Client.Operations;
|
||||||
using SafeExamBrowser.Settings.UserInterface;
|
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
using SafeExamBrowser.Logging.Contracts;
|
using SafeExamBrowser.Logging.Contracts;
|
||||||
|
using SafeExamBrowser.Settings;
|
||||||
using SafeExamBrowser.SystemComponents.Contracts;
|
using SafeExamBrowser.SystemComponents.Contracts;
|
||||||
using SafeExamBrowser.SystemComponents.Contracts.Audio;
|
using SafeExamBrowser.SystemComponents.Contracts.Audio;
|
||||||
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
|
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
|
||||||
|
@ -30,10 +30,9 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
{
|
{
|
||||||
private Mock<IActionCenter> actionCenter;
|
private Mock<IActionCenter> actionCenter;
|
||||||
private List<IActionCenterActivator> activators;
|
private List<IActionCenterActivator> activators;
|
||||||
private ActionCenterSettings actionCenterSettings;
|
|
||||||
private Mock<IAudio> audio;
|
private Mock<IAudio> audio;
|
||||||
|
private ClientContext context;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
private TaskbarSettings taskbarSettings;
|
|
||||||
private Mock<ITerminationActivator> terminationActivator;
|
private Mock<ITerminationActivator> terminationActivator;
|
||||||
private Mock<INotificationInfo> aboutInfo;
|
private Mock<INotificationInfo> aboutInfo;
|
||||||
private Mock<INotificationController> aboutController;
|
private Mock<INotificationController> aboutController;
|
||||||
|
@ -54,8 +53,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
{
|
{
|
||||||
actionCenter = new Mock<IActionCenter>();
|
actionCenter = new Mock<IActionCenter>();
|
||||||
activators = new List<IActionCenterActivator>();
|
activators = new List<IActionCenterActivator>();
|
||||||
actionCenterSettings = new ActionCenterSettings();
|
|
||||||
audio = new Mock<IAudio>();
|
audio = new Mock<IAudio>();
|
||||||
|
context = new ClientContext();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
aboutInfo = new Mock<INotificationInfo>();
|
aboutInfo = new Mock<INotificationInfo>();
|
||||||
aboutController = new Mock<INotificationController>();
|
aboutController = new Mock<INotificationController>();
|
||||||
|
@ -65,12 +64,13 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
powerSupply = new Mock<IPowerSupply>();
|
powerSupply = new Mock<IPowerSupply>();
|
||||||
systemInfo = new Mock<ISystemInfo>();
|
systemInfo = new Mock<ISystemInfo>();
|
||||||
taskbar = new Mock<ITaskbar>();
|
taskbar = new Mock<ITaskbar>();
|
||||||
taskbarSettings = new TaskbarSettings();
|
|
||||||
terminationActivator = new Mock<ITerminationActivator>();
|
terminationActivator = new Mock<ITerminationActivator>();
|
||||||
text = new Mock<IText>();
|
text = new Mock<IText>();
|
||||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||||
wirelessAdapter = new Mock<IWirelessAdapter>();
|
wirelessAdapter = new Mock<IWirelessAdapter>();
|
||||||
|
|
||||||
|
context.Settings = new AppSettings();
|
||||||
|
|
||||||
uiFactory
|
uiFactory
|
||||||
.Setup(u => u.CreateNotificationControl(It.IsAny<INotificationController>(), It.IsAny<INotificationInfo>(), It.IsAny<Location>()))
|
.Setup(u => u.CreateNotificationControl(It.IsAny<INotificationController>(), It.IsAny<INotificationInfo>(), It.IsAny<Location>()))
|
||||||
.Returns(new Mock<INotificationControl>().Object);
|
.Returns(new Mock<INotificationControl>().Object);
|
||||||
|
@ -78,10 +78,10 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
sut = new ShellOperation(
|
sut = new ShellOperation(
|
||||||
actionCenter.Object,
|
actionCenter.Object,
|
||||||
activators,
|
activators,
|
||||||
actionCenterSettings,
|
|
||||||
audio.Object,
|
audio.Object,
|
||||||
aboutInfo.Object,
|
aboutInfo.Object,
|
||||||
aboutController.Object,
|
aboutController.Object,
|
||||||
|
context,
|
||||||
keyboard.Object,
|
keyboard.Object,
|
||||||
logger.Object,
|
logger.Object,
|
||||||
logInfo.Object,
|
logInfo.Object,
|
||||||
|
@ -89,7 +89,6 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
powerSupply.Object,
|
powerSupply.Object,
|
||||||
systemInfo.Object,
|
systemInfo.Object,
|
||||||
taskbar.Object,
|
taskbar.Object,
|
||||||
taskbarSettings,
|
|
||||||
terminationActivator.Object,
|
terminationActivator.Object,
|
||||||
text.Object,
|
text.Object,
|
||||||
uiFactory.Object,
|
uiFactory.Object,
|
||||||
|
@ -106,7 +105,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
new Mock<IActionCenterActivator>()
|
new Mock<IActionCenterActivator>()
|
||||||
};
|
};
|
||||||
|
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
|
|
||||||
foreach (var activator in activatorMocks)
|
foreach (var activator in activatorMocks)
|
||||||
{
|
{
|
||||||
|
@ -126,10 +125,10 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustInitializeClock()
|
public void Perform_MustInitializeClock()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowClock = true;
|
context.Settings.ActionCenter.ShowClock = true;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowClock = true;
|
context.Settings.Taskbar.ShowClock = true;
|
||||||
|
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
|
|
||||||
|
@ -140,10 +139,10 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustNotInitializeClock()
|
public void Perform_MustNotInitializeClock()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowClock = false;
|
context.Settings.ActionCenter.ShowClock = false;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowClock = false;
|
context.Settings.Taskbar.ShowClock = false;
|
||||||
|
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
|
|
||||||
|
@ -154,12 +153,12 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustInitializeNotifications()
|
public void Perform_MustInitializeNotifications()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowApplicationInfo = true;
|
context.Settings.ActionCenter.ShowApplicationInfo = true;
|
||||||
actionCenterSettings.ShowApplicationLog = true;
|
context.Settings.ActionCenter.ShowApplicationLog = true;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowApplicationInfo = true;
|
context.Settings.Taskbar.ShowApplicationInfo = true;
|
||||||
taskbarSettings.ShowApplicationLog = true;
|
context.Settings.Taskbar.ShowApplicationLog = true;
|
||||||
|
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
|
|
||||||
|
@ -172,10 +171,10 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
{
|
{
|
||||||
var logControl = new Mock<INotificationControl>();
|
var logControl = new Mock<INotificationControl>();
|
||||||
|
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowApplicationLog = false;
|
context.Settings.ActionCenter.ShowApplicationLog = false;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowApplicationLog = false;
|
context.Settings.Taskbar.ShowApplicationLog = false;
|
||||||
|
|
||||||
uiFactory
|
uiFactory
|
||||||
.Setup(f => f.CreateNotificationControl(It.IsAny<INotificationController>(), It.Is<INotificationInfo>(i => i == logInfo.Object), It.IsAny<Location>()))
|
.Setup(f => f.CreateNotificationControl(It.IsAny<INotificationController>(), It.Is<INotificationInfo>(i => i == logInfo.Object), It.IsAny<Location>()))
|
||||||
|
@ -190,14 +189,14 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustInitializeSystemComponents()
|
public void Perform_MustInitializeSystemComponents()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowAudio = true;
|
context.Settings.ActionCenter.ShowAudio = true;
|
||||||
actionCenterSettings.ShowKeyboardLayout = true;
|
context.Settings.ActionCenter.ShowKeyboardLayout = true;
|
||||||
actionCenterSettings.ShowWirelessNetwork = true;
|
context.Settings.ActionCenter.ShowWirelessNetwork = true;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowAudio = true;
|
context.Settings.Taskbar.ShowAudio = true;
|
||||||
taskbarSettings.ShowKeyboardLayout = true;
|
context.Settings.Taskbar.ShowKeyboardLayout = true;
|
||||||
taskbarSettings.ShowWirelessNetwork = true;
|
context.Settings.Taskbar.ShowWirelessNetwork = true;
|
||||||
|
|
||||||
systemInfo.SetupGet(s => s.HasBattery).Returns(true);
|
systemInfo.SetupGet(s => s.HasBattery).Returns(true);
|
||||||
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
|
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
|
||||||
|
@ -218,14 +217,14 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustNotInitializeSystemComponents()
|
public void Perform_MustNotInitializeSystemComponents()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
actionCenterSettings.ShowAudio = false;
|
context.Settings.ActionCenter.ShowAudio = false;
|
||||||
actionCenterSettings.ShowKeyboardLayout = false;
|
context.Settings.ActionCenter.ShowKeyboardLayout = false;
|
||||||
actionCenterSettings.ShowWirelessNetwork = false;
|
context.Settings.ActionCenter.ShowWirelessNetwork = false;
|
||||||
taskbarSettings.EnableTaskbar = true;
|
context.Settings.Taskbar.EnableTaskbar = true;
|
||||||
taskbarSettings.ShowAudio = false;
|
context.Settings.Taskbar.ShowAudio = false;
|
||||||
taskbarSettings.ShowKeyboardLayout = false;
|
context.Settings.Taskbar.ShowKeyboardLayout = false;
|
||||||
taskbarSettings.ShowWirelessNetwork = false;
|
context.Settings.Taskbar.ShowWirelessNetwork = false;
|
||||||
|
|
||||||
systemInfo.SetupGet(s => s.HasBattery).Returns(false);
|
systemInfo.SetupGet(s => s.HasBattery).Returns(false);
|
||||||
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
|
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
|
||||||
|
@ -246,7 +245,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustNotInitializeActionCenterIfNotEnabled()
|
public void Perform_MustNotInitializeActionCenterIfNotEnabled()
|
||||||
{
|
{
|
||||||
actionCenterSettings.EnableActionCenter = false;
|
context.Settings.ActionCenter.EnableActionCenter = false;
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
actionCenter.VerifyNoOtherCalls();
|
actionCenter.VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
|
@ -254,7 +253,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustNotInitializeTaskbarIfNotEnabled()
|
public void Perform_MustNotInitializeTaskbarIfNotEnabled()
|
||||||
{
|
{
|
||||||
taskbarSettings.EnableTaskbar = false;
|
context.Settings.Taskbar.EnableTaskbar = false;
|
||||||
sut.Perform();
|
sut.Perform();
|
||||||
taskbar.VerifyNoOtherCalls();
|
taskbar.VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
|
@ -269,7 +268,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
new Mock<IActionCenterActivator>()
|
new Mock<IActionCenterActivator>()
|
||||||
};
|
};
|
||||||
|
|
||||||
actionCenterSettings.EnableActionCenter = true;
|
context.Settings.ActionCenter.EnableActionCenter = true;
|
||||||
|
|
||||||
foreach (var activator in activatorMocks)
|
foreach (var activator in activatorMocks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,16 @@
|
||||||
* 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.Browser.Contracts;
|
||||||
|
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
using SafeExamBrowser.Configuration.Contracts;
|
||||||
using SafeExamBrowser.Settings;
|
using SafeExamBrowser.Settings;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client
|
namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds all configuration and runtime data for the client.
|
/// Holds all configuration and session data for the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class ClientContext
|
internal class ClientContext
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,21 @@ namespace SafeExamBrowser.Client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal AppConfig AppConfig { get; set; }
|
internal AppConfig AppConfig { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The browser application.
|
||||||
|
/// </summary>
|
||||||
|
internal IBrowserApplication Browser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client communication host.
|
||||||
|
/// </summary>
|
||||||
|
internal IClientHost ClientHost { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The identifier of the current session.
|
||||||
|
/// </summary>
|
||||||
|
internal Guid SessionId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The settings for the current session.
|
/// The settings for the current session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -15,7 +15,6 @@ using SafeExamBrowser.Communication.Contracts.Data;
|
||||||
using SafeExamBrowser.Communication.Contracts.Events;
|
using SafeExamBrowser.Communication.Contracts.Events;
|
||||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
|
||||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||||
|
@ -36,6 +35,7 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
private IActionCenter actionCenter;
|
private IActionCenter actionCenter;
|
||||||
private IApplicationMonitor applicationMonitor;
|
private IApplicationMonitor applicationMonitor;
|
||||||
|
private ClientContext context;
|
||||||
private IDisplayMonitor displayMonitor;
|
private IDisplayMonitor displayMonitor;
|
||||||
private IExplorerShell explorerShell;
|
private IExplorerShell explorerShell;
|
||||||
private IHashAlgorithm hashAlgorithm;
|
private IHashAlgorithm hashAlgorithm;
|
||||||
|
@ -49,29 +49,15 @@ namespace SafeExamBrowser.Client
|
||||||
private ITerminationActivator terminationActivator;
|
private ITerminationActivator terminationActivator;
|
||||||
private IText text;
|
private IText text;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
private AppConfig appConfig;
|
|
||||||
|
|
||||||
public IBrowserApplication Browser { private get; set; }
|
private IBrowserApplication Browser => context.Browser;
|
||||||
public IClientHost ClientHost { private get; set; }
|
private IClientHost ClientHost => context.ClientHost;
|
||||||
public Guid SessionId { private get; set; }
|
private AppSettings Settings => context.Settings;
|
||||||
public AppSettings Settings { private get; set; }
|
|
||||||
|
|
||||||
public AppConfig AppConfig
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
appConfig = value;
|
|
||||||
|
|
||||||
if (splashScreen != null)
|
|
||||||
{
|
|
||||||
splashScreen.AppConfig = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientController(
|
public ClientController(
|
||||||
IActionCenter actionCenter,
|
IActionCenter actionCenter,
|
||||||
IApplicationMonitor applicationMonitor,
|
IApplicationMonitor applicationMonitor,
|
||||||
|
ClientContext context,
|
||||||
IDisplayMonitor displayMonitor,
|
IDisplayMonitor displayMonitor,
|
||||||
IExplorerShell explorerShell,
|
IExplorerShell explorerShell,
|
||||||
IHashAlgorithm hashAlgorithm,
|
IHashAlgorithm hashAlgorithm,
|
||||||
|
@ -87,6 +73,7 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
this.actionCenter = actionCenter;
|
this.actionCenter = actionCenter;
|
||||||
this.applicationMonitor = applicationMonitor;
|
this.applicationMonitor = applicationMonitor;
|
||||||
|
this.context = context;
|
||||||
this.displayMonitor = displayMonitor;
|
this.displayMonitor = displayMonitor;
|
||||||
this.explorerShell = explorerShell;
|
this.explorerShell = explorerShell;
|
||||||
this.hashAlgorithm = hashAlgorithm;
|
this.hashAlgorithm = hashAlgorithm;
|
||||||
|
@ -147,7 +134,7 @@ namespace SafeExamBrowser.Client
|
||||||
logger.Log(string.Empty);
|
logger.Log(string.Empty);
|
||||||
logger.Info("Initiating shutdown procedure...");
|
logger.Info("Initiating shutdown procedure...");
|
||||||
|
|
||||||
splashScreen = uiFactory.CreateSplashScreen(appConfig);
|
splashScreen = uiFactory.CreateSplashScreen(context.AppConfig);
|
||||||
actionCenter.Close();
|
actionCenter.Close();
|
||||||
taskbar.Close();
|
taskbar.Close();
|
||||||
|
|
||||||
|
@ -169,6 +156,14 @@ namespace SafeExamBrowser.Client
|
||||||
splashScreen.Close();
|
splashScreen.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateAppConfig()
|
||||||
|
{
|
||||||
|
if (splashScreen != null)
|
||||||
|
{
|
||||||
|
splashScreen.AppConfig = context.AppConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RegisterEvents()
|
private void RegisterEvents()
|
||||||
{
|
{
|
||||||
actionCenter.QuitButtonClicked += Shell_QuitButtonClicked;
|
actionCenter.QuitButtonClicked += Shell_QuitButtonClicked;
|
||||||
|
@ -239,7 +234,7 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
args.AllowDownload = true;
|
args.AllowDownload = true;
|
||||||
args.Callback = Browser_ConfigurationDownloadFinished;
|
args.Callback = Browser_ConfigurationDownloadFinished;
|
||||||
args.DownloadPath = Path.Combine(appConfig.DownloadDirectory, fileName);
|
args.DownloadPath = Path.Combine(context.AppConfig.DownloadDirectory, fileName);
|
||||||
logger.Info($"Allowed download request for configuration file '{fileName}'.");
|
logger.Info($"Allowed download request for configuration file '{fileName}'.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -259,7 +254,7 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
logger.Info($"Sent reconfiguration request for '{filePath}' to the runtime.");
|
logger.Info($"Sent reconfiguration request for '{filePath}' to the runtime.");
|
||||||
|
|
||||||
splashScreen = uiFactory.CreateSplashScreen(appConfig);
|
splashScreen = uiFactory.CreateSplashScreen(context.AppConfig);
|
||||||
splashScreen.SetIndeterminate();
|
splashScreen.SetIndeterminate();
|
||||||
splashScreen.UpdateStatus(TextKey.OperationStatus_InitializeSession, true);
|
splashScreen.UpdateStatus(TextKey.OperationStatus_InitializeSession, true);
|
||||||
splashScreen.Show();
|
splashScreen.Show();
|
||||||
|
|
|
@ -12,17 +12,14 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using SafeExamBrowser.Browser;
|
using SafeExamBrowser.Browser;
|
||||||
using SafeExamBrowser.Browser.Contracts;
|
|
||||||
using SafeExamBrowser.Client.Communication;
|
using SafeExamBrowser.Client.Communication;
|
||||||
using SafeExamBrowser.Client.Contracts;
|
using SafeExamBrowser.Client.Contracts;
|
||||||
using SafeExamBrowser.Client.Notifications;
|
using SafeExamBrowser.Client.Notifications;
|
||||||
using SafeExamBrowser.Client.Operations;
|
using SafeExamBrowser.Client.Operations;
|
||||||
using SafeExamBrowser.Communication.Contracts;
|
using SafeExamBrowser.Communication.Contracts;
|
||||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
|
||||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||||
using SafeExamBrowser.Communication.Hosts;
|
using SafeExamBrowser.Communication.Hosts;
|
||||||
using SafeExamBrowser.Communication.Proxies;
|
using SafeExamBrowser.Communication.Proxies;
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
|
||||||
using SafeExamBrowser.Configuration.Cryptography;
|
using SafeExamBrowser.Configuration.Cryptography;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.OperationModel;
|
using SafeExamBrowser.Core.OperationModel;
|
||||||
|
@ -56,8 +53,9 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
internal class CompositionRoot
|
internal class CompositionRoot
|
||||||
{
|
{
|
||||||
|
private const int FIVE_SECONDS = 5000;
|
||||||
|
|
||||||
private Guid authenticationToken;
|
private Guid authenticationToken;
|
||||||
private ClientConfiguration configuration;
|
|
||||||
private ClientContext context;
|
private ClientContext context;
|
||||||
private string logFilePath;
|
private string logFilePath;
|
||||||
private LogLevel logLevel;
|
private LogLevel logLevel;
|
||||||
|
@ -66,8 +64,6 @@ namespace SafeExamBrowser.Client
|
||||||
|
|
||||||
private IActionCenter actionCenter;
|
private IActionCenter actionCenter;
|
||||||
private IApplicationMonitor applicationMonitor;
|
private IApplicationMonitor applicationMonitor;
|
||||||
private IBrowserApplication browser;
|
|
||||||
private IClientHost clientHost;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private IMessageBox messageBox;
|
private IMessageBox messageBox;
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
|
@ -85,7 +81,6 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
ValidateCommandLineArguments();
|
ValidateCommandLineArguments();
|
||||||
|
|
||||||
configuration = new ClientConfiguration();
|
|
||||||
logger = new Logger();
|
logger = new Logger();
|
||||||
nativeMethods = new NativeMethods();
|
nativeMethods = new NativeMethods();
|
||||||
systemInfo = new SystemInfo();
|
systemInfo = new SystemInfo();
|
||||||
|
@ -109,25 +104,25 @@ namespace SafeExamBrowser.Client
|
||||||
var operations = new Queue<IOperation>();
|
var operations = new Queue<IOperation>();
|
||||||
|
|
||||||
operations.Enqueue(new I18nOperation(logger, text, textResource));
|
operations.Enqueue(new I18nOperation(logger, text, textResource));
|
||||||
operations.Enqueue(new RuntimeConnectionOperation(logger, runtimeProxy, authenticationToken));
|
operations.Enqueue(new RuntimeConnectionOperation(context, logger, runtimeProxy, authenticationToken));
|
||||||
operations.Enqueue(new ConfigurationOperation(configuration, context, logger, runtimeProxy));
|
operations.Enqueue(new ConfigurationOperation(context, logger, runtimeProxy));
|
||||||
operations.Enqueue(new DelegateOperation(UpdateAppConfig));
|
operations.Enqueue(new DelegateOperation(UpdateAppConfig));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildClientHostOperation));
|
operations.Enqueue(new LazyInitializationOperation(BuildClientHostOperation));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildClientHostDisconnectionOperation));
|
operations.Enqueue(new ClientHostDisconnectionOperation(context, logger, FIVE_SECONDS));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildKeyboardInterceptorOperation));
|
operations.Enqueue(new LazyInitializationOperation(BuildKeyboardInterceptorOperation));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildMouseInterceptorOperation));
|
operations.Enqueue(new LazyInitializationOperation(BuildMouseInterceptorOperation));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildApplicationOperation));
|
operations.Enqueue(new ApplicationOperation(applicationMonitor, context, logger));
|
||||||
operations.Enqueue(new DisplayMonitorOperation(displayMonitor, logger, taskbar));
|
operations.Enqueue(new DisplayMonitorOperation(context, displayMonitor, logger, taskbar));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildShellOperation));
|
operations.Enqueue(new LazyInitializationOperation(BuildShellOperation));
|
||||||
operations.Enqueue(new LazyInitializationOperation(BuildBrowserOperation));
|
operations.Enqueue(new LazyInitializationOperation(BuildBrowserOperation));
|
||||||
operations.Enqueue(new ClipboardOperation(logger, nativeMethods));
|
operations.Enqueue(new ClipboardOperation(context, logger, nativeMethods));
|
||||||
operations.Enqueue(new DelegateOperation(UpdateClientControllerDependencies));
|
|
||||||
|
|
||||||
var sequence = new OperationSequence(logger, operations);
|
var sequence = new OperationSequence(logger, operations);
|
||||||
|
|
||||||
ClientController = new ClientController(
|
ClientController = new ClientController(
|
||||||
actionCenter,
|
actionCenter,
|
||||||
applicationMonitor,
|
applicationMonitor,
|
||||||
|
context,
|
||||||
displayMonitor,
|
displayMonitor,
|
||||||
explorerShell,
|
explorerShell,
|
||||||
hashAlgorithm,
|
hashAlgorithm,
|
||||||
|
@ -198,57 +193,43 @@ namespace SafeExamBrowser.Client
|
||||||
textResource = new XmlTextResource(path);
|
textResource = new XmlTextResource(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOperation BuildApplicationOperation()
|
|
||||||
{
|
|
||||||
return new ApplicationOperation(applicationMonitor, context, logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IOperation BuildBrowserOperation()
|
private IOperation BuildBrowserOperation()
|
||||||
{
|
{
|
||||||
var moduleLogger = new ModuleLogger(logger, nameof(BrowserApplication));
|
var moduleLogger = new ModuleLogger(logger, nameof(BrowserApplication));
|
||||||
var browser = new BrowserApplication(configuration.AppConfig, configuration.Settings.Browser, messageBox, moduleLogger, text, uiFactory);
|
var browser = new BrowserApplication(context.AppConfig, context.Settings.Browser, messageBox, moduleLogger, text, uiFactory);
|
||||||
var browserInfo = new BrowserApplicationInfo();
|
var browserInfo = new BrowserApplicationInfo();
|
||||||
var operation = new BrowserOperation(actionCenter, browser, logger, taskbar, uiFactory);
|
var operation = new BrowserOperation(actionCenter, context, logger, taskbar, uiFactory);
|
||||||
|
|
||||||
this.browser = browser;
|
context.Browser = browser;
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOperation BuildClientHostOperation()
|
private IOperation BuildClientHostOperation()
|
||||||
{
|
{
|
||||||
const int FIVE_SECONDS = 5000;
|
|
||||||
var processId = Process.GetCurrentProcess().Id;
|
var processId = Process.GetCurrentProcess().Id;
|
||||||
var factory = new HostObjectFactory();
|
var factory = new HostObjectFactory();
|
||||||
var host = new ClientHost(configuration.AppConfig.ClientAddress, factory, new ModuleLogger(logger, nameof(ClientHost)), processId, FIVE_SECONDS);
|
var clientHost = new ClientHost(context.AppConfig.ClientAddress, factory, new ModuleLogger(logger, nameof(ClientHost)), processId, FIVE_SECONDS);
|
||||||
var operation = new CommunicationHostOperation(host, logger);
|
var operation = new CommunicationHostOperation(clientHost, logger);
|
||||||
|
|
||||||
clientHost = host;
|
context.ClientHost = clientHost;
|
||||||
clientHost.AuthenticationToken = authenticationToken;
|
context.ClientHost.AuthenticationToken = authenticationToken;
|
||||||
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IOperation BuildClientHostDisconnectionOperation()
|
|
||||||
{
|
|
||||||
var timeout_ms = 5000;
|
|
||||||
var operation = new ClientHostDisconnectionOperation(clientHost, logger, timeout_ms);
|
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOperation BuildKeyboardInterceptorOperation()
|
private IOperation BuildKeyboardInterceptorOperation()
|
||||||
{
|
{
|
||||||
var keyboardInterceptor = new KeyboardInterceptor(configuration.Settings.Keyboard, new ModuleLogger(logger, nameof(KeyboardInterceptor)), nativeMethods);
|
var keyboardInterceptor = new KeyboardInterceptor(new ModuleLogger(logger, nameof(KeyboardInterceptor)), nativeMethods, context.Settings.Keyboard);
|
||||||
var operation = new KeyboardInterceptorOperation(keyboardInterceptor, logger);
|
var operation = new KeyboardInterceptorOperation(context, keyboardInterceptor, logger);
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOperation BuildMouseInterceptorOperation()
|
private IOperation BuildMouseInterceptorOperation()
|
||||||
{
|
{
|
||||||
var mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, nameof(MouseInterceptor)), configuration.Settings.Mouse, nativeMethods);
|
var mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, nameof(MouseInterceptor)), nativeMethods, context.Settings.Mouse);
|
||||||
var operation = new MouseInterceptorOperation(logger, mouseInterceptor);
|
var operation = new MouseInterceptorOperation(context, logger, mouseInterceptor);
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -256,8 +237,8 @@ namespace SafeExamBrowser.Client
|
||||||
private IOperation BuildShellOperation()
|
private IOperation BuildShellOperation()
|
||||||
{
|
{
|
||||||
var aboutInfo = new AboutNotificationInfo(text);
|
var aboutInfo = new AboutNotificationInfo(text);
|
||||||
var aboutController = new AboutNotificationController(configuration.AppConfig, uiFactory);
|
var aboutController = new AboutNotificationController(context.AppConfig, uiFactory);
|
||||||
var audio = new Audio(configuration.Settings.Audio, new ModuleLogger(logger, nameof(Audio)));
|
var audio = new Audio(context.Settings.Audio, new ModuleLogger(logger, nameof(Audio)));
|
||||||
var keyboard = new Keyboard(new ModuleLogger(logger, nameof(Keyboard)));
|
var keyboard = new Keyboard(new ModuleLogger(logger, nameof(Keyboard)));
|
||||||
var logInfo = new LogNotificationInfo(text);
|
var logInfo = new LogNotificationInfo(text);
|
||||||
var logController = new LogNotificationController(logger, uiFactory);
|
var logController = new LogNotificationController(logger, uiFactory);
|
||||||
|
@ -271,10 +252,10 @@ namespace SafeExamBrowser.Client
|
||||||
var operation = new ShellOperation(
|
var operation = new ShellOperation(
|
||||||
actionCenter,
|
actionCenter,
|
||||||
activators,
|
activators,
|
||||||
configuration.Settings.ActionCenter,
|
|
||||||
audio,
|
audio,
|
||||||
aboutInfo,
|
aboutInfo,
|
||||||
aboutController,
|
aboutController,
|
||||||
|
context,
|
||||||
keyboard,
|
keyboard,
|
||||||
logger,
|
logger,
|
||||||
logInfo,
|
logInfo,
|
||||||
|
@ -282,7 +263,6 @@ namespace SafeExamBrowser.Client
|
||||||
powerSupply,
|
powerSupply,
|
||||||
systemInfo,
|
systemInfo,
|
||||||
taskbar,
|
taskbar,
|
||||||
configuration.Settings.Taskbar,
|
|
||||||
terminationActivator,
|
terminationActivator,
|
||||||
text,
|
text,
|
||||||
uiFactory,
|
uiFactory,
|
||||||
|
@ -337,15 +317,7 @@ namespace SafeExamBrowser.Client
|
||||||
|
|
||||||
private void UpdateAppConfig()
|
private void UpdateAppConfig()
|
||||||
{
|
{
|
||||||
ClientController.AppConfig = configuration.AppConfig;
|
ClientController.UpdateAppConfig();
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateClientControllerDependencies()
|
|
||||||
{
|
|
||||||
ClientController.Browser = browser;
|
|
||||||
ClientController.ClientHost = clientHost;
|
|
||||||
ClientController.SessionId = configuration.SessionId;
|
|
||||||
ClientController.Settings = configuration.Settings;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* 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 SafeExamBrowser.Applications.Contracts;
|
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
|
@ -16,50 +15,48 @@ using SafeExamBrowser.UserInterface.Contracts.Shell;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class BrowserOperation : IOperation
|
internal class BrowserOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private IActionCenter actionCenter;
|
private IActionCenter actionCenter;
|
||||||
private IApplication browser;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private ITaskbar taskbar;
|
private ITaskbar taskbar;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public BrowserOperation(
|
public BrowserOperation(
|
||||||
IActionCenter actionCenter,
|
IActionCenter actionCenter,
|
||||||
IApplication browser,
|
ClientContext context,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
ITaskbar taskbar,
|
ITaskbar taskbar,
|
||||||
IUserInterfaceFactory uiFactory)
|
IUserInterfaceFactory uiFactory) : base(context)
|
||||||
{
|
{
|
||||||
this.actionCenter = actionCenter;
|
this.actionCenter = actionCenter;
|
||||||
this.browser = browser;
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.taskbar = taskbar;
|
this.taskbar = taskbar;
|
||||||
this.uiFactory = uiFactory;
|
this.uiFactory = uiFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Initializing browser...");
|
logger.Info("Initializing browser...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeBrowser);
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeBrowser);
|
||||||
|
|
||||||
browser.Initialize();
|
Context.Browser.Initialize();
|
||||||
|
|
||||||
actionCenter.AddApplicationControl(uiFactory.CreateApplicationControl(browser, Location.ActionCenter));
|
actionCenter.AddApplicationControl(uiFactory.CreateApplicationControl(Context.Browser, Location.ActionCenter));
|
||||||
taskbar.AddApplicationControl(uiFactory.CreateApplicationControl(browser, Location.Taskbar));
|
taskbar.AddApplicationControl(uiFactory.CreateApplicationControl(Context.Browser, Location.Taskbar));
|
||||||
|
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Terminating browser...");
|
logger.Info("Terminating browser...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateBrowser);
|
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateBrowser);
|
||||||
|
|
||||||
browser.Terminate();
|
Context.Browser.Terminate();
|
||||||
|
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SafeExamBrowser.Communication.Contracts.Events;
|
using SafeExamBrowser.Communication.Contracts.Events;
|
||||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
|
@ -20,43 +19,41 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
/// During application shutdown, it could happen that the client stops its communication host before the runtime had the chance to
|
/// During application shutdown, it could happen that the client stops its communication host before the runtime had the chance to
|
||||||
/// disconnect from it. This operation prevents the described race condition by waiting on the runtime to disconnect from the client.
|
/// disconnect from it. This operation prevents the described race condition by waiting on the runtime to disconnect from the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class ClientHostDisconnectionOperation : IOperation
|
internal class ClientHostDisconnectionOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private IClientHost clientHost;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private int timeout_ms;
|
private int timeout_ms;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public ClientHostDisconnectionOperation(IClientHost clientHost, ILogger logger, int timeout_ms)
|
public ClientHostDisconnectionOperation(ClientContext context, ILogger logger, int timeout_ms) : base(context)
|
||||||
{
|
{
|
||||||
this.clientHost = clientHost;
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.timeout_ms = timeout_ms;
|
this.timeout_ms = timeout_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_WaitRuntimeDisconnection);
|
StatusChanged?.Invoke(TextKey.OperationStatus_WaitRuntimeDisconnection);
|
||||||
|
|
||||||
if (clientHost.IsConnected)
|
if (Context.ClientHost.IsConnected)
|
||||||
{
|
{
|
||||||
var disconnected = false;
|
var disconnected = false;
|
||||||
var disconnectedEvent = new AutoResetEvent(false);
|
var disconnectedEvent = new AutoResetEvent(false);
|
||||||
var disconnectedEventHandler = new CommunicationEventHandler(() => disconnectedEvent.Set());
|
var disconnectedEventHandler = new CommunicationEventHandler(() => disconnectedEvent.Set());
|
||||||
|
|
||||||
clientHost.RuntimeDisconnected += disconnectedEventHandler;
|
Context.ClientHost.RuntimeDisconnected += disconnectedEventHandler;
|
||||||
|
|
||||||
logger.Info("Waiting for runtime to disconnect from client communication host...");
|
logger.Info("Waiting for runtime to disconnect from client communication host...");
|
||||||
disconnected = disconnectedEvent.WaitOne(timeout_ms);
|
disconnected = disconnectedEvent.WaitOne(timeout_ms);
|
||||||
|
|
||||||
clientHost.RuntimeDisconnected -= disconnectedEventHandler;
|
Context.ClientHost.RuntimeDisconnected -= disconnectedEventHandler;
|
||||||
|
|
||||||
if (disconnected)
|
if (disconnected)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,28 +14,28 @@ using SafeExamBrowser.WindowsApi.Contracts;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class ClipboardOperation : IOperation
|
internal class ClipboardOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public ClipboardOperation(ILogger logger, INativeMethods nativeMethods)
|
public ClipboardOperation(ClientContext context, ILogger logger, INativeMethods nativeMethods) : base(context)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.nativeMethods = nativeMethods;
|
this.nativeMethods = nativeMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
|
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
|
@ -17,17 +16,14 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class ConfigurationOperation : ClientOperation
|
internal class ConfigurationOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private ClientConfiguration configuration;
|
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private IRuntimeProxy runtime;
|
private IRuntimeProxy runtime;
|
||||||
|
|
||||||
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public override event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
// TODO: Remove and delete ClientConfiguration!
|
public ConfigurationOperation(ClientContext context, ILogger logger, IRuntimeProxy runtime) : base(context)
|
||||||
public ConfigurationOperation(ClientConfiguration configuration, ClientContext context, ILogger logger, IRuntimeProxy runtime) : base(context)
|
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
}
|
}
|
||||||
|
@ -38,19 +34,16 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeConfiguration);
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeConfiguration);
|
||||||
|
|
||||||
var communication = runtime.GetConfiguration();
|
var communication = runtime.GetConfiguration();
|
||||||
var config = communication.Value.Configuration;
|
var configuration = communication.Value.Configuration;
|
||||||
|
|
||||||
configuration.AppConfig = config.AppConfig;
|
Context.AppConfig = configuration.AppConfig;
|
||||||
configuration.SessionId = config.SessionId;
|
Context.SessionId = configuration.SessionId;
|
||||||
configuration.Settings = config.Settings;
|
Context.Settings = configuration.Settings;
|
||||||
|
|
||||||
Context.AppConfig = config.AppConfig;
|
|
||||||
Context.Settings = config.Settings;
|
|
||||||
|
|
||||||
logger.Info("Successfully retrieved the application configuration from the runtime.");
|
logger.Info("Successfully retrieved the application configuration from the runtime.");
|
||||||
logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}");
|
logger.Info($" -> Client-ID: {Context.AppConfig.ClientId}");
|
||||||
logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId}");
|
logger.Info($" -> Runtime-ID: {Context.AppConfig.RuntimeId}");
|
||||||
logger.Info($" -> Session-ID: {configuration.SessionId}");
|
logger.Info($" -> Session-ID: {Context.SessionId}");
|
||||||
|
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,23 +15,23 @@ using SafeExamBrowser.UserInterface.Contracts.Shell;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class DisplayMonitorOperation : IOperation
|
internal class DisplayMonitorOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private IDisplayMonitor displayMonitor;
|
private IDisplayMonitor displayMonitor;
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private ITaskbar taskbar;
|
private ITaskbar taskbar;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public DisplayMonitorOperation(IDisplayMonitor displayMonitor, ILogger logger, ITaskbar taskbar)
|
public DisplayMonitorOperation(ClientContext context, IDisplayMonitor displayMonitor, ILogger logger, ITaskbar taskbar) : base(context)
|
||||||
{
|
{
|
||||||
this.displayMonitor = displayMonitor;
|
this.displayMonitor = displayMonitor;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.taskbar = taskbar;
|
this.taskbar = taskbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Initializing working area...");
|
logger.Info("Initializing working area...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeWorkingArea);
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeWorkingArea);
|
||||||
|
@ -43,7 +43,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Restoring working area...");
|
logger.Info("Restoring working area...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_RestoreWorkingArea);
|
StatusChanged?.Invoke(TextKey.OperationStatus_RestoreWorkingArea);
|
||||||
|
|
|
@ -14,21 +14,21 @@ using SafeExamBrowser.Monitoring.Contracts.Keyboard;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class KeyboardInterceptorOperation : IOperation
|
internal class KeyboardInterceptorOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private IKeyboardInterceptor keyboardInterceptor;
|
private IKeyboardInterceptor keyboardInterceptor;
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public KeyboardInterceptorOperation(IKeyboardInterceptor keyboardInterceptor, ILogger logger)
|
public KeyboardInterceptorOperation(ClientContext context, IKeyboardInterceptor keyboardInterceptor, ILogger logger) : base(context)
|
||||||
{
|
{
|
||||||
this.keyboardInterceptor = keyboardInterceptor;
|
this.keyboardInterceptor = keyboardInterceptor;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Starting keyboard interception...");
|
logger.Info("Starting keyboard interception...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_StartKeyboardInterception);
|
StatusChanged?.Invoke(TextKey.OperationStatus_StartKeyboardInterception);
|
||||||
|
@ -38,7 +38,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Stopping keyboard interception...");
|
logger.Info("Stopping keyboard interception...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_StopKeyboardInterception);
|
StatusChanged?.Invoke(TextKey.OperationStatus_StopKeyboardInterception);
|
||||||
|
|
|
@ -14,21 +14,21 @@ using SafeExamBrowser.Monitoring.Contracts.Mouse;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class MouseInterceptorOperation : IOperation
|
internal class MouseInterceptorOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private IMouseInterceptor mouseInterceptor;
|
private IMouseInterceptor mouseInterceptor;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public MouseInterceptorOperation(ILogger logger, IMouseInterceptor mouseInterceptor)
|
public MouseInterceptorOperation(ClientContext context, ILogger logger, IMouseInterceptor mouseInterceptor) : base(context)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mouseInterceptor = mouseInterceptor;
|
this.mouseInterceptor = mouseInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Starting mouse interception...");
|
logger.Info("Starting mouse interception...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_StartMouseInterception);
|
StatusChanged?.Invoke(TextKey.OperationStatus_StartMouseInterception);
|
||||||
|
@ -38,7 +38,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Stopping mouse interception...");
|
logger.Info("Stopping mouse interception...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_StopMouseInterception);
|
StatusChanged?.Invoke(TextKey.OperationStatus_StopMouseInterception);
|
||||||
|
|
|
@ -15,23 +15,23 @@ using SafeExamBrowser.Logging.Contracts;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class RuntimeConnectionOperation : IOperation
|
internal class RuntimeConnectionOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private IRuntimeProxy runtime;
|
private IRuntimeProxy runtime;
|
||||||
private Guid token;
|
private Guid token;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public RuntimeConnectionOperation(ILogger logger, IRuntimeProxy runtime, Guid token)
|
public RuntimeConnectionOperation(ClientContext context, ILogger logger, IRuntimeProxy runtime, Guid token) : base(context)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Initializing runtime connection...");
|
logger.Info("Initializing runtime connection...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeRuntimeConnection);
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeRuntimeConnection);
|
||||||
|
@ -50,7 +50,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
return connected ? OperationResult.Success : OperationResult.Failed;
|
return connected ? OperationResult.Success : OperationResult.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Closing runtime connection...");
|
logger.Info("Closing runtime connection...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_CloseRuntimeConnection);
|
StatusChanged?.Invoke(TextKey.OperationStatus_CloseRuntimeConnection);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SafeExamBrowser.Client.Contracts;
|
using SafeExamBrowser.Client.Contracts;
|
||||||
using SafeExamBrowser.Settings.UserInterface;
|
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||||
using SafeExamBrowser.I18n.Contracts;
|
using SafeExamBrowser.I18n.Contracts;
|
||||||
|
@ -24,11 +23,10 @@ using SafeExamBrowser.WindowsApi.Contracts;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client.Operations
|
namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
internal class ShellOperation : IOperation
|
internal class ShellOperation : ClientOperation
|
||||||
{
|
{
|
||||||
private IActionCenter actionCenter;
|
private IActionCenter actionCenter;
|
||||||
private IEnumerable<IActionCenterActivator> activators;
|
private IEnumerable<IActionCenterActivator> activators;
|
||||||
private ActionCenterSettings actionCenterSettings;
|
|
||||||
private IAudio audio;
|
private IAudio audio;
|
||||||
private INotificationInfo aboutInfo;
|
private INotificationInfo aboutInfo;
|
||||||
private INotificationController aboutController;
|
private INotificationController aboutController;
|
||||||
|
@ -39,22 +37,21 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
private IPowerSupply powerSupply;
|
private IPowerSupply powerSupply;
|
||||||
private ISystemInfo systemInfo;
|
private ISystemInfo systemInfo;
|
||||||
private ITaskbar taskbar;
|
private ITaskbar taskbar;
|
||||||
private TaskbarSettings taskbarSettings;
|
|
||||||
private ITerminationActivator terminationActivator;
|
private ITerminationActivator terminationActivator;
|
||||||
private IText text;
|
private IText text;
|
||||||
private IUserInterfaceFactory uiFactory;
|
private IUserInterfaceFactory uiFactory;
|
||||||
private IWirelessAdapter wirelessAdapter;
|
private IWirelessAdapter wirelessAdapter;
|
||||||
|
|
||||||
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||||
public event StatusChangedEventHandler StatusChanged;
|
public override event StatusChangedEventHandler StatusChanged;
|
||||||
|
|
||||||
public ShellOperation(
|
public ShellOperation(
|
||||||
IActionCenter actionCenter,
|
IActionCenter actionCenter,
|
||||||
IEnumerable<IActionCenterActivator> activators,
|
IEnumerable<IActionCenterActivator> activators,
|
||||||
ActionCenterSettings actionCenterSettings,
|
|
||||||
IAudio audio,
|
IAudio audio,
|
||||||
INotificationInfo aboutInfo,
|
INotificationInfo aboutInfo,
|
||||||
INotificationController aboutController,
|
INotificationController aboutController,
|
||||||
|
ClientContext context,
|
||||||
IKeyboard keyboard,
|
IKeyboard keyboard,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
INotificationInfo logInfo,
|
INotificationInfo logInfo,
|
||||||
|
@ -62,17 +59,15 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
IPowerSupply powerSupply,
|
IPowerSupply powerSupply,
|
||||||
ISystemInfo systemInfo,
|
ISystemInfo systemInfo,
|
||||||
ITaskbar taskbar,
|
ITaskbar taskbar,
|
||||||
TaskbarSettings taskbarSettings,
|
|
||||||
ITerminationActivator terminationActivator,
|
ITerminationActivator terminationActivator,
|
||||||
IText text,
|
IText text,
|
||||||
IUserInterfaceFactory uiFactory,
|
IUserInterfaceFactory uiFactory,
|
||||||
IWirelessAdapter wirelessAdapter)
|
IWirelessAdapter wirelessAdapter) : base(context)
|
||||||
{
|
{
|
||||||
this.aboutInfo = aboutInfo;
|
this.aboutInfo = aboutInfo;
|
||||||
this.aboutController = aboutController;
|
this.aboutController = aboutController;
|
||||||
this.actionCenter = actionCenter;
|
this.actionCenter = actionCenter;
|
||||||
this.activators = activators;
|
this.activators = activators;
|
||||||
this.actionCenterSettings = actionCenterSettings;
|
|
||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
this.keyboard = keyboard;
|
this.keyboard = keyboard;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
@ -80,7 +75,6 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
this.logController = logController;
|
this.logController = logController;
|
||||||
this.powerSupply = powerSupply;
|
this.powerSupply = powerSupply;
|
||||||
this.systemInfo = systemInfo;
|
this.systemInfo = systemInfo;
|
||||||
this.taskbarSettings = taskbarSettings;
|
|
||||||
this.terminationActivator = terminationActivator;
|
this.terminationActivator = terminationActivator;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.taskbar = taskbar;
|
this.taskbar = taskbar;
|
||||||
|
@ -88,7 +82,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
this.wirelessAdapter = wirelessAdapter;
|
this.wirelessAdapter = wirelessAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
logger.Info("Initializing shell...");
|
logger.Info("Initializing shell...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeShell);
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeShell);
|
||||||
|
@ -101,7 +95,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Revert()
|
public override OperationResult Revert()
|
||||||
{
|
{
|
||||||
logger.Info("Terminating shell...");
|
logger.Info("Terminating shell...");
|
||||||
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateShell);
|
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateShell);
|
||||||
|
@ -117,7 +111,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
terminationActivator.Start();
|
terminationActivator.Start();
|
||||||
|
|
||||||
if (actionCenterSettings.EnableActionCenter)
|
if (Context.Settings.ActionCenter.EnableActionCenter)
|
||||||
{
|
{
|
||||||
foreach (var activator in activators)
|
foreach (var activator in activators)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +123,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeActionCenter()
|
private void InitializeActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.EnableActionCenter)
|
if (Context.Settings.ActionCenter.EnableActionCenter)
|
||||||
{
|
{
|
||||||
logger.Info("Initializing action center...");
|
logger.Info("Initializing action center...");
|
||||||
actionCenter.InitializeText(text);
|
actionCenter.InitializeText(text);
|
||||||
|
@ -150,7 +144,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeTaskbar()
|
private void InitializeTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.EnableTaskbar)
|
if (Context.Settings.Taskbar.EnableTaskbar)
|
||||||
{
|
{
|
||||||
logger.Info("Initializing taskbar...");
|
logger.Info("Initializing taskbar...");
|
||||||
taskbar.InitializeText(text);
|
taskbar.InitializeText(text);
|
||||||
|
@ -179,7 +173,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeAboutNotificationForActionCenter()
|
private void InitializeAboutNotificationForActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.ShowApplicationInfo)
|
if (Context.Settings.ActionCenter.ShowApplicationInfo)
|
||||||
{
|
{
|
||||||
actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.ActionCenter));
|
actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.ActionCenter));
|
||||||
}
|
}
|
||||||
|
@ -187,7 +181,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeAboutNotificationForTaskbar()
|
private void InitializeAboutNotificationForTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.ShowApplicationInfo)
|
if (Context.Settings.Taskbar.ShowApplicationInfo)
|
||||||
{
|
{
|
||||||
taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.Taskbar));
|
taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.Taskbar));
|
||||||
}
|
}
|
||||||
|
@ -195,7 +189,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeAudioForActionCenter()
|
private void InitializeAudioForActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.ShowAudio)
|
if (Context.Settings.ActionCenter.ShowAudio)
|
||||||
{
|
{
|
||||||
actionCenter.AddSystemControl(uiFactory.CreateAudioControl(audio, Location.ActionCenter));
|
actionCenter.AddSystemControl(uiFactory.CreateAudioControl(audio, Location.ActionCenter));
|
||||||
}
|
}
|
||||||
|
@ -203,7 +197,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeAudioForTaskbar()
|
private void InitializeAudioForTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.ShowAudio)
|
if (Context.Settings.Taskbar.ShowAudio)
|
||||||
{
|
{
|
||||||
taskbar.AddSystemControl(uiFactory.CreateAudioControl(audio, Location.Taskbar));
|
taskbar.AddSystemControl(uiFactory.CreateAudioControl(audio, Location.Taskbar));
|
||||||
}
|
}
|
||||||
|
@ -211,17 +205,17 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeClockForActionCenter()
|
private void InitializeClockForActionCenter()
|
||||||
{
|
{
|
||||||
actionCenter.ShowClock = actionCenterSettings.ShowClock;
|
actionCenter.ShowClock = Context.Settings.ActionCenter.ShowClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeClockForTaskbar()
|
private void InitializeClockForTaskbar()
|
||||||
{
|
{
|
||||||
taskbar.ShowClock = taskbarSettings.ShowClock;
|
taskbar.ShowClock = Context.Settings.Taskbar.ShowClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeLogNotificationForActionCenter()
|
private void InitializeLogNotificationForActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.ShowApplicationLog)
|
if (Context.Settings.ActionCenter.ShowApplicationLog)
|
||||||
{
|
{
|
||||||
actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.ActionCenter));
|
actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.ActionCenter));
|
||||||
}
|
}
|
||||||
|
@ -229,7 +223,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeLogNotificationForTaskbar()
|
private void InitializeLogNotificationForTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.ShowApplicationLog)
|
if (Context.Settings.Taskbar.ShowApplicationLog)
|
||||||
{
|
{
|
||||||
taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.Taskbar));
|
taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.Taskbar));
|
||||||
}
|
}
|
||||||
|
@ -237,7 +231,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeKeyboardLayoutForActionCenter()
|
private void InitializeKeyboardLayoutForActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.ShowKeyboardLayout)
|
if (Context.Settings.ActionCenter.ShowKeyboardLayout)
|
||||||
{
|
{
|
||||||
actionCenter.AddSystemControl(uiFactory.CreateKeyboardLayoutControl(keyboard, Location.ActionCenter));
|
actionCenter.AddSystemControl(uiFactory.CreateKeyboardLayoutControl(keyboard, Location.ActionCenter));
|
||||||
}
|
}
|
||||||
|
@ -245,7 +239,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeKeyboardLayoutForTaskbar()
|
private void InitializeKeyboardLayoutForTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.ShowKeyboardLayout)
|
if (Context.Settings.Taskbar.ShowKeyboardLayout)
|
||||||
{
|
{
|
||||||
taskbar.AddSystemControl(uiFactory.CreateKeyboardLayoutControl(keyboard, Location.Taskbar));
|
taskbar.AddSystemControl(uiFactory.CreateKeyboardLayoutControl(keyboard, Location.Taskbar));
|
||||||
}
|
}
|
||||||
|
@ -269,7 +263,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeWirelessNetworkForActionCenter()
|
private void InitializeWirelessNetworkForActionCenter()
|
||||||
{
|
{
|
||||||
if (actionCenterSettings.ShowWirelessNetwork)
|
if (Context.Settings.ActionCenter.ShowWirelessNetwork)
|
||||||
{
|
{
|
||||||
actionCenter.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.ActionCenter));
|
actionCenter.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.ActionCenter));
|
||||||
}
|
}
|
||||||
|
@ -277,7 +271,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
private void InitializeWirelessNetworkForTaskbar()
|
private void InitializeWirelessNetworkForTaskbar()
|
||||||
{
|
{
|
||||||
if (taskbarSettings.ShowWirelessNetwork)
|
if (Context.Settings.Taskbar.ShowWirelessNetwork)
|
||||||
{
|
{
|
||||||
taskbar.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.Taskbar));
|
taskbar.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.Taskbar));
|
||||||
}
|
}
|
||||||
|
@ -287,7 +281,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
terminationActivator.Stop();
|
terminationActivator.Stop();
|
||||||
|
|
||||||
if (actionCenterSettings.EnableActionCenter)
|
if (Context.Settings.ActionCenter.EnableActionCenter)
|
||||||
{
|
{
|
||||||
foreach (var activator in activators)
|
foreach (var activator in activators)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace SafeExamBrowser.Monitoring.Keyboard
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
private KeyboardSettings settings;
|
private KeyboardSettings settings;
|
||||||
|
|
||||||
public KeyboardInterceptor(KeyboardSettings settings, ILogger logger, INativeMethods nativeMethods)
|
public KeyboardInterceptor(ILogger logger, INativeMethods nativeMethods, KeyboardSettings settings)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.nativeMethods = nativeMethods;
|
this.nativeMethods = nativeMethods;
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace SafeExamBrowser.Monitoring.Mouse
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
private MouseSettings settings;
|
private MouseSettings settings;
|
||||||
|
|
||||||
public MouseInterceptor(ILogger logger, MouseSettings settings, INativeMethods nativeMethods)
|
public MouseInterceptor(ILogger logger, INativeMethods nativeMethods, MouseSettings settings)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.nativeMethods = nativeMethods;
|
this.nativeMethods = nativeMethods;
|
||||||
|
|
|
@ -11,23 +11,23 @@ using System;
|
||||||
namespace SafeExamBrowser.Settings.Applications
|
namespace SafeExamBrowser.Settings.Applications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TODO
|
/// Defines an application which is blacklisted, i.e. not allowed to run during a session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BlacklistApplication
|
public class BlacklistApplication
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Specifies whether the application may be automatically terminated when starting a session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoTerminate { get; set; }
|
public bool AutoTerminate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// The name of the main executable of the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ExecutableName { get; set; }
|
public string ExecutableName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// The original file name of the main executable of the application, if available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ExecutableOriginalName { get; set; }
|
public string ExecutableOriginalName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue