Restore SEBPatch

This commit is contained in:
2025-06-01 11:44:20 +02:00
commit 8c656e3137
1297 changed files with 142172 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the client configuration event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ClientConfigurationEventArgs : CommunicationEventArgs
{
/// <summary>
/// The configuration to be sent to the client.
/// </summary>
public ClientConfiguration ClientConfiguration { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// Base class which must be used for all event parameters <c>T</c> of <see cref="CommunicationEventHandler{T}"/>.
/// </summary>
public abstract class CommunicationEventArgs
{
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System.Threading.Tasks;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The default handler for communication events of an interlocutor.
/// </summary>
public delegate void CommunicationEventHandler();
/// <summary>
/// The handler with parameter for communication events of an interlocutor.
/// </summary>
public delegate void CommunicationEventHandler<T>(T args) where T : CommunicationEventArgs;
public static class CommunicationEventHandlerExtensions
{
/// <summary>
/// Executes the event handler asynchronously, i.e. on a separate thread.
/// </summary>
public static async Task InvokeAsync(this CommunicationEventHandler handler)
{
await Task.Run(() => handler?.Invoke());
}
/// <summary>
/// Executes the event handler asynchronously, i.e. on a separate thread.
/// </summary>
public static async Task InvokeAsync<T>(this CommunicationEventHandler<T> handler, T args) where T : CommunicationEventArgs
{
await Task.Run(() => handler?.Invoke(args));
}
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the exam selection event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ExamSelectionReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// Identifies the exam selection request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The identifier of the exam selected by the user.
/// </summary>
public string SelectedExamId { get; set; }
/// <summary>
/// Indicates whether an exam has been successfully selected by the user.
/// </summary>
public bool Success { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Collections.Generic;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server exam selection request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class ExamSelectionRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The exams from which the user needs to make a selection.
/// </summary>
public IEnumerable<(string id, string lms, string name, string url)> Exams { get; set; }
/// <summary>
/// Identifies the server exam selection request.
/// </summary>
public Guid RequestId { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the message box reply event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class MessageBoxReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The result of the interaction.
/// </summary>
public int Result { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the message box request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class MessageBoxRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The action to be displayed.
/// </summary>
public int Action { get; set; }
/// <summary>
/// The icon to be displayed.
/// </summary>
public int Icon { get; set; }
/// <summary>
/// The message to be displayed.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Identifies the message box request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// The title to be displayed.
/// </summary>
public string Title { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the password input event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class PasswordReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// The password entered by the user, or <c>null</c> if not available.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Identifies the password request.
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// Indicates whether the password has been successfully entered by the user.
/// </summary>
public bool Success { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using SafeExamBrowser.Communication.Contracts.Data;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the password request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class PasswordRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The purpose for which a password is requested.
/// </summary>
public PasswordRequestPurpose Purpose { get; set; }
/// <summary>
/// Identifies the password request.
/// </summary>
public Guid RequestId { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the reconfiguration event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ReconfigurationEventArgs : CommunicationEventArgs
{
/// <summary>
/// The full path to the configuration file to be used for reconfiguration.
/// </summary>
public string ConfigurationPath { get; set; }
/// <summary>
/// The original URL from where the configuration file was downloaded.
/// </summary>
public string ResourceUrl { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server failure action event fired by the <see cref="Hosts.IRuntimeHost"/>.
/// </summary>
public class ServerFailureActionReplyEventArgs : CommunicationEventArgs
{
/// <summary>
/// The user chose to abort the operation.
/// </summary>
public bool Abort { get; set; }
/// <summary>
/// The user chose to perform a fallback.
/// </summary>
public bool Fallback { get; set; }
/// <summary>
/// The user chose to retry the operation.
/// </summary>
public bool Retry { get; set; }
/// <summary>
/// Identifies the server failure action request.
/// </summary>
public Guid RequestId { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the server failure action request event fired by the <see cref="Hosts.IClientHost"/>.
/// </summary>
public class ServerFailureActionRequestEventArgs : CommunicationEventArgs
{
/// <summary>
/// The server failure message, if available.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Indicates whether the fallback option should be shown to the user.
/// </summary>
public bool ShowFallback { get; set; }
/// <summary>
/// Identifies the server failure action selection request.
/// </summary>
public Guid RequestId { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using SafeExamBrowser.Configuration.Contracts;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the session start event fired by the <see cref="Hosts.IServiceHost"/>.
/// </summary>
public class SessionStartEventArgs : CommunicationEventArgs
{
/// <summary>
/// The configuration to be used for the new session.
/// </summary>
public ServiceConfiguration Configuration { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Communication.Contracts.Events
{
/// <summary>
/// The event arguments used for the session stop event fired by the <see cref="Hosts.IServiceHost"/>.
/// </summary>
public class SessionStopEventArgs : CommunicationEventArgs
{
/// <summary>
/// The identifier of the session to be stopped.
/// </summary>
public Guid SessionId { get; set; }
}
}