From ee5e98d3dd9384a79bc2950fa119a889e393e765 Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 31 May 2021 11:12:27 -0700 Subject: [PATCH] Rename SPUUpdateState back to SPUUserUpdateState --- Sparkle.xcodeproj/project.pbxproj | 34 ++++++------- Sparkle/SPUCoreBasedUpdateDriver.h | 3 +- Sparkle/SPUStandardUserDriver.m | 4 +- Sparkle/SPUUIBasedUpdateDriver.m | 40 +++++++-------- Sparkle/SPUUpdateState+Private.h | 22 --------- Sparkle/SPUUpdateState.h | 41 ---------------- Sparkle/SPUUserDriver.h | 6 +-- Sparkle/SPUUserUpdateChoice.h | 18 ------- Sparkle/SPUUserUpdateState+Private.h | 24 +++++++++ Sparkle/SPUUserUpdateState.h | 49 +++++++++++++++++++ ...{SPUUpdateState.m => SPUUserUpdateState.m} | 12 ++--- Sparkle/SUUpdateAlert.h | 6 +-- Sparkle/SUUpdateAlert.m | 20 ++++---- Sparkle/Sparkle.h | 2 +- TestApplication/SUPopUpTitlebarUserDriver.m | 10 ++-- 15 files changed, 138 insertions(+), 153 deletions(-) delete mode 100644 Sparkle/SPUUpdateState+Private.h delete mode 100644 Sparkle/SPUUpdateState.h delete mode 100644 Sparkle/SPUUserUpdateChoice.h create mode 100644 Sparkle/SPUUserUpdateState+Private.h create mode 100644 Sparkle/SPUUserUpdateState.h rename Sparkle/{SPUUpdateState.m => SPUUserUpdateState.m} (77%) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 085caf98..ecb65e20 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -289,9 +289,9 @@ 7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; }; 7269E497264798200088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; }; 7269E4982648D3460088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; }; - 7269E49A2648F7C00088C213 /* SPUUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUpdateState.m */; }; - 7269E49B2648F7C00088C213 /* SPUUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUpdateState.m */; }; - 726DF88E1C84277600188804 /* SPUUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */; }; + 7269E49B2648F7C00088C213 /* SPUUserUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */; }; + 726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUserUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; }; 726E075C1CA3A6D6001A286B /* SPUSecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E075A1CA3A6D6001A286B /* SPUSecureCoding.h */; }; 726E075D1CA3A6D6001A286B /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; }; 726E078D1CA891E9001A286B /* SPUUpdaterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E078B1CA891E9001A286B /* SPUUpdaterSettings.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -323,8 +323,6 @@ 7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; }; 7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; }; 729924941DF4A45000DBCDF5 /* SUUpdateValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */; }; - 729E1D1B2664C2C500BF3EFB /* SPUUserUpdateChoice.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D1A2664C1F800BF3EFB /* SPUUserUpdateChoice.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 729E1D1C2664C34000BF3EFB /* SPUUserUpdateChoice.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D1A2664C1F800BF3EFB /* SPUUserUpdateChoice.h */; settings = {ATTRIBUTES = (Public, ); }; }; 729E1D1F26651CF500BF3EFB /* SPUAppcastItemState.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D1D26651CF500BF3EFB /* SPUAppcastItemState.h */; }; 729E1D2026651CF500BF3EFB /* SPUAppcastItemState.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D1D26651CF500BF3EFB /* SPUAppcastItemState.h */; }; 729E1D2126651CF500BF3EFB /* SPUAppcastItemState.m in Sources */ = {isa = PBXBuildFile; fileRef = 729E1D1E26651CF500BF3EFB /* SPUAppcastItemState.m */; }; @@ -399,7 +397,7 @@ 72A5D5F41D692CF50009E5AC /* SparkleCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72A5D59C1D6927730009E5AC /* SparkleCore.framework */; }; 72A5D5F51D692CFE0009E5AC /* SparkleCore.framework in Copy Sparkle */ = {isa = PBXBuildFile; fileRef = 72A5D59C1D6927730009E5AC /* SparkleCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 72A5D5F81D692F2B0009E5AC /* SUExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 14652F8319A9759F00959E44 /* SUExport.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 72A5D5F91D692F4C0009E5AC /* SPUUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 72A5D5F91D692F4C0009E5AC /* SPUUserUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUserUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5FB1D69312F0009E5AC /* SUBundleIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7214B8801D456A8500CB5CED /* SUBundleIcon.m */; }; 72A6F98A1C94E2D6005F404C /* SUUpdaterDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A6F9891C94E2D6005F404C /* SUUpdaterDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; }; @@ -1265,10 +1263,10 @@ 7267E5FB1D3DD1B700D1BF90 /* SPUResumableUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUResumableUpdate.h; sourceTree = ""; }; 7269E492264798200088C213 /* SPUSkippedUpdate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUSkippedUpdate.h; sourceTree = ""; }; 7269E493264798200088C213 /* SPUSkippedUpdate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUSkippedUpdate.m; sourceTree = ""; }; - 7269E4992648F7C00088C213 /* SPUUpdateState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUUpdateState.m; sourceTree = ""; }; - 7269E49C2648FC6C0088C213 /* SPUUpdateState+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SPUUpdateState+Private.h"; sourceTree = ""; }; + 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUUserUpdateState.m; sourceTree = ""; }; + 7269E49C2648FC6C0088C213 /* SPUUserUpdateState+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SPUUserUpdateState+Private.h"; sourceTree = ""; }; 726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 726DF88D1C84277500188804 /* SPUUpdateState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdateState.h; sourceTree = ""; }; + 726DF88D1C84277500188804 /* SPUUserUpdateState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUserUpdateState.h; sourceTree = ""; }; 726E075A1CA3A6D6001A286B /* SPUSecureCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPUSecureCoding.h; path = Sparkle/SPUSecureCoding.h; sourceTree = SOURCE_ROOT; }; 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPUSecureCoding.m; path = Sparkle/SPUSecureCoding.m; sourceTree = SOURCE_ROOT; }; 726E07681CA616A4001A286B /* libxar.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxar.tbd; path = usr/lib/libxar.tbd; sourceTree = SDKROOT; }; @@ -1306,7 +1304,6 @@ 729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUUpdateValidator.h; path = Sparkle/SUUpdateValidator.h; sourceTree = SOURCE_ROOT; }; 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdateValidator.m; path = Sparkle/SUUpdateValidator.m; sourceTree = SOURCE_ROOT; }; 729BB3D11D503826007C4276 /* org.sparkle-project.Downloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.Downloader.entitlements"; path = "Downloader/org.sparkle-project.Downloader.entitlements"; sourceTree = SOURCE_ROOT; }; - 729E1D1A2664C1F800BF3EFB /* SPUUserUpdateChoice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUUserUpdateChoice.h; sourceTree = ""; }; 729E1D1D26651CF500BF3EFB /* SPUAppcastItemState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUAppcastItemState.h; sourceTree = ""; }; 729E1D1E26651CF500BF3EFB /* SPUAppcastItemState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemState.m; sourceTree = ""; }; 729E1D2526652DCF00BF3EFB /* SPUAppcastItemStateResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUAppcastItemStateResolver.h; sourceTree = ""; }; @@ -2065,9 +2062,6 @@ 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */, 72A450511C69A68900D67EEA /* SUUpdatePermissionResponse.h */, 72A450521C69A68900D67EEA /* SUUpdatePermissionResponse.m */, - 726DF88D1C84277500188804 /* SPUUpdateState.h */, - 7269E49C2648FC6C0088C213 /* SPUUpdateState+Private.h */, - 7269E4992648F7C00088C213 /* SPUUpdateState.m */, ); name = "Update Control"; sourceTree = ""; @@ -2173,7 +2167,9 @@ 725CB9591C7121830064365A /* SPUStandardUserDriver.m */, 726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */, 725CB9561C7120410064365A /* SPUUserDriver.h */, - 729E1D1A2664C1F800BF3EFB /* SPUUserUpdateChoice.h */, + 726DF88D1C84277500188804 /* SPUUserUpdateState.h */, + 7269E49C2648FC6C0088C213 /* SPUUserUpdateState+Private.h */, + 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */, ); name = "User Driver"; sourceTree = ""; @@ -2422,13 +2418,12 @@ buildActionMask = 2147483647; files = ( 729E1D2826652DCF00BF3EFB /* SPUAppcastItemStateResolver.h in Headers */, - 729E1D1C2664C34000BF3EFB /* SPUUserUpdateChoice.h in Headers */, 7269E495264798200088C213 /* SPUSkippedUpdate.h in Headers */, 72A5D5DE1D692ACC0009E5AC /* SparkleCore.h in Headers */, 72B3DECE1E23479000457642 /* SPUInformationalUpdate.h in Headers */, 72A5D5EB1D692BD40009E5AC /* SPUDownloadData.h in Headers */, 721D588E25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.h in Headers */, - 72A5D5F91D692F4C0009E5AC /* SPUUpdateState.h in Headers */, + 72A5D5F91D692F4C0009E5AC /* SPUUserUpdateState.h in Headers */, 72A5D5E71D692BB00009E5AC /* SPUUpdatePermissionRequest.h in Headers */, EA1E286F22B6661D004AA304 /* SUSignatures.h in Headers */, 72A5D5E21D692B770009E5AC /* SPUUpdater.h in Headers */, @@ -2455,7 +2450,6 @@ 72B767D61C9C8B5C00A07552 /* SPUBasicUpdateDriver.h in Headers */, 72B767E21C9CE90A00A07552 /* SPUCoreBasedUpdateDriver.h in Headers */, 72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */, - 729E1D1B2664C2C500BF3EFB /* SPUUserUpdateChoice.h in Headers */, 7229E1BD1C98EFF200CB50D0 /* SPUDownloadDriver.h in Headers */, 7267E5FD1D3DD1B700D1BF90 /* SPUResumableUpdate.h in Headers */, 7267E5B61D3D8AEE00D1BF90 /* SPUInstallationInfo.h in Headers */, @@ -2472,7 +2466,7 @@ 7246E0A31C83B685003B4E75 /* SPUStandardUpdaterController.h in Headers */, 725CB95A1C7121830064365A /* SPUStandardUserDriver.h in Headers */, 726E4A371C89116000C57C6A /* SPUStandardUserDriverDelegate.h in Headers */, - 726DF88E1C84277600188804 /* SPUUpdateState.h in Headers */, + 726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */, 72B767DA1C9CD2E400A07552 /* SPUUIBasedUpdateDriver.h in Headers */, 7229E1B61C97C91100CB50D0 /* SPUUpdateDriver.h in Headers */, 72DBA37D1D60CC34002594A8 /* SPUUpdatePermissionRequest.h in Headers */, @@ -3599,7 +3593,7 @@ 72A5D5B01D6929F80009E5AC /* SUInstallerConnection.m in Sources */, 72A5D5AE1D6929F80009E5AC /* SUInstallerLauncher.m in Sources */, 72B3DED01E23479000457642 /* SPUInformationalUpdate.m in Sources */, - 7269E49B2648F7C00088C213 /* SPUUpdateState.m in Sources */, + 7269E49B2648F7C00088C213 /* SPUUserUpdateState.m in Sources */, 72A5D5B21D6929F80009E5AC /* SUInstallerStatus.m in Sources */, 72A5D5C51D6929F80009E5AC /* SULog.m in Sources */, 72A5D5C61D6929F80009E5AC /* SUOperatingSystem.m in Sources */, @@ -3705,7 +3699,7 @@ 72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */, 61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */, 7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */, - 7269E49A2648F7C00088C213 /* SPUUpdateState.m in Sources */, + 7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */, 725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */, 7214B8821D456A8500CB5CED /* SUBundleIcon.m in Sources */, 72DBA37F1D62C23E002594A8 /* SUCodeSigningVerifier.m in Sources */, diff --git a/Sparkle/SPUCoreBasedUpdateDriver.h b/Sparkle/SPUCoreBasedUpdateDriver.h index b52e4c95..833ff946 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.h +++ b/Sparkle/SPUCoreBasedUpdateDriver.h @@ -7,9 +7,8 @@ // #import -#import "SPUUpdateState.h" #import "SPUUpdateDriver.h" -#import "SPUUserUpdateChoice.h" +#import "SPUUserUpdateState.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index d0faf60d..78198e98 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -17,7 +17,7 @@ #import "SULocalizations.h" #import "SUApplicationInfo.h" #import "SUOperatingSystem.h" -#import "SPUUpdateState.h" +#import "SPUUserUpdateState.h" @interface SPUStandardUserDriver () @@ -116,7 +116,7 @@ #pragma mark Update Found -- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply +- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply { assert(NSThread.isMainThread); diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 4dd0bcfc..ed8f958c 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -18,7 +18,7 @@ #import "SPUResumableUpdate.h" #import "SPUDownloadDriver.h" #import "SPUSkippedUpdate.h" -#import "SPUUpdateState+Private.h" +#import "SPUUserUpdateState+Private.h" #include "AppKitPrevention.h" @@ -169,25 +169,25 @@ id updaterDelegate = self.updaterDelegate; - SPUUpdateStage stage; + SPUUserUpdateStage stage; if (updateItem.isInformationOnlyUpdate) { - stage = SPUUpdateStageInformational; + stage = SPUUserUpdateStageInformational; } else if (self.resumingDownloadedUpdate) { - stage = SPUUpdateStageDownloaded; + stage = SPUUserUpdateStageDownloaded; } else if (self.resumingInstallingUpdate) { - stage = SPUUpdateStageInstalling; + stage = SPUUserUpdateStageInstalling; } else { - stage = SPUUpdateStageNotDownloaded; + stage = SPUUserUpdateStageNotDownloaded; } - SPUUpdateState *state = [[SPUUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated]; + SPUUserUpdateState *state = [[SPUUserUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated]; [self.userDriver showUpdateFoundWithAppcastItem:updateItem state:state reply:^(SPUUserUpdateChoice userChoice) { dispatch_async(dispatch_get_main_queue(), ^{ // Rule out invalid choices SPUUserUpdateChoice validatedChoice; - if (stage == SPUUpdateStageInformational && userChoice == SPUUserUpdateChoiceInstall) { + if (stage == SPUUserUpdateStageInformational && userChoice == SPUUserUpdateChoiceInstall) { validatedChoice = SPUUserUpdateChoiceDismiss; } else { validatedChoice = userChoice; @@ -196,16 +196,16 @@ switch (validatedChoice) { case SPUUserUpdateChoiceInstall: { switch (stage) { - case SPUUpdateStageDownloaded: + case SPUUserUpdateStageDownloaded: [self.coreDriver extractDownloadedUpdate]; break; - case SPUUpdateStageInstalling: + case SPUUserUpdateStageInstalling: [self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction]; break; - case SPUUpdateStageNotDownloaded: + case SPUUserUpdateStageNotDownloaded: [self.coreDriver downloadUpdateFromAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem inBackground:NO]; break; - case SPUUpdateStageInformational: + case SPUUserUpdateStageInformational: assert(false); break; } @@ -219,9 +219,9 @@ } switch (stage) { - case SPUUpdateStageDownloaded: - case SPUUpdateStageNotDownloaded: - case SPUUpdateStageInformational: + case SPUUserUpdateStageDownloaded: + case SPUUserUpdateStageNotDownloaded: + case SPUUserUpdateStageInformational: // Informational updates can be resumed too, so make sure we check // self.resumingDownloadedUpdate instead of the stage we pass to user driver if (self.resumingDownloadedUpdate) { @@ -231,7 +231,7 @@ [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; break; - case SPUUpdateStageInstalling: + case SPUUserUpdateStageInstalling: [self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction]; break; } @@ -240,13 +240,13 @@ } case SPUUserUpdateChoiceDismiss: { switch (stage) { - case SPUUpdateStageDownloaded: - case SPUUpdateStageNotDownloaded: - case SPUUpdateStageInformational: { + case SPUUserUpdateStageDownloaded: + case SPUUserUpdateStageNotDownloaded: + case SPUUserUpdateStageInformational: { [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; break; } - case SPUUpdateStageInstalling: { + case SPUUserUpdateStageInstalling: { [self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction]; break; } diff --git a/Sparkle/SPUUpdateState+Private.h b/Sparkle/SPUUpdateState+Private.h deleted file mode 100644 index 1c2ab7e8..00000000 --- a/Sparkle/SPUUpdateState+Private.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// SPUUpdateState+Private.h -// Sparkle -// -// Created by Mayur Pawashe on 5/9/21. -// Copyright © 2021 Sparkle Project. All rights reserved. -// - -#ifndef SPUUpdateState_Private_h -#define SPUUpdateState_Private_h - -NS_ASSUME_NONNULL_BEGIN - -@interface SPUUpdateState (Private) - -- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated; - -@end - -NS_ASSUME_NONNULL_END - -#endif /* SPUUpdateState_Private_h */ diff --git a/Sparkle/SPUUpdateState.h b/Sparkle/SPUUpdateState.h deleted file mode 100644 index 60f8826e..00000000 --- a/Sparkle/SPUUpdateState.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// SPUUpdateState.h -// Sparkle -// -// Created by Mayur Pawashe on 2/29/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#ifndef SPUUpdateState_h -#define SPUUpdateState_h - -#if __has_feature(modules) -#if __has_warning("-Watimport-in-framework-header") -#pragma clang diagnostic ignored "-Watimport-in-framework-header" -#endif -@import Foundation; -#else -#import -#endif - -#import "SUExport.h" - -NS_ASSUME_NONNULL_BEGIN - -typedef NS_ENUM(NSInteger, SPUUpdateStage) { - SPUUpdateStageNotDownloaded, - SPUUpdateStageDownloaded, - SPUUpdateStageInstalling, - SPUUpdateStageInformational -}; - -SU_EXPORT @interface SPUUpdateState : NSObject - -@property (nonatomic, readonly) SPUUpdateStage stage; -@property (nonatomic, readonly) BOOL userInitiated; - -@end - -NS_ASSUME_NONNULL_END - -#endif /* SPUUpdateState_h */ diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 38b7f051..6b6e80af 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -15,12 +15,12 @@ #import #endif -#import "SPUUserUpdateChoice.h" +#import "SPUUserUpdateState.h" #import "SUExport.h" NS_ASSUME_NONNULL_BEGIN -@class SPUUpdatePermissionRequest, SUUpdatePermissionResponse, SUAppcastItem, SPUDownloadData, SPUUpdateState; +@class SPUUpdatePermissionRequest, SUUpdatePermissionResponse, SUAppcastItem, SPUDownloadData; /*! The API in Sparkle for controlling the user interaction. @@ -83,7 +83,7 @@ SU_EXPORT @protocol SPUUserDriver * If state.majorUpgrade is YES, the major update and any minor updates to that major release are skipped. * If the state.stage is SPUUpdateStateInstalling, the installation is also canceled when the update is skipped. */ -- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply; +- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply; /*! * Show the user the release notes for the new update diff --git a/Sparkle/SPUUserUpdateChoice.h b/Sparkle/SPUUserUpdateChoice.h deleted file mode 100644 index 194ff871..00000000 --- a/Sparkle/SPUUserUpdateChoice.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// SPUUserUpdateChoice.h -// Sparkle -// -// Created by Mayur Pawashe on 5/31/21. -// Copyright © 2021 Sparkle Project. All rights reserved. -// - -#ifndef SPUUserUpdateChoice_h -#define SPUUserUpdateChoice_h - -typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) { - SPUUserUpdateChoiceSkip, - SPUUserUpdateChoiceInstall, - SPUUserUpdateChoiceDismiss, -}; - -#endif /* SPUUserUpdateChoice_h */ diff --git a/Sparkle/SPUUserUpdateState+Private.h b/Sparkle/SPUUserUpdateState+Private.h new file mode 100644 index 00000000..578fc98d --- /dev/null +++ b/Sparkle/SPUUserUpdateState+Private.h @@ -0,0 +1,24 @@ +// +// SPUUserUpdateState+Private.h +// Sparkle +// +// Created by Mayur Pawashe on 5/9/21. +// Copyright © 2021 Sparkle Project. All rights reserved. +// + +#ifndef SPUUserUpdateState_Private_h +#define SPUUserUpdateState_Private_h + +#import "SPUUserUpdateState.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface SPUUserUpdateState (Private) + +- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated; + +@end + +NS_ASSUME_NONNULL_END + +#endif /* SPUUserUpdateState_Private_h */ diff --git a/Sparkle/SPUUserUpdateState.h b/Sparkle/SPUUserUpdateState.h new file mode 100644 index 00000000..0b004ae7 --- /dev/null +++ b/Sparkle/SPUUserUpdateState.h @@ -0,0 +1,49 @@ +// +// SPUUserUpdateState.h +// Sparkle +// +// Created by Mayur Pawashe on 2/29/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#ifndef SPUUpdateState_h +#define SPUUpdateState_h + +#if __has_feature(modules) +#if __has_warning("-Watimport-in-framework-header") +#pragma clang diagnostic ignored "-Watimport-in-framework-header" +#endif +@import Foundation; +#else +#import +#endif + +#import "SUExport.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) { + SPUUserUpdateChoiceSkip, + SPUUserUpdateChoiceInstall, + SPUUserUpdateChoiceDismiss, +}; + +typedef NS_ENUM(NSInteger, SPUUserUpdateStage) { + SPUUserUpdateStageNotDownloaded, + SPUUserUpdateStageDownloaded, + SPUUserUpdateStageInstalling, + SPUUserUpdateStageInformational +}; + +SU_EXPORT @interface SPUUserUpdateState : NSObject + +- (instancetype)init NS_UNAVAILABLE; + +@property (nonatomic, readonly) SPUUserUpdateStage stage; +@property (nonatomic, readonly) BOOL userInitiated; + +@end + +NS_ASSUME_NONNULL_END + +#endif /* SPUUserUpdateState_h */ diff --git a/Sparkle/SPUUpdateState.m b/Sparkle/SPUUserUpdateState.m similarity index 77% rename from Sparkle/SPUUpdateState.m rename to Sparkle/SPUUserUpdateState.m index 19e5c400..32654807 100644 --- a/Sparkle/SPUUpdateState.m +++ b/Sparkle/SPUUserUpdateState.m @@ -6,8 +6,8 @@ // Copyright © 2021 Sparkle Project. All rights reserved. // -#import "SPUUpdateState.h" -#import "SPUUpdateState+Private.h" +#import "SPUUserUpdateState.h" +#import "SPUUserUpdateState+Private.h" #include "AppKitPrevention.h" @@ -17,15 +17,15 @@ #define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade" #define SPUUserUpdateStateCriticalUpdateKey @"SPUUserUpdateStateCriticalUpdate" -@interface SPUUpdateState () +@interface SPUUserUpdateState () @end -@implementation SPUUpdateState +@implementation SPUUserUpdateState @synthesize stage = _stage; @synthesize userInitiated = _userInitiated; -- (instancetype)initWithStage:(SPUUpdateStage)stage userInitiated:(BOOL)userInitiated +- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated { self = [super init]; if (self != nil) { @@ -43,7 +43,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { - SPUUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey]; + SPUUserUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey]; BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey]; return [self initWithStage:stage userInitiated:userInitiated]; diff --git a/Sparkle/SUUpdateAlert.h b/Sparkle/SUUpdateAlert.h index db2a5a3b..41ee55bd 100644 --- a/Sparkle/SUUpdateAlert.h +++ b/Sparkle/SUUpdateAlert.h @@ -11,16 +11,16 @@ #import #import "SUVersionDisplayProtocol.h" -#import "SPUUserUpdateChoice.h" +#import "SPUUserUpdateState.h" @protocol SUUpdateAlertDelegate; -@class SUAppcastItem, SPUDownloadData, SUHost, SPUUpdateState; +@class SUAppcastItem, SPUDownloadData, SUHost; @interface SUUpdateAlert : NSWindowController @property (nonatomic, weak, readonly) id versionDisplayer; -- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id )aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block; +- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id )aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block; - (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData; - (void)showReleaseNotesFailedToDownload; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index cb830306..633676c8 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -27,7 +27,7 @@ #import "SUTouchBarForwardDeclarations.h" #import "SUTouchBarButtonGroup.h" #import "SPUXPCServiceInfo.h" -#import "SPUUpdateState.h" +#import "SPUUserUpdateState.h" static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDENTIFIER ".SUUpdateAlert"; @@ -37,7 +37,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE @property (strong) SUHost *host; @property (nonatomic) BOOL allowsAutomaticUpdates; @property (nonatomic, copy, nullable) void(^completionBlock)(SPUUserUpdateChoice); -@property (nonatomic) SPUUpdateState *state; +@property (nonatomic) SPUUserUpdateState *state; @property (strong) NSProgressIndicator *releaseNotesSpinner; @@ -81,7 +81,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE @synthesize webView = _webView; -- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id )aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block +- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id )aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block { self = [super initWithWindowNibName:@"SUUpdateAlert"]; if (self != nil) { @@ -93,7 +93,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE _completionBlock = [block copy]; SPUUpdaterSettings *updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:host.bundle]; - _allowsAutomaticUpdates = updaterSettings.allowsAutomaticUpdates && state.stage != SPUUpdateStageInformational; + _allowsAutomaticUpdates = updaterSettings.allowsAutomaticUpdates && state.stage != SPUUserUpdateStageInformational; [self setShouldCascadeWindows:NO]; } return self; @@ -339,7 +339,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE [self.window setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! } - if (self.state.stage == SPUUpdateStageInformational) { + if (self.state.stage == SPUUserUpdateStageInformational) { [self.installButton setTitle:SULocalizedString(@"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed.")]; [self.installButton setAction:@selector(openInfoURL:)]; } @@ -373,7 +373,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE } } - if (self.state.stage == SPUUpdateStageInstalling) { + if (self.state.stage == SPUUserUpdateStageInstalling) { // We're going to be relaunching pretty instantaneously self.installButton.title = SULocalizedString(@"Install and Relaunch", nil); @@ -411,7 +411,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE { return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]]; } - else if (self.state.stage == SPUUpdateStageDownloaded || self.state.stage == SPUUpdateStageInstalling) + else if (self.state.stage == SPUUserUpdateStageDownloaded || self.state.stage == SPUUserUpdateStageInstalling) { return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]]; } @@ -436,16 +436,16 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE // We display a different summary depending on if it's an "info-only" item, or a "critical update" item, or if we've already downloaded the update and just need to relaunch NSString *finalString = nil; - if (self.state.stage == SPUUpdateStageInformational) { + if (self.state.stage == SPUUserUpdateStageInformational) { finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?", @"Description text for SUUpdateAlert when the update informational with no download."), self.host.name, updateItemVersion, hostVersion]; } else if (self.updateItem.criticalUpdate) { - if (self.state.stage == SPUUpdateStageNotDownloaded) { + if (self.state.stage == SPUUserUpdateStageNotDownloaded) { finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. This is an important update; would you like to download it now?", @"Description text for SUUpdateAlert when the critical update is downloadable."), self.host.name, updateItemVersion, hostVersion]; } else { finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the critical update has already been downloaded and ready to install."), self.host.name, updateItemVersion]; } } else { - if (self.state.stage == SPUUpdateStageNotDownloaded) { + if (self.state.stage == SPUUserUpdateStageNotDownloaded) { finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", @"Description text for SUUpdateAlert when the update is downloadable."), self.host.name, updateItemVersion, hostVersion]; } else { finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the update has already been downloaded and ready to install."), self.host.name, updateItemVersion]; diff --git a/Sparkle/Sparkle.h b/Sparkle/Sparkle.h index bd72a9f5..d451c9a1 100644 --- a/Sparkle/Sparkle.h +++ b/Sparkle/Sparkle.h @@ -30,7 +30,7 @@ #import "SPUUpdatePermissionRequest.h" #import "SUUpdatePermissionResponse.h" #import "SPUUserDriver.h" -#import "SPUUpdateState.h" +#import "SPUUserUpdateState.h" #import "SPUStandardUserDriver.h" #import "SPUStandardUserDriverDelegate.h" #import "SPUDownloadData.h" diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index 21a785c3..a72f923f 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -133,10 +133,10 @@ }]; } -- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply +- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply { switch (state.stage) { - case SPUUpdateStageInformational: + case SPUUserUpdateStageInformational: // Todo: show user interface for this NSLog(@"Found info URL: %@", appcastItem.infoURL); @@ -146,9 +146,9 @@ reply(SPUUserUpdateChoiceDismiss); break; - case SPUUpdateStageNotDownloaded: - case SPUUpdateStageDownloaded: - case SPUUpdateStageInstalling: + case SPUUserUpdateStageNotDownloaded: + case SPUUserUpdateStageDownloaded: + case SPUUserUpdateStageInstalling: [self showUpdateWithAppcastItem:appcastItem reply:reply]; break; }