2017-07-21 10:04:27 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-23 15:57:49 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Applications;
|
2018-08-31 10:06:27 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Core.OperationModel;
|
2018-10-03 14:35:27 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Core.OperationModel.Events;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2019-03-06 16:10:00 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Shell;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2018-01-18 08:16:20 +01:00
|
|
|
|
internal class BrowserOperation : IOperation
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
private IApplicationController browserController;
|
|
|
|
|
private IApplicationInfo browserInfo;
|
|
|
|
|
private ILogger logger;
|
|
|
|
|
private ITaskbar taskbar;
|
2017-07-27 14:45:54 +02:00
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2018-10-03 14:35:27 +02:00
|
|
|
|
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public event StatusChangedEventHandler StatusChanged;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-07-26 14:36:20 +02:00
|
|
|
|
public BrowserOperation(
|
2017-07-21 10:04:27 +02:00
|
|
|
|
IApplicationController browserController,
|
|
|
|
|
IApplicationInfo browserInfo,
|
|
|
|
|
ILogger logger,
|
|
|
|
|
ITaskbar taskbar,
|
2017-07-27 14:45:54 +02:00
|
|
|
|
IUserInterfaceFactory uiFactory)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
this.browserController = browserController;
|
|
|
|
|
this.browserInfo = browserInfo;
|
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.taskbar = taskbar;
|
|
|
|
|
this.uiFactory = uiFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 15:49:06 +01:00
|
|
|
|
public OperationResult Perform()
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-07-24 15:29:17 +02:00
|
|
|
|
logger.Info("Initializing browser...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeBrowser);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
|
|
|
|
var browserButton = uiFactory.CreateApplicationButton(browserInfo);
|
|
|
|
|
|
2017-07-24 17:31:28 +02:00
|
|
|
|
browserController.Initialize();
|
2017-07-21 10:04:27 +02:00
|
|
|
|
browserController.RegisterApplicationButton(browserButton);
|
2017-07-24 17:31:28 +02:00
|
|
|
|
|
2017-08-15 15:30:31 +02:00
|
|
|
|
taskbar.AddApplication(browserButton);
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 09:19:03 +02:00
|
|
|
|
public OperationResult Revert()
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2017-07-24 17:31:28 +02:00
|
|
|
|
logger.Info("Terminating browser...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateBrowser);
|
2017-07-26 14:36:20 +02:00
|
|
|
|
|
2017-07-24 17:31:28 +02:00
|
|
|
|
browserController.Terminate();
|
2018-10-10 09:19:03 +02:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|