mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-01 05:18:27 +01:00
Add GPL modules
This commit is contained in:
18
MediaBrowser.Model/Tasks/IConfigurableScheduledTask.cs
Normal file
18
MediaBrowser.Model/Tasks/IConfigurableScheduledTask.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
public interface IConfigurableScheduledTask
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is hidden.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
|
||||
bool IsHidden { get; }
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is enabled.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
|
||||
bool IsEnabled { get; }
|
||||
|
||||
bool IsLogged { get; }
|
||||
}
|
||||
}
|
||||
47
MediaBrowser.Model/Tasks/IScheduledTask.cs
Normal file
47
MediaBrowser.Model/Tasks/IScheduledTask.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IScheduledTaskWorker
|
||||
/// </summary>
|
||||
public interface IScheduledTask
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the task
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
string Name { get; }
|
||||
|
||||
string Key { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category.
|
||||
/// </summary>
|
||||
/// <value>The category.</value>
|
||||
string Category { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Executes the task
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task Execute(CancellationToken cancellationToken, IProgress<double> progress);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default triggers.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
||||
IEnumerable<TaskTriggerInfo> GetDefaultTriggers();
|
||||
}
|
||||
}
|
||||
76
MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs
Normal file
76
MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Events;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IScheduledTaskWorker
|
||||
/// </summary>
|
||||
public interface IScheduledTaskWorker : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [task progress].
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<double>> TaskProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scheduled task.
|
||||
/// </summary>
|
||||
/// <value>The scheduled task.</value>
|
||||
IScheduledTask ScheduledTask { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last execution result.
|
||||
/// </summary>
|
||||
/// <value>The last execution result.</value>
|
||||
TaskResult LastExecutionResult { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category.
|
||||
/// </summary>
|
||||
/// <value>The category.</value>
|
||||
string Category { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state.
|
||||
/// </summary>
|
||||
/// <value>The state.</value>
|
||||
TaskState State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current progress.
|
||||
/// </summary>
|
||||
/// <value>The current progress.</value>
|
||||
double? CurrentProgress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triggers that define when the task will run
|
||||
/// </summary>
|
||||
/// <value>The triggers.</value>
|
||||
/// <exception cref="ArgumentNullException">value</exception>
|
||||
TaskTriggerInfo[] Triggers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique id.
|
||||
/// </summary>
|
||||
/// <value>The unique id.</value>
|
||||
string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the trigger events.
|
||||
/// </summary>
|
||||
void ReloadTriggerEvents();
|
||||
}
|
||||
}
|
||||
78
MediaBrowser.Model/Tasks/ITaskManager.cs
Normal file
78
MediaBrowser.Model/Tasks/ITaskManager.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Events;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
public interface ITaskManager : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the list of Scheduled Tasks
|
||||
/// </summary>
|
||||
/// <value>The scheduled tasks.</value>
|
||||
IScheduledTaskWorker[] ScheduledTasks { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running and queue.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="options">Task options.</param>
|
||||
void CancelIfRunningAndQueue<T>(TaskOptions options)
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running and queue.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void CancelIfRunningAndQueue<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void CancelIfRunning<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="options">Task options.</param>
|
||||
void QueueScheduledTask<T>(TaskOptions options)
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void QueueScheduledTask<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
void QueueIfNotRunning<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task.
|
||||
/// </summary>
|
||||
void QueueScheduledTask(IScheduledTask task, TaskOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the tasks.
|
||||
/// </summary>
|
||||
/// <param name="tasks">The tasks.</param>
|
||||
void AddTasks(IEnumerable<IScheduledTask> tasks);
|
||||
|
||||
void Cancel(IScheduledTaskWorker task);
|
||||
Task Execute(IScheduledTaskWorker task, TaskOptions options);
|
||||
|
||||
void Execute<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
|
||||
event EventHandler<TaskCompletionEventArgs> TaskCompleted;
|
||||
|
||||
void RunTaskOnNextStartup(string key);
|
||||
}
|
||||
}
|
||||
32
MediaBrowser.Model/Tasks/ITaskTrigger.cs
Normal file
32
MediaBrowser.Model/Tasks/ITaskTrigger.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface ITaskTrigger
|
||||
/// </summary>
|
||||
public interface ITaskTrigger
|
||||
{
|
||||
/// <summary>
|
||||
/// Fires when the trigger condition is satisfied and the task should run
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Triggered;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the options of this task.
|
||||
/// </summary>
|
||||
TaskOptions TaskOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stars waiting for the trigger action
|
||||
/// </summary>
|
||||
void Start(TaskResult lastResult, ILogger logger, string taskName, bool isApplicationStartup);
|
||||
|
||||
/// <summary>
|
||||
/// Stops waiting for the trigger action
|
||||
/// </summary>
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
44
MediaBrowser.Model/Tasks/ScheduledTaskHelpers.cs
Normal file
44
MediaBrowser.Model/Tasks/ScheduledTaskHelpers.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ScheduledTaskHelpers
|
||||
/// </summary>
|
||||
public static class ScheduledTaskHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the task info.
|
||||
/// </summary>
|
||||
/// <param name="task">The task.</param>
|
||||
/// <returns>TaskInfo.</returns>
|
||||
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
|
||||
{
|
||||
var isHidden = false;
|
||||
|
||||
var configurableTask = task.ScheduledTask as IConfigurableScheduledTask;
|
||||
|
||||
if (configurableTask != null)
|
||||
{
|
||||
isHidden = configurableTask.IsHidden;
|
||||
}
|
||||
|
||||
string key = task.ScheduledTask.Key;
|
||||
|
||||
return new TaskInfo
|
||||
{
|
||||
Name = task.Name,
|
||||
CurrentProgressPercentage = task.CurrentProgress,
|
||||
State = task.State,
|
||||
Id = task.Id,
|
||||
LastExecutionResult = task.LastExecutionResult,
|
||||
|
||||
Triggers = task.Triggers,
|
||||
|
||||
Description = task.Description,
|
||||
Category = task.Category,
|
||||
IsHidden = isHidden,
|
||||
Key = key
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
14
MediaBrowser.Model/Tasks/SystemEvent.cs
Normal file
14
MediaBrowser.Model/Tasks/SystemEvent.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum SystemEvent
|
||||
/// </summary>
|
||||
public enum SystemEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The wake from sleep
|
||||
/// </summary>
|
||||
WakeFromSleep = 0
|
||||
}
|
||||
}
|
||||
11
MediaBrowser.Model/Tasks/TaskCompletionEventArgs.cs
Normal file
11
MediaBrowser.Model/Tasks/TaskCompletionEventArgs.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
public class TaskCompletionEventArgs : EventArgs
|
||||
{
|
||||
public IScheduledTaskWorker Task { get; set; }
|
||||
|
||||
public TaskResult Result { get; set; }
|
||||
}
|
||||
}
|
||||
29
MediaBrowser.Model/Tasks/TaskCompletionStatus.cs
Normal file
29
MediaBrowser.Model/Tasks/TaskCompletionStatus.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum TaskCompletionStatus
|
||||
/// </summary>
|
||||
public enum TaskCompletionStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The completed
|
||||
/// </summary>
|
||||
Completed,
|
||||
|
||||
/// <summary>
|
||||
/// The failed
|
||||
/// </summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// Manually cancelled by the user
|
||||
/// </summary>
|
||||
Cancelled,
|
||||
|
||||
/// <summary>
|
||||
/// Aborted due to a system failure or shutdown
|
||||
/// </summary>
|
||||
Aborted
|
||||
}
|
||||
}
|
||||
78
MediaBrowser.Model/Tasks/TaskInfo.cs
Normal file
78
MediaBrowser.Model/Tasks/TaskInfo.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TaskInfo
|
||||
/// </summary>
|
||||
public class TaskInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the state of the task.
|
||||
/// </summary>
|
||||
/// <value>The state of the task.</value>
|
||||
public TaskState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the progress.
|
||||
/// </summary>
|
||||
/// <value>The progress.</value>
|
||||
public double? CurrentProgressPercentage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last execution result.
|
||||
/// </summary>
|
||||
/// <value>The last execution result.</value>
|
||||
public TaskResult LastExecutionResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the triggers.
|
||||
/// </summary>
|
||||
/// <value>The triggers.</value>
|
||||
public TaskTriggerInfo[] Triggers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the category.
|
||||
/// </summary>
|
||||
/// <value>The category.</value>
|
||||
public string Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is hidden.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
|
||||
public bool IsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key.
|
||||
/// </summary>
|
||||
/// <value>The key.</value>
|
||||
public string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TaskInfo"/> class.
|
||||
/// </summary>
|
||||
public TaskInfo()
|
||||
{
|
||||
Triggers = new TaskTriggerInfo[]{};
|
||||
}
|
||||
}
|
||||
}
|
||||
8
MediaBrowser.Model/Tasks/TaskOptions.cs
Normal file
8
MediaBrowser.Model/Tasks/TaskOptions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
public class TaskOptions
|
||||
{
|
||||
public long? MaxRuntimeTicks { get; set; }
|
||||
}
|
||||
}
|
||||
58
MediaBrowser.Model/Tasks/TaskResult.cs
Normal file
58
MediaBrowser.Model/Tasks/TaskResult.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TaskExecutionInfo
|
||||
/// </summary>
|
||||
public class TaskResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the start time UTC.
|
||||
/// </summary>
|
||||
/// <value>The start time UTC.</value>
|
||||
public DateTime StartTimeUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end time UTC.
|
||||
/// </summary>
|
||||
/// <value>The end time UTC.</value>
|
||||
public DateTime EndTimeUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status.
|
||||
/// </summary>
|
||||
/// <value>The status.</value>
|
||||
public TaskCompletionStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key.
|
||||
/// </summary>
|
||||
/// <value>The key.</value>
|
||||
public string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the error message.
|
||||
/// </summary>
|
||||
/// <value>The error message.</value>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the long error message.
|
||||
/// </summary>
|
||||
/// <value>The long error message.</value>
|
||||
public string LongErrorMessage { get; set; }
|
||||
}
|
||||
}
|
||||
22
MediaBrowser.Model/Tasks/TaskState.cs
Normal file
22
MediaBrowser.Model/Tasks/TaskState.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum TaskState
|
||||
/// </summary>
|
||||
public enum TaskState
|
||||
{
|
||||
/// <summary>
|
||||
/// The idle
|
||||
/// </summary>
|
||||
Idle,
|
||||
/// <summary>
|
||||
/// The cancelling
|
||||
/// </summary>
|
||||
Cancelling,
|
||||
/// <summary>
|
||||
/// The running
|
||||
/// </summary>
|
||||
Running
|
||||
}
|
||||
}
|
||||
52
MediaBrowser.Model/Tasks/TaskTriggerInfo.cs
Normal file
52
MediaBrowser.Model/Tasks/TaskTriggerInfo.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TaskTriggerInfo
|
||||
/// </summary>
|
||||
public class TaskTriggerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
/// </summary>
|
||||
/// <value>The type.</value>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time of day.
|
||||
/// </summary>
|
||||
/// <value>The time of day.</value>
|
||||
public long? TimeOfDayTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the interval.
|
||||
/// </summary>
|
||||
/// <value>The interval.</value>
|
||||
public long? IntervalTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the system event.
|
||||
/// </summary>
|
||||
/// <value>The system event.</value>
|
||||
public SystemEvent? SystemEvent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the day of week.
|
||||
/// </summary>
|
||||
/// <value>The day of week.</value>
|
||||
public DayOfWeek? DayOfWeek { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum runtime ticks.
|
||||
/// </summary>
|
||||
/// <value>The maximum runtime ticks.</value>
|
||||
public long? MaxRuntimeTicks { get; set; }
|
||||
|
||||
public const string TriggerDaily = "DailyTrigger";
|
||||
public const string TriggerWeekly = "WeeklyTrigger";
|
||||
public const string TriggerInterval = "IntervalTrigger";
|
||||
public const string TriggerSystemEvent = "SystemEventTrigger";
|
||||
public const string TriggerStartup = "StartupTrigger";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user