2020-02-11 00:30:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib.Downloaders;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib
|
2020-02-10 23:25:24 +00:00
|
|
|
|
{
|
2020-02-11 00:30:38 +00:00
|
|
|
|
public class ManuallyDownloadFile : AUserIntervention
|
2020-02-10 23:25:24 +00:00
|
|
|
|
{
|
2020-02-11 00:30:38 +00:00
|
|
|
|
public ManualDownloader.State State { get; }
|
2020-04-10 01:29:53 +00:00
|
|
|
|
public override string ShortDescription { get; } = string.Empty;
|
|
|
|
|
public override string ExtendedDescription { get; } = string.Empty;
|
|
|
|
|
|
2020-06-26 17:08:30 +00:00
|
|
|
|
private TaskCompletionSource<(Uri, Wabbajack.Lib.Http.Client)> _tcs = new TaskCompletionSource<(Uri, Wabbajack.Lib.Http.Client)>();
|
|
|
|
|
public Task<(Uri, Wabbajack.Lib.Http.Client)> Task => _tcs.Task;
|
2020-02-11 00:30:38 +00:00
|
|
|
|
|
|
|
|
|
private ManuallyDownloadFile(ManualDownloader.State state)
|
|
|
|
|
{
|
|
|
|
|
State = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async Task<ManuallyDownloadFile> Create(ManualDownloader.State state)
|
|
|
|
|
{
|
|
|
|
|
var result = new ManuallyDownloadFile(state);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public override void Cancel()
|
|
|
|
|
{
|
|
|
|
|
_tcs.SetCanceled();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 17:08:30 +00:00
|
|
|
|
public void Resume(Uri s, Wabbajack.Lib.Http.Client client)
|
2020-02-11 00:30:38 +00:00
|
|
|
|
{
|
|
|
|
|
_tcs.SetResult((s, client));
|
|
|
|
|
}
|
2020-02-10 23:25:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|