2018-02-12 12:21:55 +01:00
|
|
|
|
/*
|
2021-02-03 00:45:33 +01:00
|
|
|
|
* Copyright (c) 2021 ETH Zürich, Educational Development and Technology (LET)
|
2018-02-12 12:21:55 +01: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.Communication.Contracts.Proxies;
|
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
|
|
|
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
|
|
|
|
using SafeExamBrowser.I18n.Contracts;
|
|
|
|
|
using SafeExamBrowser.Logging.Contracts;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
2019-10-01 11:30:53 +02:00
|
|
|
|
internal class ConfigurationOperation : ClientOperation
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
|
|
|
|
private ILogger logger;
|
|
|
|
|
private IRuntimeProxy runtime;
|
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
|
|
|
public override event StatusChangedEventHandler StatusChanged;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
public ConfigurationOperation(ClientContext context, ILogger logger, IRuntimeProxy runtime) : base(context)
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.runtime = runtime;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
public override OperationResult Perform()
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
|
|
|
|
logger.Info("Initializing application configuration...");
|
2018-10-03 15:42:50 +02:00
|
|
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeConfiguration);
|
2018-02-12 12:21:55 +01:00
|
|
|
|
|
2019-02-12 14:17:56 +01:00
|
|
|
|
var communication = runtime.GetConfiguration();
|
2019-10-01 16:24:10 +02:00
|
|
|
|
var configuration = communication.Value.Configuration;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
Context.AppConfig = configuration.AppConfig;
|
|
|
|
|
Context.SessionId = configuration.SessionId;
|
|
|
|
|
Context.Settings = configuration.Settings;
|
2019-10-01 11:30:53 +02:00
|
|
|
|
|
2019-02-12 14:17:56 +01:00
|
|
|
|
logger.Info("Successfully retrieved the application configuration from the runtime.");
|
2019-10-01 16:24:10 +02:00
|
|
|
|
logger.Info($" -> Client-ID: {Context.AppConfig.ClientId}");
|
|
|
|
|
logger.Info($" -> Runtime-ID: {Context.AppConfig.RuntimeId}");
|
|
|
|
|
logger.Info($" -> Session-ID: {Context.SessionId}");
|
2018-02-28 15:49:06 +01:00
|
|
|
|
|
|
|
|
|
return OperationResult.Success;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
public override OperationResult Revert()
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
2018-10-10 09:19:03 +02:00
|
|
|
|
return OperationResult.Success;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|