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; }
|
|
|
|
|
public override string ShortDescription { get; }
|
|
|
|
|
public override string ExtendedDescription { get; }
|
2020-02-10 23:25:24 +00:00
|
|
|
|
|
2020-02-14 22:23:27 +00:00
|
|
|
|
private TaskCompletionSource<(Uri, Common.Http.Client)> _tcs = new TaskCompletionSource<(Uri, Common.Http.Client)>();
|
|
|
|
|
public Task<(Uri, Common.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-02-14 22:23:27 +00:00
|
|
|
|
public void Resume(Uri s, Common.Http.Client client)
|
2020-02-11 00:30:38 +00:00
|
|
|
|
{
|
|
|
|
|
_tcs.SetResult((s, client));
|
|
|
|
|
}
|
2020-02-10 23:25:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|