2017-08-04 12:19:56 +02:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2017-08-04 12:19:56 +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-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
|
|
|
|
using SafeExamBrowser.I18n.Contracts;
|
|
|
|
|
using SafeExamBrowser.Logging.Contracts;
|
2019-09-05 09:00:41 +02:00
|
|
|
|
using SafeExamBrowser.Monitoring.Contracts.Mouse;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
2017-08-04 12:19:56 +02:00
|
|
|
|
{
|
2019-10-01 16:24:10 +02:00
|
|
|
|
internal class MouseInterceptorOperation : ClientOperation
|
2017-08-04 12:19:56 +02:00
|
|
|
|
{
|
|
|
|
|
private ILogger logger;
|
2017-08-04 15:20:33 +02:00
|
|
|
|
private IMouseInterceptor mouseInterceptor;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public override event StatusChangedEventHandler StatusChanged;
|
2017-08-07 09:42:12 +02:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public MouseInterceptorOperation(ClientContext context, ILogger logger, IMouseInterceptor mouseInterceptor) : base(context)
|
2017-08-04 12:19:56 +02:00
|
|
|
|
{
|
|
|
|
|
this.logger = logger;
|
2017-08-04 15:20:33 +02:00
|
|
|
|
this.mouseInterceptor = mouseInterceptor;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override OperationResult Perform()
|
2017-08-04 12:19:56 +02:00
|
|
|
|
{
|
2017-08-07 09:42:12 +02:00
|
|
|
|
logger.Info("Starting mouse interception...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_StartMouseInterception);
|
2017-08-04 12:19:56 +02:00
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
mouseInterceptor.Start();
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public override OperationResult Revert()
|
2017-08-04 12:19:56 +02:00
|
|
|
|
{
|
2017-08-07 09:42:12 +02:00
|
|
|
|
logger.Info("Stopping mouse interception...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_StopMouseInterception);
|
2017-08-04 12:19:56 +02:00
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
mouseInterceptor.Stop();
|
2018-10-10 09:19:03 +02:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2017-08-04 12:19:56 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|