From 6d856f73e74cc907aa1e3ce707d4afd19ae0a1b5 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 3 Jul 2021 22:06:56 -0600 Subject: [PATCH] Reused yellow stoplight to indicate and interrupted and resumable download. --- FileLiberator/DownloadDecryptBook.cs | 3 +-- FileManager/AudibleFileStorage.cs | 14 +++++++------- LibationWinForms/Form1.cs | 2 +- LibationWinForms/GridEntry.cs | 4 ++-- LibationWinForms/ProductsGrid.cs | 6 +++--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/FileLiberator/DownloadDecryptBook.cs b/FileLiberator/DownloadDecryptBook.cs index 60fcad80..9a9270d7 100644 --- a/FileLiberator/DownloadDecryptBook.cs +++ b/FileLiberator/DownloadDecryptBook.cs @@ -213,8 +213,7 @@ namespace FileLiberator } public bool Validate(LibraryBook libraryBook) - => !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId) - && !AudibleFileStorage.AAX.Exists(libraryBook.Book.AudibleProductId); + => !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId); public void Cancel() { diff --git a/FileManager/AudibleFileStorage.cs b/FileManager/AudibleFileStorage.cs index 3d1bf74f..d7db110c 100644 --- a/FileManager/AudibleFileStorage.cs +++ b/FileManager/AudibleFileStorage.cs @@ -9,7 +9,7 @@ using Dinah.Core.Collections.Generic; namespace FileManager { // could add images here, but for now images are stored in a well-known location - public enum FileType { Unknown, Audio, AAX, PDF } + public enum FileType { Unknown, Audio, AAXC, PDF } /// /// Files are large. File contents are never read by app. @@ -25,7 +25,7 @@ namespace FileManager #region static public static AudioFileStorage Audio { get; } = new AudioFileStorage(); - public static AudibleFileStorage AAX { get; } = new AaxFileStorage(); + public static AudibleFileStorage AAXC { get; } = new AaxcFileStorage(); public static AudibleFileStorage PDF { get; } = new PdfFileStorage(); public static string DownloadsInProgress @@ -77,7 +77,7 @@ namespace FileManager public FileType FileType => (FileType)Value; private IEnumerable extensions_noDots { get; } - private string extAggr { get; } + private string extAggr { get; } protected AudibleFileStorage(FileType fileType) : base((int)fileType, fileType.ToString()) { @@ -153,16 +153,16 @@ namespace FileManager } } - public class AaxFileStorage : AudibleFileStorage + public class AaxcFileStorage : AudibleFileStorage { - public override string[] Extensions { get; } = new[] { "aax" }; + public override string[] Extensions { get; } = new[] { "aaxc" }; // we always want to use the latest config value, therefore // - DO use 'get' arrow "=>" // - do NOT use assign "=" - public override string StorageDirectory => DownloadsFinal; + public override string StorageDirectory => DownloadsInProgress; - public AaxFileStorage() : base(FileType.AAX) { } + public AaxcFileStorage() : base(FileType.AAXC) { } } public class PdfFileStorage : AudibleFileStorage diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs index 3c4fa133..b6241779 100644 --- a/LibationWinForms/Form1.cs +++ b/LibationWinForms/Form1.cs @@ -117,7 +117,7 @@ namespace LibationWinForms { if (AudibleFileStorage.Audio.Exists(productId)) return AudioFileState.full; - if (AudibleFileStorage.AAX.Exists(productId)) + if (AudibleFileStorage.AAXC.Exists(productId)) return AudioFileState.aax; return AudioFileState.none; } diff --git a/LibationWinForms/GridEntry.cs b/LibationWinForms/GridEntry.cs index 39e4bce8..bac23cca 100644 --- a/LibationWinForms/GridEntry.cs +++ b/LibationWinForms/GridEntry.cs @@ -26,11 +26,11 @@ namespace LibationWinForms [Browsable(false)] public IEnumerable TagsEnumerated => book.UserDefinedItem.TagsEnumerated; - public enum LiberatedState { NotDownloaded, DRM, Liberated } + public enum LiberatedState { NotDownloaded, PartialDownload, Liberated } [Browsable(false)] public LiberatedState Liberated_Status => FileManager.AudibleFileStorage.Audio.Exists(book.AudibleProductId) ? LiberatedState.Liberated - : FileManager.AudibleFileStorage.AAX.Exists(book.AudibleProductId) ? LiberatedState.DRM + : FileManager.AudibleFileStorage.AAXC.Exists(book.AudibleProductId) ? LiberatedState.PartialDownload : LiberatedState.NotDownloaded; public enum PdfState { NoPdf, Downloaded, NotDownloaded } diff --git a/LibationWinForms/ProductsGrid.cs b/LibationWinForms/ProductsGrid.cs index 2e837432..f4cd7fc9 100644 --- a/LibationWinForms/ProductsGrid.cs +++ b/LibationWinForms/ProductsGrid.cs @@ -126,7 +126,7 @@ namespace LibationWinForms var libState = liberatedStatus switch { GridEntry.LiberatedState.Liberated => "Liberated", - GridEntry.LiberatedState.DRM => "Downloaded but needs DRM removed", + GridEntry.LiberatedState.PartialDownload => "File has been at least\r\npartially downloaded", GridEntry.LiberatedState.NotDownloaded => "Book NOT downloaded", _ => throw new Exception("Unexpected liberation state") }; @@ -142,7 +142,7 @@ namespace LibationWinForms var text = libState + pdfState; if (liberatedStatus == GridEntry.LiberatedState.NotDownloaded || - liberatedStatus == GridEntry.LiberatedState.DRM || + liberatedStatus == GridEntry.LiberatedState.PartialDownload || pdfStatus == GridEntry.PdfState.NotDownloaded) text += "\r\nClick to complete"; @@ -154,7 +154,7 @@ namespace LibationWinForms { var image_lib = liberatedStatus == GridEntry.LiberatedState.NotDownloaded ? "red" - : liberatedStatus == GridEntry.LiberatedState.DRM ? "yellow" + : liberatedStatus == GridEntry.LiberatedState.PartialDownload ? "yellow" : liberatedStatus == GridEntry.LiberatedState.Liberated ? "green" : throw new Exception("Unexpected liberation state"); var image_pdf