-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #3070 from marticliment/operations-redesign
Showing
89 changed files
with
2,568 additions
and
1,827 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.Core.Classes.Tests/UniGetUI.Core.Classes.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.Core.Language.Tests/UniGetUI.Core.LanguageEngine.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.Core.Logging.Tests/UniGetUI.Core.Logging.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.Core.Settings.Tests/UniGetUI.Core.Settings.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.PackageEngine.Enums/UniGetUI.PackageEngine.Structs.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.PackageEngine.Managers.Vcpkg/UniGetUI.PackageEngine.Managers.Vcpkg.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
356 changes: 356 additions & 0 deletions
356
src/UniGetUI.PackageEngine.Operations/AbstractOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,356 @@ | ||
using UniGetUI.Core.Logging; | ||
using UniGetUI.Core.SettingsEngine; | ||
using UniGetUI.Core.Tools; | ||
using UniGetUI.PackageEngine.Enums; | ||
|
||
namespace UniGetUI.PackageOperations; | ||
|
||
public abstract class AbstractOperation : IDisposable | ||
{ | ||
public static class RetryMode | ||
{ | ||
public const string NoRetry = ""; | ||
public const string Retry = "Retry"; | ||
public const string Retry_AsAdmin = "RetryAsAdmin"; | ||
public const string Retry_Interactive = "RetryInteractive"; | ||
public const string Retry_SkipIntegrity = "RetryNoHashCheck"; | ||
} | ||
|
||
public class OperationMetadata | ||
{ | ||
/// <summary> | ||
/// Installation of X | ||
/// </summary> | ||
public string Title = ""; | ||
|
||
/// <summary> | ||
/// X is being installed/upated/removed | ||
/// </summary> | ||
public string Status = ""; | ||
|
||
/// <summary> | ||
/// X was installed | ||
/// </summary> | ||
public string SuccessTitle = ""; | ||
|
||
/// <summary> | ||
/// X has been installed successfully | ||
/// </summary> | ||
public string SuccessMessage = ""; | ||
|
||
/// <summary> | ||
/// X could not be installed. | ||
/// </summary> | ||
public string FailureTitle = ""; | ||
|
||
/// <summary> | ||
/// X Could not be installed | ||
/// </summary> | ||
public string FailureMessage = ""; | ||
|
||
/// <summary> | ||
/// Starting operation X with options Y | ||
/// </summary> | ||
public string OperationInformation = ""; | ||
|
||
public readonly string Identifier; | ||
|
||
public OperationMetadata() | ||
{ | ||
Identifier = new Random().NextInt64(1000000, 9999999).ToString(); | ||
} | ||
} | ||
|
||
public readonly OperationMetadata Metadata = new(); | ||
public static readonly List<AbstractOperation> OperationQueue = new(); | ||
|
||
public event EventHandler<OperationStatus>? StatusChanged; | ||
public event EventHandler<EventArgs>? CancelRequested; | ||
public event EventHandler<(string, LineType)>? LogLineAdded; | ||
public event EventHandler<EventArgs>? OperationStarting; | ||
public event EventHandler<EventArgs>? OperationFinished; | ||
public event EventHandler<EventArgs>? Enqueued; | ||
public event EventHandler<EventArgs>? OperationSucceeded; | ||
public event EventHandler<EventArgs>? OperationFailed; | ||
|
||
public static int MAX_OPERATIONS; | ||
|
||
public event EventHandler<BadgeCollection>? BadgesChanged; | ||
|
||
public class BadgeCollection | ||
{ | ||
public readonly bool AsAdministrator; | ||
public readonly bool Interactive; | ||
public readonly bool SkipHashCheck; | ||
public readonly PackageScope? Scope; | ||
|
||
public BadgeCollection(bool admin, bool interactive, bool skiphash, PackageScope? scope) | ||
{ | ||
AsAdministrator = admin; | ||
Interactive = interactive; | ||
SkipHashCheck = skiphash; | ||
Scope = scope; | ||
} | ||
} | ||
public void ApplyCapabilities(bool admin, bool interactive, bool skiphash, PackageScope? scope) | ||
{ | ||
BadgesChanged?.Invoke(this, new BadgeCollection(admin, interactive, skiphash, scope)); | ||
} | ||
|
||
public enum LineType | ||
{ | ||
OperationInfo, | ||
Progress, | ||
StdOUT, | ||
StdERR | ||
} | ||
|
||
private List<(string, LineType)> LogList = new(); | ||
private OperationStatus _status = OperationStatus.InQueue; | ||
public OperationStatus Status | ||
{ | ||
get => _status; | ||
set { _status = value; StatusChanged?.Invoke(this, value); } | ||
} | ||
|
||
public bool Started { get; private set; } | ||
protected bool QUEUE_ENABLED; | ||
protected bool FORCE_HOLD_QUEUE; | ||
|
||
public AbstractOperation(bool queue_enabled) | ||
{ | ||
QUEUE_ENABLED = queue_enabled; | ||
Status = OperationStatus.InQueue; | ||
Line("Please wait...", LineType.Progress); | ||
|
||
if(int.TryParse(Settings.GetValue("ParallelOperationCount"), out int _maxPps)) | ||
{ | ||
Logger.Debug("Parallel operation limit not set, defaulting to 1"); | ||
MAX_OPERATIONS = _maxPps; | ||
} | ||
else | ||
{ | ||
MAX_OPERATIONS = 1; | ||
Logger.Debug($"Parallel operation limit set to {MAX_OPERATIONS}"); | ||
} | ||
} | ||
|
||
public void Cancel() | ||
{ | ||
switch (_status) | ||
{ | ||
case OperationStatus.Canceled: | ||
break; | ||
case OperationStatus.Failed: | ||
break; | ||
case OperationStatus.Running: | ||
Status = OperationStatus.Canceled; | ||
while(OperationQueue.Remove(this)); | ||
CancelRequested?.Invoke(this, EventArgs.Empty); | ||
Status = OperationStatus.Canceled; | ||
break; | ||
case OperationStatus.InQueue: | ||
Status = OperationStatus.Canceled; | ||
while(OperationQueue.Remove(this)); | ||
Status = OperationStatus.Canceled; | ||
break; | ||
case OperationStatus.Succeeded: | ||
break; | ||
} | ||
} | ||
|
||
protected void Line(string line, LineType type) | ||
{ | ||
if(type != LineType.Progress) LogList.Add((line, type)); | ||
LogLineAdded?.Invoke(this, (line, type)); | ||
} | ||
|
||
public IReadOnlyList<(string, LineType)> GetOutput() | ||
{ | ||
return LogList; | ||
} | ||
|
||
public async Task MainThread() | ||
{ | ||
try | ||
{ | ||
if (Metadata.Status == "") throw new InvalidDataException("Metadata.Status was not set!"); | ||
if (Metadata.Title == "") throw new InvalidDataException("Metadata.Title was not set!"); | ||
if (Metadata.OperationInformation == "") | ||
throw new InvalidDataException("Metadata.OperationInformation was not set!"); | ||
if (Metadata.SuccessTitle == "") throw new InvalidDataException("Metadata.SuccessTitle was not set!"); | ||
if (Metadata.SuccessMessage == "") throw new InvalidDataException("Metadata.SuccessMessage was not set!"); | ||
if (Metadata.FailureTitle == "") throw new InvalidDataException("Metadata.FailureTitle was not set!"); | ||
if (Metadata.FailureMessage == "") throw new InvalidDataException("Metadata.FailureMessage was not set!"); | ||
|
||
Started = true; | ||
|
||
if (OperationQueue.Contains(this)) | ||
throw new InvalidOperationException("This operation was already on the queue"); | ||
|
||
Status = OperationStatus.InQueue; | ||
Line(Metadata.OperationInformation, LineType.OperationInfo); | ||
Line(Metadata.Status, LineType.Progress); | ||
|
||
// BEGIN QUEUE HANDLER | ||
if (QUEUE_ENABLED) | ||
{ | ||
SKIP_QUEUE = false; | ||
OperationQueue.Add(this); | ||
Enqueued?.Invoke(this, EventArgs.Empty); | ||
int lastPos = -2; | ||
|
||
while (FORCE_HOLD_QUEUE || (OperationQueue.IndexOf(this) >= MAX_OPERATIONS && !SKIP_QUEUE)) | ||
{ | ||
int pos = OperationQueue.IndexOf(this) - MAX_OPERATIONS + 1; | ||
|
||
if (pos == -1) return; | ||
// In this case, operation was canceled; | ||
|
||
if (pos != lastPos) | ||
{ | ||
lastPos = pos; | ||
Line(CoreTools.Translate("Operation on queue (position {0})...", pos), LineType.Progress); | ||
} | ||
|
||
await Task.Delay(100); | ||
} | ||
} | ||
// END QUEUE HANDLER | ||
|
||
// BEGIN ACTUAL OPERATION | ||
OperationVeredict result; | ||
Line(CoreTools.Translate("Starting operation..."), LineType.Progress); | ||
if(Status is OperationStatus.InQueue) Status = OperationStatus.Running; | ||
OperationStarting?.Invoke(this, EventArgs.Empty); | ||
|
||
do | ||
{ | ||
try | ||
{ | ||
// Check if the operation was canceled | ||
if (Status is OperationStatus.Canceled) | ||
{ | ||
result = OperationVeredict.Canceled; | ||
break; | ||
} | ||
|
||
Task<OperationVeredict> op = PerformOperation(); | ||
while (Status != OperationStatus.Canceled && !op.IsCompleted) await Task.Delay(100); | ||
|
||
if (Status is OperationStatus.Canceled) result = OperationVeredict.Canceled; | ||
else result = op.GetAwaiter().GetResult(); | ||
} | ||
catch (Exception e) | ||
{ | ||
result = OperationVeredict.Failure; | ||
Logger.Error(e); | ||
foreach (string l in e.ToString().Split("\n")) Line(l, LineType.StdERR); | ||
} | ||
} while (result == OperationVeredict.AutoRetry); | ||
|
||
OperationFinished?.Invoke(this, EventArgs.Empty); | ||
|
||
while (OperationQueue.Remove(this)); | ||
// END OPERATION | ||
|
||
if (result == OperationVeredict.Success) | ||
{ | ||
Status = OperationStatus.Succeeded; | ||
OperationSucceeded?.Invoke(this, EventArgs.Empty); | ||
Line(Metadata.SuccessMessage, LineType.StdOUT); | ||
} | ||
else if (result == OperationVeredict.Failure) | ||
{ | ||
Status = OperationStatus.Failed; | ||
OperationFailed?.Invoke(this, EventArgs.Empty); | ||
Line(Metadata.FailureMessage, LineType.StdERR); | ||
Line(Metadata.FailureMessage + " - " + CoreTools.Translate("Click here for more details"), | ||
LineType.Progress); | ||
} | ||
else if (result == OperationVeredict.Canceled) | ||
{ | ||
Status = OperationStatus.Canceled; | ||
Line(CoreTools.Translate("Operation canceled by user"), LineType.StdERR); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Line("An internal error occurred:", LineType.StdERR); | ||
foreach (var line in ex.ToString().Split("\n")) | ||
Line(line, LineType.StdERR); | ||
|
||
while (OperationQueue.Remove(this)) ; | ||
|
||
Status = OperationStatus.Failed; | ||
try | ||
{ | ||
OperationFinished?.Invoke(this, EventArgs.Empty); | ||
OperationFailed?.Invoke(this, EventArgs.Empty); | ||
} | ||
catch (Exception e2) | ||
{ | ||
Line("An internal error occurred while handling an internal error:", LineType.StdERR); | ||
foreach (var line in e2.ToString().Split("\n")) | ||
Line(line, LineType.StdERR); | ||
} | ||
|
||
Line(Metadata.FailureMessage, LineType.StdERR); | ||
Line(Metadata.FailureMessage + " - " + CoreTools.Translate("Click here for more details"), | ||
LineType.Progress); | ||
} | ||
} | ||
|
||
private bool SKIP_QUEUE; | ||
|
||
public void SkipQueue() | ||
{ | ||
if (Status != OperationStatus.InQueue) return; | ||
while(OperationQueue.Remove(this)); | ||
SKIP_QUEUE = true; | ||
} | ||
|
||
public void RunNext() | ||
{ | ||
if (Status != OperationStatus.InQueue) return; | ||
if (!OperationQueue.Contains(this)) return; | ||
|
||
FORCE_HOLD_QUEUE = true; | ||
while(OperationQueue.Remove(this)); | ||
OperationQueue.Insert(Math.Min(MAX_OPERATIONS, OperationQueue.Count), this); | ||
FORCE_HOLD_QUEUE = false; | ||
} | ||
|
||
public void BackOfTheQueue() | ||
{ | ||
if (Status != OperationStatus.InQueue) return; | ||
if (!OperationQueue.Contains(this)) return; | ||
|
||
FORCE_HOLD_QUEUE = true; | ||
while(OperationQueue.Remove(this)); | ||
OperationQueue.Add(this); | ||
FORCE_HOLD_QUEUE = false; | ||
} | ||
|
||
public void Retry(string retryMode) | ||
{ | ||
if (retryMode is RetryMode.NoRetry) | ||
throw new InvalidOperationException("We weren't supposed to reach this, weren't we?"); | ||
|
||
ApplyRetryAction(retryMode); | ||
Line($"", LineType.OperationInfo); | ||
Line($"-----------------------", LineType.OperationInfo); | ||
Line($"Retrying operation with RetryMode={retryMode}", LineType.OperationInfo); | ||
Line($"", LineType.OperationInfo); | ||
if (Status is OperationStatus.Running or OperationStatus.InQueue) return; | ||
_ = MainThread(); | ||
} | ||
|
||
protected abstract void ApplyRetryAction(string retryMode); | ||
protected abstract Task<OperationVeredict> PerformOperation(); | ||
public abstract Task<Uri> GetOperationIcon(); | ||
public void Dispose() | ||
{ | ||
while(OperationQueue.Remove(this)); | ||
} | ||
} |
289 changes: 289 additions & 0 deletions
289
src/UniGetUI.PackageEngine.Operations/PackageOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,289 @@ | ||
using System.Diagnostics; | ||
using UniGetUI.Core.Classes; | ||
using UniGetUI.Core.Data; | ||
using UniGetUI.Core.Logging; | ||
using UniGetUI.Core.SettingsEngine; | ||
using UniGetUI.Core.Tools; | ||
using UniGetUI.Interface; | ||
using UniGetUI.Interface.Enums; | ||
using UniGetUI.PackageEngine.Classes.Packages.Classes; | ||
using UniGetUI.PackageEngine.Enums; | ||
using UniGetUI.PackageEngine.Interfaces; | ||
using UniGetUI.PackageEngine.PackageClasses; | ||
using UniGetUI.PackageEngine.PackageLoader; | ||
using UniGetUI.PackageOperations; | ||
|
||
namespace UniGetUI.PackageEngine.Operations | ||
{ | ||
public abstract class PackageOperation : AbstractProcessOperation | ||
{ | ||
protected List<string> DesktopShortcutsBeforeStart = []; | ||
|
||
public readonly IPackage Package; | ||
public readonly IInstallationOptions Options; | ||
public readonly OperationType Role; | ||
|
||
protected abstract Task HandleSuccess(); | ||
protected abstract Task HandleFailure(); | ||
protected abstract void Initialize(); | ||
|
||
public PackageOperation( | ||
IPackage package, | ||
IInstallationOptions options, | ||
OperationType role, | ||
bool IgnoreParallelInstalls = false) | ||
: base(!IgnoreParallelInstalls) | ||
{ | ||
Package = package; | ||
Options = options; | ||
Role = role; | ||
|
||
Initialize(); | ||
|
||
Enqueued += (_, _) => | ||
{ | ||
ApplyCapabilities(RequiresAdminRights(), | ||
Options.InteractiveInstallation, | ||
(Options.SkipHashCheck && Role is not OperationType.Uninstall), | ||
Package.OverridenOptions.Scope ?? Options.InstallationScope); | ||
|
||
Package.SetTag(PackageTag.OnQueue); | ||
}; | ||
CancelRequested += (_, _) => Package.SetTag(PackageTag.Default); | ||
OperationSucceeded += (_, _) => HandleSuccess(); | ||
OperationFailed += (_, _) => HandleFailure(); | ||
} | ||
|
||
public PackageOperation( | ||
IPackage package, | ||
OperationType role, | ||
bool IgnoreParallelInstalls = false) | ||
: this(package, InstallationOptions.FromPackage(package), role, IgnoreParallelInstalls) { } | ||
|
||
private bool RequiresAdminRights() | ||
{ | ||
return Package.OverridenOptions.RunAsAdministrator is true | ||
|| Options.RunAsAdministrator | ||
|| (Settings.Get("AlwaysElevate" + Package.Manager.Name) && !Package.OverridenOptions.RunAsAdministrator is false); | ||
} | ||
|
||
protected override void ApplyRetryAction(string retryMode) | ||
{ | ||
switch (retryMode) | ||
{ | ||
case RetryMode.Retry_AsAdmin: | ||
Options.RunAsAdministrator = true; | ||
break; | ||
case RetryMode.Retry_Interactive: | ||
Options.InteractiveInstallation = true; | ||
break; | ||
case RetryMode.Retry_SkipIntegrity: | ||
Options.SkipHashCheck = true; | ||
break; | ||
case RetryMode.Retry: | ||
break; | ||
default: | ||
throw new InvalidOperationException($"Retry mode {retryMode} is not supported in this context"); | ||
} | ||
Metadata.OperationInformation = "Retried package operation for Package=" + Package.Id + " with Manager=" + | ||
Package.Manager.Name + "\nUpdated installation options: " + Options.ToString(); | ||
|
||
} | ||
|
||
protected sealed override void PrepareProcessStartInfo() | ||
{ | ||
bool admin = false; | ||
Package.SetTag(PackageTag.OnQueue); | ||
string operation_args = string.Join(" ", Package.Manager.OperationHelper.GetParameters(Package, Options, Role)); | ||
|
||
if (RequiresAdminRights()) | ||
{ | ||
admin = true; | ||
if (Settings.Get("DoCacheAdminRights") || Settings.Get("DoCacheAdminRightsForBatches")) | ||
{ | ||
CoreTools.CacheUACForCurrentProcess().GetAwaiter().GetResult(); | ||
} | ||
|
||
process.StartInfo.FileName = CoreData.GSudoPath; | ||
process.StartInfo.Arguments = | ||
$"\"{Package.Manager.Status.ExecutablePath}\" {Package.Manager.Properties.ExecutableCallArgs} {operation_args}"; | ||
} | ||
else | ||
{ | ||
process.StartInfo.FileName = Package.Manager.Status.ExecutablePath; | ||
process.StartInfo.Arguments = $"{Package.Manager.Properties.ExecutableCallArgs} {operation_args}"; | ||
} | ||
ApplyCapabilities(admin, | ||
Options.InteractiveInstallation, | ||
(Options.SkipHashCheck && Role is not OperationType.Uninstall), | ||
Package.OverridenOptions.Scope ?? Options.InstallationScope); | ||
} | ||
|
||
protected sealed override Task<OperationVeredict> GetProcessVeredict(int ReturnCode, string[] Output) | ||
{ | ||
return Task.FromResult(Package.Manager.OperationHelper.GetResult(Package, Role, Output, ReturnCode)); | ||
} | ||
|
||
public override Task<Uri> GetOperationIcon() | ||
{ | ||
return TaskRecycler<Uri>.RunOrAttachAsync(Package.GetIconUrl); | ||
} | ||
} | ||
|
||
public class InstallPackageOperation : PackageOperation | ||
{ | ||
|
||
public InstallPackageOperation( | ||
IPackage package, | ||
IInstallationOptions options, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, options, OperationType.Install, IgnoreParallelInstalls) | ||
{ } | ||
|
||
public InstallPackageOperation( | ||
IPackage package, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, OperationType.Install, IgnoreParallelInstalls) | ||
{ } | ||
|
||
protected override Task HandleFailure() | ||
{ | ||
Package.SetTag(PackageTag.Failed); | ||
return Task.CompletedTask; | ||
} | ||
|
||
protected override Task HandleSuccess() | ||
{ | ||
Package.SetTag(PackageTag.AlreadyInstalled); | ||
InstalledPackagesLoader.Instance.AddForeign(Package); | ||
|
||
if (Settings.Get("AskToDeleteNewDesktopShortcuts")) | ||
{ | ||
DesktopShortcutsDatabase.TryRemoveNewShortcuts(DesktopShortcutsBeforeStart); | ||
} | ||
return Task.CompletedTask; | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Metadata.OperationInformation = "Package install operation for Package=" + Package.Id + " with Manager=" + | ||
Package.Manager.Name + "\nInstallation options: " + Options.ToString(); | ||
|
||
Metadata.Title = CoreTools.Translate("{package} Installation", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.Status = CoreTools.Translate("{0} is being installed", Package.Name); | ||
Metadata.SuccessTitle = CoreTools.Translate("Installation succeeded"); | ||
Metadata.SuccessMessage = CoreTools.Translate("{package} was installed successfully", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureTitle = CoreTools.Translate("Installation failed", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureMessage = CoreTools.Translate("{package} could not be installed", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
|
||
if (Settings.Get("AskToDeleteNewDesktopShortcuts")) | ||
{ | ||
DesktopShortcutsBeforeStart = DesktopShortcutsDatabase.GetShortcuts(); | ||
} | ||
} | ||
} | ||
|
||
public class UpdatePackageOperation : PackageOperation | ||
{ | ||
|
||
public UpdatePackageOperation( | ||
IPackage package, | ||
IInstallationOptions options, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, options, OperationType.Update, IgnoreParallelInstalls) | ||
{ } | ||
|
||
public UpdatePackageOperation( | ||
IPackage package, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, OperationType.Update, IgnoreParallelInstalls) | ||
{ } | ||
|
||
protected override Task HandleFailure() | ||
{ | ||
Package.SetTag(PackageTag.Failed); | ||
return Task.CompletedTask; | ||
} | ||
|
||
protected override async Task HandleSuccess() | ||
{ | ||
Package.SetTag(PackageTag.Default); | ||
Package.GetInstalledPackage()?.SetTag(PackageTag.Default); | ||
Package.GetAvailablePackage()?.SetTag(PackageTag.AlreadyInstalled); | ||
|
||
UpgradablePackagesLoader.Instance.Remove(Package); | ||
|
||
if (await Package.HasUpdatesIgnoredAsync() && await Package.GetIgnoredUpdatesVersionAsync() != "*") | ||
await Package.RemoveFromIgnoredUpdatesAsync(); | ||
|
||
if (Settings.Get("AskToDeleteNewDesktopShortcuts")) | ||
{ | ||
DesktopShortcutsDatabase.TryRemoveNewShortcuts(DesktopShortcutsBeforeStart); | ||
} | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Metadata.OperationInformation = "Package update operation for Package=" + Package.Id + " with Manager=" + | ||
Package.Manager.Name + "\nInstallation options: " + Options.ToString(); | ||
|
||
Metadata.Title = CoreTools.Translate("{package} Update", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.Status = CoreTools.Translate("{0} is being updated to version {1}", Package.Name, Package.NewVersion); | ||
Metadata.SuccessTitle = CoreTools.Translate("Update succeeded"); | ||
Metadata.SuccessMessage = CoreTools.Translate("{package} was updated successfully", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureTitle = CoreTools.Translate("Update failed", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureMessage = CoreTools.Translate("{package} could not be updated", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
|
||
if (Settings.Get("AskToDeleteNewDesktopShortcuts")) | ||
{ | ||
DesktopShortcutsBeforeStart = DesktopShortcutsDatabase.GetShortcuts(); | ||
} | ||
} | ||
} | ||
|
||
public class UninstallPackageOperation : PackageOperation | ||
{ | ||
|
||
public UninstallPackageOperation( | ||
IPackage package, | ||
IInstallationOptions options, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, options, OperationType.Uninstall, IgnoreParallelInstalls) | ||
{ } | ||
|
||
public UninstallPackageOperation( | ||
IPackage package, | ||
bool IgnoreParallelInstalls = false) | ||
: base(package, OperationType.Uninstall, IgnoreParallelInstalls) | ||
{ } | ||
|
||
protected override Task HandleFailure() | ||
{ | ||
Package.SetTag(PackageTag.Failed); | ||
return Task.CompletedTask; | ||
} | ||
|
||
protected override Task HandleSuccess() | ||
{ | ||
Package.SetTag(PackageTag.Default); | ||
Package.GetAvailablePackage()?.SetTag(PackageTag.Default); | ||
UpgradablePackagesLoader.Instance.Remove(Package); | ||
InstalledPackagesLoader.Instance.Remove(Package); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Metadata.OperationInformation = "Package uninstall operation for Package=" + Package.Id + " with Manager=" + | ||
Package.Manager.Name + "\nInstallation options: " + Options.ToString(); | ||
|
||
Metadata.Title = CoreTools.Translate("{package} Uninstall", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.Status = CoreTools.Translate("{0} is being uninstalled", Package.Name); | ||
Metadata.SuccessTitle = CoreTools.Translate("Uninstall succeeded"); | ||
Metadata.SuccessMessage = CoreTools.Translate("{package} was uninstalled successfully", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureTitle = CoreTools.Translate("Uninstall failed", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
Metadata.FailureMessage = CoreTools.Translate("{package} could not be uninstalled", new Dictionary<string, object?> { { "package", Package.Name } }); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/UniGetUI.PackageEngine.Operations/ProcessOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System.Diagnostics; | ||
using UniGetUI.PackageEngine.Enums; | ||
|
||
namespace UniGetUI.PackageOperations; | ||
|
||
public abstract class AbstractProcessOperation : AbstractOperation | ||
{ | ||
protected Process process { get; private set; } | ||
private bool ProcessKilled; | ||
protected AbstractProcessOperation(bool queue_enabled) : base(queue_enabled) | ||
{ | ||
process = new(); | ||
CancelRequested += (_, _) => | ||
{ | ||
try | ||
{ | ||
process.Kill(); | ||
ProcessKilled = true; | ||
} | ||
catch (InvalidOperationException e) | ||
{ | ||
Line("Attempted to cancel a process that hasn't ben created yet: " + e.Message, LineType.StdERR); | ||
} | ||
}; | ||
OperationStarting += (_, _) => | ||
{ | ||
ProcessKilled = false; | ||
process = new(); | ||
process.StartInfo.UseShellExecute = false; | ||
process.StartInfo.RedirectStandardOutput = true; | ||
process.StartInfo.RedirectStandardInput = true; | ||
process.StartInfo.RedirectStandardError = true; | ||
process.StartInfo.CreateNoWindow = true; | ||
process.StartInfo.FileName = "lol"; | ||
process.StartInfo.Arguments = "lol"; | ||
process.OutputDataReceived += (_, e) => | ||
{ | ||
if (e.Data is null) return; | ||
string line = e.Data.ToString().Trim(); | ||
if (line.Contains("For the question below") || | ||
line.Contains("Would remove:")) | ||
{ // Mitigate chocolatey timeouts | ||
process.StandardInput.WriteLine(""); | ||
} | ||
|
||
var lineType = LineType.StdOUT; | ||
if (line.Length < 6 || line.EndsWith("install/uninstall to complete...")) | ||
{ | ||
lineType = LineType.Progress; | ||
} | ||
|
||
Line(line, lineType); | ||
}; | ||
process.ErrorDataReceived += (_, e) => | ||
{ | ||
if (e.Data is null) return; | ||
string line = e.Data.ToString().Trim(); | ||
var lineType = LineType.StdERR; | ||
if (line.Length < 6 || line.Contains("Waiting for another install...")) | ||
{ | ||
lineType = LineType.Progress; | ||
} | ||
|
||
Line(line, lineType); | ||
}; | ||
PrepareProcessStartInfo(); | ||
}; | ||
} | ||
|
||
protected override async Task<OperationVeredict> PerformOperation() | ||
{ | ||
if(process.StartInfo.UseShellExecute) throw new InvalidOperationException("UseShellExecute must be set to false"); | ||
if(!process.StartInfo.RedirectStandardOutput) throw new InvalidOperationException("RedirectStandardOutput must be set to true"); | ||
if(!process.StartInfo.RedirectStandardInput) throw new InvalidOperationException("RedirectStandardInput must be set to true"); | ||
if(!process.StartInfo.RedirectStandardError) throw new InvalidOperationException("RedirectStandardError must be set to true"); | ||
if (process.StartInfo.FileName == "lol") throw new InvalidOperationException("StartInfo.FileName has not been set"); | ||
if (process.StartInfo.Arguments == "lol") throw new InvalidOperationException("StartInfo.Arguments has not been set"); | ||
|
||
Line($"Executing process with StartInfo:", LineType.OperationInfo); | ||
Line($" - FileName: \"{process.StartInfo.FileName.Trim()}\"", LineType.OperationInfo); | ||
Line($" - Arguments: \"{process.StartInfo.Arguments.Trim()}\"", LineType.OperationInfo); | ||
Line($"Start Time: \"{DateTime.Now}\"", LineType.OperationInfo); | ||
|
||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
await process.WaitForExitAsync(); | ||
|
||
Line($"End Time: \"{DateTime.Now}\"", LineType.OperationInfo); | ||
Line($"Process return value: \"{process.ExitCode}\" (0x{process.ExitCode:X})", LineType.OperationInfo); | ||
|
||
if (ProcessKilled) | ||
return OperationVeredict.Canceled; | ||
|
||
return await GetProcessVeredict(process.ExitCode, []); | ||
} | ||
|
||
protected abstract Task<OperationVeredict> GetProcessVeredict(int ReturnCode, string[] Output); | ||
protected abstract void PrepareProcessStartInfo(); | ||
} |
141 changes: 141 additions & 0 deletions
141
src/UniGetUI.PackageEngine.Operations/SourceOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System.Diagnostics; | ||
using Windows.Media.Capture; | ||
using UniGetUI.Core.Data; | ||
using UniGetUI.Core.Logging; | ||
using UniGetUI.Core.SettingsEngine; | ||
using UniGetUI.Core.Tools; | ||
using UniGetUI.Interface; | ||
using UniGetUI.Interface.Enums; | ||
using UniGetUI.PackageEngine.Enums; | ||
using UniGetUI.PackageEngine.Interfaces; | ||
using UniGetUI.PackageOperations; | ||
|
||
namespace UniGetUI.PackageEngine.Operations | ||
{ | ||
|
||
public abstract class SourceOperation : AbstractProcessOperation | ||
{ | ||
protected abstract void Initialize(); | ||
|
||
protected IManagerSource Source; | ||
public bool ForceAsAdministrator { get; private set; } | ||
|
||
public SourceOperation(IManagerSource source) : base(false) | ||
{ | ||
Source = source; | ||
Initialize(); | ||
} | ||
|
||
public override Task<Uri> GetOperationIcon() | ||
{ | ||
return Task.FromResult(new Uri($"ms-appx:///Assets/Images/{Source.Manager.Properties.ColorIconId}.png")); | ||
} | ||
|
||
protected override void ApplyRetryAction(string retryMode) | ||
{ | ||
switch (retryMode) | ||
{ | ||
case RetryMode.Retry: | ||
break; | ||
case RetryMode.Retry_AsAdmin: | ||
ForceAsAdministrator = true; | ||
break; | ||
default: | ||
throw new InvalidOperationException($"Retry mode {retryMode} is not supported in this context"); | ||
} | ||
} | ||
} | ||
|
||
public class AddSourceOperation : SourceOperation | ||
{ | ||
public AddSourceOperation(IManagerSource source) : base(source) | ||
{ } | ||
|
||
protected override void PrepareProcessStartInfo() | ||
{ | ||
bool admin = false; | ||
if (ForceAsAdministrator || Source.Manager.Capabilities.Sources.MustBeInstalledAsAdmin) | ||
{ | ||
if (Settings.Get("DoCacheAdminRights") || Settings.Get("DoCacheAdminRightsForBatches")) | ||
{ | ||
CoreTools.CacheUACForCurrentProcess().GetAwaiter().GetResult(); | ||
} | ||
|
||
admin = true; | ||
process.StartInfo.FileName = CoreData.GSudoPath; | ||
process.StartInfo.Arguments = $"\"{Source.Manager.Status.ExecutablePath}\" " + Source.Manager.Properties.ExecutableCallArgs + " " + string.Join(" ", Source.Manager.SourcesHelper.GetAddSourceParameters(Source)); | ||
} | ||
else | ||
{ | ||
process.StartInfo.FileName = Source.Manager.Status.ExecutablePath; | ||
process.StartInfo.Arguments = Source.Manager.Properties.ExecutableCallArgs + " " + string.Join(" ", Source.Manager.SourcesHelper.GetAddSourceParameters(Source)); | ||
} | ||
|
||
ApplyCapabilities(admin, false, false, null); | ||
} | ||
|
||
protected override Task<OperationVeredict> GetProcessVeredict(int ReturnCode, string[] Output) | ||
{ | ||
return Task.Run(() => Source.Manager.SourcesHelper.GetAddOperationVeredict(Source, ReturnCode, Output)); | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Metadata.OperationInformation = "Starting adding source operation for source=" + Source.Name + | ||
"with Manager=" + Source.Manager.Name; | ||
|
||
Metadata.Title = CoreTools.Translate("Adding source {source}", new Dictionary<string, object?> { { "source", Source.Name } }); | ||
Metadata.Status = CoreTools.Translate("Adding source {source} to {manager}", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });; | ||
Metadata.SuccessTitle = CoreTools.Translate("Source added successfully"); | ||
Metadata.SuccessMessage = CoreTools.Translate("The source {source} was added to {manager} successfully", | ||
new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } }); | ||
Metadata.FailureTitle = CoreTools.Translate("Could not add source"); | ||
Metadata.FailureMessage = CoreTools.Translate("Could not add source {source} to {manager}", | ||
new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } }); | ||
} | ||
} | ||
|
||
public class RemoveSourceOperation : SourceOperation | ||
{ | ||
public RemoveSourceOperation(IManagerSource source) : base(source) | ||
{ } | ||
|
||
protected override void PrepareProcessStartInfo() | ||
{ | ||
if (ForceAsAdministrator || Source.Manager.Capabilities.Sources.MustBeInstalledAsAdmin) | ||
{ | ||
if (Settings.Get("DoCacheAdminRights") || Settings.Get("DoCacheAdminRightsForBatches")) | ||
{ | ||
CoreTools.CacheUACForCurrentProcess().GetAwaiter().GetResult(); | ||
} | ||
process.StartInfo.FileName = CoreData.GSudoPath; | ||
process.StartInfo.Arguments = $"\"{Source.Manager.Status.ExecutablePath}\" " + Source.Manager.Properties.ExecutableCallArgs + " " + string.Join(" ", Source.Manager.SourcesHelper.GetRemoveSourceParameters(Source)); | ||
|
||
} | ||
else | ||
{ | ||
process.StartInfo.FileName = Source.Manager.Status.ExecutablePath; | ||
process.StartInfo.Arguments = Source.Manager.Properties.ExecutableCallArgs + " " + string.Join(" ", Source.Manager.SourcesHelper.GetRemoveSourceParameters(Source)); | ||
} | ||
} | ||
|
||
protected override Task<OperationVeredict> GetProcessVeredict(int ReturnCode, string[] Output) | ||
{ | ||
return Task.Run(() => Source.Manager.SourcesHelper.GetRemoveOperationVeredict(Source, ReturnCode, Output)); | ||
} | ||
|
||
protected override void Initialize() | ||
{ | ||
Metadata.OperationInformation = "Starting remove source operation for source=" + Source.Name + "with Manager=" + Source.Manager.Name; | ||
|
||
Metadata.Title = CoreTools.Translate("Removing source {source}", new Dictionary<string, object?> { { "source", Source.Name } }); | ||
Metadata.Status = CoreTools.Translate("Removing source {source} from {manager}", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });; | ||
Metadata.SuccessTitle = CoreTools.Translate("Source removed successfully"); | ||
Metadata.SuccessMessage = CoreTools.Translate("The source {source} was removed from {manager} successfully", | ||
new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } }); | ||
Metadata.FailureTitle = CoreTools.Translate("Could not remove source"); | ||
Metadata.FailureMessage = CoreTools.Translate("Could not remove source {source} from {manager}", | ||
new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } }); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/UniGetUI.PackageEngine.Operations/UniGetUI.PackageEngine.Operations.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers> | ||
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier> | ||
<Platforms>x64</Platforms> | ||
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion> | ||
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion> | ||
<SdkVersion>8.0.401</SdkVersion> | ||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> | ||
<PublishSelfContained>true</PublishSelfContained> | ||
<Authors>Martí Climent and the contributors</Authors> | ||
<PublisherName>Martí Climent</PublisherName> | ||
<Nullable>enable</Nullable> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\UniGetUI.Core.Classes\UniGetUI.Core.Classes.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.Core.Data\UniGetUI.Core.Data.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.Core.Logger\UniGetUI.Core.Logging.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.Core.Settings\UniGetUI.Core.Settings.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.Core.Tools\UniGetUI.Core.Tools.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Enums\UniGetUI.PackageEngine.Structs.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Cargo\UniGetUI.PackageEngine.Managers.Cargo.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Chocolatey\UniGetUI.PackageEngine.Managers.Chocolatey.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Dotnet\UniGetUI.PackageEngine.Managers.Dotnet.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Generic.NuGet\UniGetUI.PackageEngine.Managers.Generic.NuGet.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Npm\UniGetUI.PackageEngine.Managers.Npm.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Pip\UniGetUI.PackageEngine.Managers.Pip.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.PowerShell\UniGetUI.PackageEngine.Managers.PowerShell.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.Scoop\UniGetUI.PackageEngine.Managers.Scoop.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.Managers.WinGet\UniGetUI.PackageEngine.Managers.WinGet.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.PackageLoader\UniGetUI.PackageEngine.PackageLoaders.csproj" /> | ||
<ProjectReference Include="..\UniGetUI.PackageEngine.PackageManagerClasses\UniGetUI.PackageEngine.Classes.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\SharedAssemblyInfo.cs" Link="SharedAssemblyInfo.cs" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/UniGetUI.PackageEngine.Serializable/UniGetUI.PackageEngine.Serializable.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UniGetUI.Interface.Enums; | ||
|
||
namespace UniGetUI.Controls.OperationWidgets; | ||
public class OperationBadge | ||
{ | ||
public string Tooltip; | ||
public string PrimaryBanner; | ||
public string SecondaryBanner; | ||
public bool SecondaryBannerVisible; | ||
public IconType Icon; | ||
|
||
public OperationBadge(string tooltip, IconType icon, string primaryBanner, string? secondaryBanner = null) | ||
{ | ||
Tooltip = tooltip; | ||
Icon = icon; | ||
PrimaryBanner = primaryBanner; | ||
if(secondaryBanner is null || secondaryBanner == String.Empty) | ||
{ | ||
SecondaryBannerVisible = false; | ||
SecondaryBanner = ""; | ||
} | ||
else | ||
{ | ||
SecondaryBanner = secondaryBanner; | ||
SecondaryBannerVisible = true; | ||
} | ||
} | ||
} |
579 changes: 579 additions & 0 deletions
579
src/UniGetUI/Controls/OperationWidgets/OperationControl.cs
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
src/UniGetUI/Controls/OperationWidgets/OperationControl.xaml
This file was deleted.
Oops, something went wrong.
626 changes: 0 additions & 626 deletions
626
src/UniGetUI/Controls/OperationWidgets/OperationControl.xaml.cs
This file was deleted.
Oops, something went wrong.
463 changes: 0 additions & 463 deletions
463
src/UniGetUI/Controls/OperationWidgets/PackageOperations.cs
This file was deleted.
Oops, something went wrong.
282 changes: 0 additions & 282 deletions
282
src/UniGetUI/Controls/OperationWidgets/SourceOperations.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.