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,15 @@
/*
* 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.Core.Contracts.Notifications.Events
{
/// <summary>
/// Indicates that a notification has changed.
/// </summary>
public delegate void NotificationChangedEventHandler();
}

View File

@@ -0,0 +1,49 @@
/*
* 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.Core.Contracts.Notifications.Events;
using SafeExamBrowser.Core.Contracts.Resources.Icons;
namespace SafeExamBrowser.Core.Contracts.Notifications
{
/// <summary>
/// Controls the lifetime and functionality of a notification which can be activated via the UI.
/// </summary>
public interface INotification
{
/// <summary>
/// Determines whether the notification can be activated.
/// </summary>
bool CanActivate { get; }
/// <summary>
/// The resource providing the notification icon.
/// </summary>
IconResource IconResource { get; }
/// <summary>
/// The tooltip for the notification.
/// </summary>
string Tooltip { get; }
/// <summary>
/// Event fired when the notification has changed.
/// </summary>
event NotificationChangedEventHandler NotificationChanged;
/// <summary>
/// Executes the notification functionality.
/// </summary>
void Activate();
/// <summary>
/// Terminates the notification functionality and release all used resources.
/// </summary>
void Terminate();
}
}

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.Core.Contracts.OperationModel.Events
{
/// <summary>
/// Base class for all event arguments used for <see cref="IOperationSequence.ActionRequired"/>.
/// </summary>
public abstract class ActionRequiredEventArgs
{
}
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Core.Contracts.OperationModel.Events
{
/// <summary>
/// Event handler used to indicate that an <see cref="IOperation"/> requires user interaction.
/// </summary>
public delegate void ActionRequiredEventHandler(ActionRequiredEventArgs args);
}

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/.
*/
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
{
/// <summary>
/// The event arguments used for <see cref="IOperationSequence.ProgressChanged"/>.
/// </summary>
public class ProgressChangedEventArgs
{
/// <summary>
/// Specifies the current progress value, if set.
/// </summary>
public int? CurrentValue { get; set; }
/// <summary>
/// Indicates that the progress value is indeterminate, if set.
/// </summary>
public bool? IsIndeterminate { get; set; }
/// <summary>
/// Sets the maximum progress value, if set.
/// </summary>
public int? MaxValue { get; set; }
/// <summary>
/// Indicates that the current progress value has increased by 1, if set.
/// </summary>
public bool? Progress { get; set; }
/// <summary>
/// Indicates that the current progress value has decreased by 1, if set.
/// </summary>
public bool? Regress { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
/*
* 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.Core.Contracts.OperationModel.Events
{
/// <summary>
/// Event handler used to indicate that the progress of an <see cref="IOperationSequence"/> has changed.
/// </summary>
public delegate void ProgressChangedEventHandler(ProgressChangedEventArgs args);
}

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/.
*/
using SafeExamBrowser.I18n.Contracts;
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
{
/// <summary>
/// Event handler used to indicate that the status of an <see cref="IOperation"/> has changed.
/// </summary>
public delegate void StatusChangedEventHandler(TextKey status);
}

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 SafeExamBrowser.Core.Contracts.OperationModel.Events;
namespace SafeExamBrowser.Core.Contracts.OperationModel
{
/// <summary>
/// Defines an operation which will be executed as part of an <see cref="IOperationSequence"/>.
/// </summary>
public interface IOperation
{
/// <summary>
/// Event fired when the operation requires user interaction.
/// </summary>
event ActionRequiredEventHandler ActionRequired;
/// <summary>
/// Event fired when the status of the operation has changed.
/// </summary>
event StatusChangedEventHandler StatusChanged;
/// <summary>
/// Performs the operation.
/// </summary>
OperationResult Perform();
/// <summary>
/// Reverts all changes made when executing the operation.
/// </summary>
OperationResult Revert();
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.Core.Contracts.OperationModel.Events;
namespace SafeExamBrowser.Core.Contracts.OperationModel
{
/// <summary>
/// A sequence of <see cref="IOperation"/> which can be used for sequential procedures, e.g. the initialization &amp; finalization of
/// an application component. Each operation will be executed failsafe, i.e. the return value will indicate whether a procedure
/// completed successfully or not.
///
/// Exemplary execution order for a sequence initialized with operations A, B, C, D:
///
/// <see cref="TryPerform"/>: A -> B -> C -> D.
/// <see cref="TryRevert"/>: D -> C -> B -> A.
/// </summary>
public interface IOperationSequence
{
/// <summary>
/// Event fired when an operation requires user interaction.
/// </summary>
event ActionRequiredEventHandler ActionRequired;
/// <summary>
/// Event fired when the progress of the sequence has changed.
/// </summary>
event ProgressChangedEventHandler ProgressChanged;
/// <summary>
/// Event fired when the status of an operation has changed.
/// </summary>
event StatusChangedEventHandler StatusChanged;
/// <summary>
/// Tries to perform the operations of this sequence according to their initialized order. If any operation fails, the already
/// performed operations will be reverted.
/// </summary>
OperationResult TryPerform();
/// <summary>
/// Tries to revert the operations of this sequence in reversion of their initialized order. The reversion of all operations will
/// continue, even if one or multiple operations fail to revert successfully.
/// </summary>
OperationResult TryRevert();
}
}

View File

@@ -0,0 +1,21 @@
/*
* 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.Core.Contracts.OperationModel
{
/// <summary>
/// Defines an operation which can be executed multiple times as part of an <see cref="IRepeatableOperationSequence"/>.
/// </summary>
public interface IRepeatableOperation : IOperation
{
/// <summary>
/// Repeats the operation.
/// </summary>
OperationResult Repeat();
}
}

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.Core.Contracts.OperationModel
{
/// <summary>
/// A sequence of <see cref="IRepeatableOperation"/> which can be used for repeatable sequential procedures.
///
/// Exemplary execution order for a sequence initialized with operations A, B, C, D:
///
/// <see cref="TryRepeat()"/>: A -> B -> C -> D.
/// </summary>
public interface IRepeatableOperationSequence : IOperationSequence
{
/// <summary>
/// Tries to repeat the operations of this sequence according to their initialized order. If any operation fails, the already
/// repeated operations will not be reverted.
/// </summary>
OperationResult TryRepeat();
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.Core.Contracts.OperationModel
{
/// <summary>
/// Defines the operation result of the execution of an <see cref="IOperation"/> resp. <see cref="IOperationSequence"/>.
/// </summary>
public enum OperationResult
{
/// <summary>
/// Indicates that the operation has been aborted due to an expected condition, e.g. as result of a user decision.
/// </summary>
Aborted = 1,
/// <summary>
/// Indicates that the operation has failed due to an invalid or unexpected condition.
/// </summary>
Failed,
/// <summary>
/// Indicates that the operation has been executed successfully.
/// </summary>
Success
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SafeExamBrowser.Core.Contracts")]
[assembly: AssemblyDescription("Safe Exam Browser")]
[assembly: AssemblyCompany("ETH Zürich")]
[assembly: AssemblyProduct("SafeExamBrowser.Core.Contracts")]
[assembly: AssemblyCopyright("Copyright © 2024 ETH Zürich, IT Services")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fe0e1224-b447-4b14-81e7-ed7d84822aa0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]

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.Core.Contracts.Resources.Icons
{
/// <summary>
/// Defines an icon resource which is a bitmap image (i.e. raster graphics).
/// </summary>
public class BitmapIconResource : IconResource
{
/// <summary>
/// The <see cref="System.Uri"/> pointing to the image file.
/// </summary>
public Uri Uri { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
/*
* 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.Core.Contracts.Resources.Icons
{
/// <summary>
/// Defines an icon resource which is a file with embedded icon data (e.g. an executable).
/// </summary>
public class EmbeddedIconResource : IconResource
{
/// <summary>
/// The full path of the file.
/// </summary>
public string FilePath { 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.Core.Contracts.Resources.Icons
{
/// <summary>
/// Defines an icon resource.
/// </summary>
public abstract class IconResource
{
}
}

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.Core.Contracts.Resources.Icons
{
/// <summary>
/// Defines an icon resource which is managed by the operating system.
/// </summary>
public class NativeIconResource : IconResource
{
/// <summary>
/// The handle of the icon.
/// </summary>
public IntPtr Handle { 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.Core.Contracts.Resources.Icons
{
/// <summary>
/// Defines an icon resource which consists of XAML markup (i.e. vector graphics).
/// </summary>
public class XamlIconResource : IconResource
{
/// <summary>
/// The <see cref="System.Uri"/> pointing to the XAML file.
/// </summary>
public Uri Uri { get; set; }
}
}

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FE0E1224-B447-4B14-81E7-ED7D84822AA0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SafeExamBrowser.Core.Contracts</RootNamespace>
<AssemblyName>SafeExamBrowser.Core.Contracts</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Notifications\Events\NotificationChangedEventHandler.cs" />
<Compile Include="Notifications\INotification.cs" />
<Compile Include="OperationModel\Events\ActionRequiredEventArgs.cs" />
<Compile Include="OperationModel\Events\ActionRequiredEventHandler.cs" />
<Compile Include="OperationModel\Events\ProgressChangedEventArgs.cs" />
<Compile Include="OperationModel\Events\ProgressChangedEventHandler.cs" />
<Compile Include="OperationModel\Events\StatusChangedEventHandler.cs" />
<Compile Include="OperationModel\IOperation.cs" />
<Compile Include="OperationModel\IOperationSequence.cs" />
<Compile Include="OperationModel\IRepeatableOperation.cs" />
<Compile Include="OperationModel\IRepeatableOperationSequence.cs" />
<Compile Include="OperationModel\OperationResult.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Icons\BitmapIconResource.cs" />
<Compile Include="Resources\Icons\EmbeddedIconResource.cs" />
<Compile Include="Resources\Icons\IconResource.cs" />
<Compile Include="Resources\Icons\NativeIconResource.cs" />
<Compile Include="Resources\Icons\XamlIconResource.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeExamBrowser.I18n.Contracts\SafeExamBrowser.I18n.Contracts.csproj">
<Project>{1858ddf3-bc2a-4bff-b663-4ce2ffeb8b7d}</Project>
<Name>SafeExamBrowser.I18n.Contracts</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>