diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f97d97f..9129025c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Changelog +#### Version - 3.0.0.1 - 8/19/2020 +* Fix the utterly broken build pipeline, app actually runs now +* Trigger login pages for sites if the user doesn't log in before installing + #### Version - 3.0.0.0 - 8/18/2022 * Completely new codebase * Based on WebView2, .NET 6 diff --git a/Wabbajack.App.Wpf/LoginManagers/INeedsLogin.cs b/Wabbajack.App.Wpf/LoginManagers/INeedsLogin.cs index 073b8900..aaed7797 100644 --- a/Wabbajack.App.Wpf/LoginManagers/INeedsLogin.cs +++ b/Wabbajack.App.Wpf/LoginManagers/INeedsLogin.cs @@ -1,7 +1,10 @@ +using System; +using System.Threading.Tasks; using System.Windows.Input; using System.Windows.Media; using ReactiveUI; +using Wabbajack.Downloaders.Interfaces; namespace Wabbajack.LoginManagers; @@ -11,4 +14,11 @@ public interface INeedsLogin ICommand TriggerLogin { get; set; } ICommand ClearLogin { get; set; } ImageSource Icon { get; set; } + Type LoginFor(); +} + +public interface ILoginFor : INeedsLogin +where T : IDownloader +{ + } \ No newline at end of file diff --git a/Wabbajack.App.Wpf/LoginManagers/LoversLabLoginManager.cs b/Wabbajack.App.Wpf/LoginManagers/LoversLabLoginManager.cs index f0eb60fe..1fd6e5d1 100644 --- a/Wabbajack.App.Wpf/LoginManagers/LoversLabLoginManager.cs +++ b/Wabbajack.App.Wpf/LoginManagers/LoversLabLoginManager.cs @@ -7,11 +7,13 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Wabbajack.Common; +using Wabbajack.Downloaders.IPS4OAuth2Downloader; using Wabbajack.DTOs.Interventions; using Wabbajack.DTOs.Logins; using Wabbajack.Messages; @@ -20,7 +22,7 @@ using Wabbajack.UserIntervention; namespace Wabbajack.LoginManagers; -public class LoversLabLoginManager : ViewModel, INeedsLogin +public class LoversLabLoginManager : ViewModel, ILoginFor { private readonly ILogger _logger; private readonly ITokenProvider _token; @@ -32,7 +34,11 @@ public class LoversLabLoginManager : ViewModel, INeedsLogin public ICommand ClearLogin { get; set; } public ImageSource Icon { get; set; } - + public Type LoginFor() + { + return typeof(LoversLabDownloader); + } + [Reactive] public bool HaveLogin { get; set; } diff --git a/Wabbajack.App.Wpf/LoginManagers/NexusLoginManager.cs b/Wabbajack.App.Wpf/LoginManagers/NexusLoginManager.cs index 73aa95f8..db4823d2 100644 --- a/Wabbajack.App.Wpf/LoginManagers/NexusLoginManager.cs +++ b/Wabbajack.App.Wpf/LoginManagers/NexusLoginManager.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using ReactiveUI; using ReactiveUI.Fody.Helpers; +using Wabbajack.Downloaders; using Wabbajack.DTOs.Interventions; using Wabbajack.DTOs.Logins; using Wabbajack.Messages; @@ -16,7 +17,7 @@ using Wabbajack.UserIntervention; namespace Wabbajack.LoginManagers; -public class NexusLoginManager : ViewModel, INeedsLogin +public class NexusLoginManager : ViewModel, ILoginFor { private readonly ILogger _logger; private readonly ITokenProvider _token; @@ -28,7 +29,11 @@ public class NexusLoginManager : ViewModel, INeedsLogin public ICommand ClearLogin { get; set; } public ImageSource Icon { get; set; } - + public Type LoginFor() + { + return typeof(NexusDownloader); + } + [Reactive] public bool HaveLogin { get; set; } diff --git a/Wabbajack.App.Wpf/LoginManagers/VectorPlexusLoginManager.cs b/Wabbajack.App.Wpf/LoginManagers/VectorPlexusLoginManager.cs index 15c84fa5..07e6e703 100644 --- a/Wabbajack.App.Wpf/LoginManagers/VectorPlexusLoginManager.cs +++ b/Wabbajack.App.Wpf/LoginManagers/VectorPlexusLoginManager.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Wabbajack.Common; +using Wabbajack.Downloaders.IPS4OAuth2Downloader; using Wabbajack.DTOs.Interventions; using Wabbajack.DTOs.Logins; using Wabbajack.Messages; @@ -20,7 +21,7 @@ using Wabbajack.UserIntervention; namespace Wabbajack.LoginManagers; -public class VectorPlexusLoginManager : ViewModel, INeedsLogin +public class VectorPlexusLoginManager : ViewModel, ILoginFor { private readonly ILogger _logger; private readonly ITokenProvider _token; @@ -32,7 +33,11 @@ public class VectorPlexusLoginManager : ViewModel, INeedsLogin public ICommand ClearLogin { get; set; } public ImageSource Icon { get; set; } - + public Type LoginFor() + { + return typeof(LoversLabDownloader); + } + [Reactive] public bool HaveLogin { get; set; } diff --git a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs index 58882695..1181fbe0 100644 --- a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs @@ -235,6 +235,7 @@ namespace Wabbajack { try { + await SaveSettingsFile(); var token = CancellationToken.None; State = CompilerState.Compiling; diff --git a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs index 40417966..a6aa1a7d 100644 --- a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs @@ -15,15 +15,18 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; using System.Windows.Shell; +using System.Windows.Threading; using Microsoft.Extensions.Logging; using Microsoft.WindowsAPICodePack.Dialogs; using Wabbajack.Common; +using Wabbajack.Downloaders; using Wabbajack.Downloaders.GameFile; using Wabbajack.DTOs; using Wabbajack.DTOs.DownloadStates; using Wabbajack.DTOs.JsonConverters; using Wabbajack.Hashing.xxHash64; using Wabbajack.Installer; +using Wabbajack.LoginManagers; using Wabbajack.Messages; using Wabbajack.Models; using Wabbajack.Paths; @@ -116,6 +119,8 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM private readonly ResourceMonitor _resourceMonitor; private readonly Services.OSIntegrated.Configuration _configuration; private readonly HttpClient _client; + private readonly DownloadDispatcher _downloadDispatcher; + private readonly IEnumerable _logins; public ReadOnlyObservableCollection StatusList => _resourceMonitor.Tasks; [Reactive] @@ -145,7 +150,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM public InstallerVM(ILogger logger, DTOSerializer dtos, SettingsManager settingsManager, IServiceProvider serviceProvider, SystemParametersConstructor parametersConstructor, IGameLocator gameLocator, LogStream loggerProvider, ResourceMonitor resourceMonitor, - Wabbajack.Services.OSIntegrated.Configuration configuration, HttpClient client) : base(logger) + Wabbajack.Services.OSIntegrated.Configuration configuration, HttpClient client, DownloadDispatcher dispatcher, IEnumerable logins) : base(logger) { _logger = logger; _configuration = configuration; @@ -157,6 +162,8 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM _gameLocator = gameLocator; _resourceMonitor = resourceMonitor; _client = client; + _downloadDispatcher = dispatcher; + _logins = logins; Installer = new MO2InstallerVM(this); @@ -344,6 +351,38 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM await Task.Run(async () => { InstallState = InstallState.Installing; + + foreach (var downloader in await _downloadDispatcher.AllDownloaders(ModList.Archives.Select(a => a.State))) + { + _logger.LogInformation("Preparing {Name}", downloader.GetType().Name); + if (await downloader.Prepare()) + continue; + + + var manager = _logins + .FirstOrDefault(l => l.LoginFor() == downloader.GetType()); + if (manager == null) + { + _logger.LogError("Cannot install, could not prepare {Name} for downloading", + downloader.GetType().Name); + throw new Exception($"No way to prepare {downloader}"); + } + + RxApp.MainThreadScheduler.Schedule(manager, (_, _) => + { + manager.TriggerLogin.Execute(null); + return Disposable.Empty; + }); + + while (true) + { + if (await downloader.Prepare()) + break; + await Task.Delay(1000); + } + } + + var postfix = (await ModListLocation.TargetPath.ToString().Hash()).ToHex(); await _settingsManager.Save(InstallSettingsPrefix + postfix, new SavedInstallSettings { diff --git a/Wabbajack.App.Wpf/View Models/Settings/LoginManagerVM.cs b/Wabbajack.App.Wpf/View Models/Settings/LoginManagerVM.cs index f0c6375d..f2021215 100644 --- a/Wabbajack.App.Wpf/View Models/Settings/LoginManagerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Settings/LoginManagerVM.cs @@ -1,18 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Reactive; -using System.Reactive.Linq; -using System.Threading.Tasks; -using System.Windows.Media; -using System.Windows.Media.Imaging; using Microsoft.Extensions.Logging; -using ReactiveUI; -using ReactiveUI.Fody.Helpers; -using Wabbajack; using Wabbajack.LoginManagers; namespace Wabbajack diff --git a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj index b2535871..09ab21fc 100644 --- a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj +++ b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj @@ -12,9 +12,8 @@ Copyright © 2019-2022 An automated ModList installer true - true - true + Wabbajack diff --git a/Wabbajack.DTOs/Logins/VectorPlexusLoginState.cs b/Wabbajack.DTOs/Logins/VectorPlexusLoginState.cs index f2a442f2..55e705c5 100644 --- a/Wabbajack.DTOs/Logins/VectorPlexusLoginState.cs +++ b/Wabbajack.DTOs/Logins/VectorPlexusLoginState.cs @@ -7,6 +7,6 @@ public class VectorPlexusLoginState : OAuth2LoginState public override string SiteName => "Vector Plexus"; public override string[] Scopes => new[] {"profile", "get_downloads"}; public override string ClientID => "45c6d3c9867903a7daa6ded0a38cedf8"; - public override Uri AuthorizationEndpoint => new("https://vectorplexus.com/oauth/authorize/"); - public override Uri TokenEndpoint => new("https://vectorplexus.com/oauth/token/"); + public override Uri AuthorizationEndpoint => new("https://vectorplexis.com/oauth/authorize/"); + public override Uri TokenEndpoint => new("https://vectorplexis.com/oauth/token/"); } \ No newline at end of file diff --git a/Wabbajack.Downloaders.Dispatcher/DownloadDispatcher.cs b/Wabbajack.Downloaders.Dispatcher/DownloadDispatcher.cs index 86ed9ac3..3ddc373b 100644 --- a/Wabbajack.Downloaders.Dispatcher/DownloadDispatcher.cs +++ b/Wabbajack.Downloaders.Dispatcher/DownloadDispatcher.cs @@ -292,10 +292,9 @@ public class DownloadDispatcher } } - public async Task PrepareAll(IEnumerable downloadStates) + public async Task> AllDownloaders(IEnumerable downloadStates) { - foreach (var d in downloadStates.Select(d => Downloader(new Archive {State = d})).Distinct()) - await d.Prepare(); + return downloadStates.Select(d => Downloader(new Archive {State = d})).Distinct(); } public bool Matches(Archive archive, ServerAllowList mirrorAllowList) diff --git a/Wabbajack.Downloaders.IPS4OAuth2Downloader/AIPS4OAuth2Downloader.cs b/Wabbajack.Downloaders.IPS4OAuth2Downloader/AIPS4OAuth2Downloader.cs index a2a0bb3a..f643b78f 100644 --- a/Wabbajack.Downloaders.IPS4OAuth2Downloader/AIPS4OAuth2Downloader.cs +++ b/Wabbajack.Downloaders.IPS4OAuth2Downloader/AIPS4OAuth2Downloader.cs @@ -163,9 +163,9 @@ public class AIPS4OAuth2Downloader : ADownloader Prepare() + public override async Task Prepare() { - return Task.FromResult(true); + return _loginInfo.HaveToken(); } public override bool IsAllowed(ServerAllowList allowList, IDownloadState state) diff --git a/Wabbajack.Downloaders.Nexus/NexusDownloader.cs b/Wabbajack.Downloaders.Nexus/NexusDownloader.cs index 77ef642c..faa2edb4 100644 --- a/Wabbajack.Downloaders.Nexus/NexusDownloader.cs +++ b/Wabbajack.Downloaders.Nexus/NexusDownloader.cs @@ -48,7 +48,7 @@ public class NexusDownloader : ADownloader, IUrlDownloader public override async Task Prepare() { - return true; + return _api.ApiKey.HaveToken(); } public override bool IsAllowed(ServerAllowList allowList, IDownloadState state) diff --git a/Wabbajack.Networking.NexusApi/NexusApi.cs b/Wabbajack.Networking.NexusApi/NexusApi.cs index 6daadfc7..4ca13bcc 100644 --- a/Wabbajack.Networking.NexusApi/NexusApi.cs +++ b/Wabbajack.Networking.NexusApi/NexusApi.cs @@ -29,7 +29,7 @@ public class NexusApi private readonly JsonSerializerOptions _jsonOptions; private readonly IResource _limiter; private readonly ILogger _logger; - protected readonly ITokenProvider ApiKey; + public readonly ITokenProvider ApiKey; private DateTime _lastValidated; private (ValidateInfo info, ResponseMetadata header) _lastValidatedInfo; diff --git a/buildall.bat b/buildall.bat index c06348b7..2c563a18 100644 --- a/buildall.bat +++ b/buildall.bat @@ -7,7 +7,7 @@ mkdir c:\tmp\publish-wj dotnet clean dotnet restore -dotnet publish Wabbajack.App.Wpf\Wabbajack.App.Wpf.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app --self-contained +dotnet publish Wabbajack.App.Wpf\Wabbajack.App.Wpf.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app /p:PublishedTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained dotnet publish Wabbajack.Launcher\Wabbajack.Launcher.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\launcher /p:PublishedTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained dotnet publish c:\oss\Wabbajack\Wabbajack.CLI\Wabbajack.CLI.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app --self-contained "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.sectigo.com c:\tmp\publish-wj\app\Wabbajack.exe