From 833eb89bb5a95b34284771884ae91db62ce9faf5 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 14:41:07 -0700 Subject: [PATCH 01/12] Simplify user driver API Deprecate the "done" statuses for user initiated update checks and downloading updates because they really did nothing but burden implementor (there was a relic of an XPC reason back in the day that no longer applies). --- Sparkle/SPUStatusCompletionResults.h | 4 ++-- Sparkle/SPUUIBasedUpdateDriver.m | 4 ++++ Sparkle/SPUUserDriver.h | 20 ++------------------ Sparkle/SPUUserDriverCoreComponent.m | 10 ++-------- Sparkle/SPUUserInitiatedUpdateDriver.m | 4 ++++ 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Sparkle/SPUStatusCompletionResults.h b/Sparkle/SPUStatusCompletionResults.h index 38d5a6a4..98328381 100644 --- a/Sparkle/SPUStatusCompletionResults.h +++ b/Sparkle/SPUStatusCompletionResults.h @@ -19,12 +19,12 @@ #endif typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) { - SPUUserInitiatedCheckDone, + SPUUserInitiatedCheckDone __deprecated_msg("Deprecated because SPUUserInitiatedCheckDone has no effect. Just don't reply with this status."), SPUUserInitiatedCheckCanceled }; typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) { - SPUDownloadUpdateDone, + SPUDownloadUpdateDone __deprecated_msg("Deprecated because SPUDownloadUpdateDone has no effect. Just don't reply with this status."), SPUDownloadUpdateCanceled }; diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 989d3611..9fd4eafc 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -203,7 +203,11 @@ { [self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) { switch (downloadCompletionStatus) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" case SPUDownloadUpdateDone: + // Note this status is documented to have no effect +#pragma clang diagnostic pop break; case SPUDownloadUpdateCanceled: dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 31c6e7e3..a3ae4f63 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -28,18 +28,7 @@ NS_ASSUME_NONNULL_BEGIN This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell an object that implements this protocol what actions to take and show to the user. - Every method in this protocol is required (i.e, not optional) and has a void return type and can optionally take a single parameter block, which waits for - a response back from the user driver. Note that every parameter block, or reply, *must* be responded to eventually - - that is, none can be ignored. Furthermore, they can only be replied to *once* - a reply or completion block should be considered - invalidated after it's once used. The faster a reply can be made, the more Sparkle may be able to idle, and so the better. Every method in this protocol can be assumed to be called from the main thread. - - It may be possible for an action that says to invalidate or dismiss something to be called multiple times in succession, and the implementor may choose to ignore further requests. (TODO: This should be verified if this actually can happen in practice). - - Note: Once upon a time, when first developing the user driver API, I had the user driver exist in a separate process from the rest of the framework (this is no longer supported). - If you're familiar with how the higher level XPC APIs work, this explains why some of the decisions above were made - (reply block executed on any thread, reply block replied only once, single reply block, void return types, idleness, no optional methods, ...) - This is somewhat of an artifact now, but I think most of these set of restrictions still enforces a well designed API. */ SU_EXPORT @protocol SPUUserDriver @@ -66,9 +55,8 @@ SU_EXPORT @protocol SPUUserDriver * * Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar. * - * @param updateCheckStatusCompletion A reply indicating whether the initiated update check is done or canceled. - * Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. Replying with SPUUserInitiatedCheckDone - * on the other hand should not be done until -dismissUserInitiatedUpdateCheck is invoked. + * @param updateCheckStatusCompletion A reply that can be used to cancel the update check with SPUUserInitiatedCheckCanceled. + * Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. */ - (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion; @@ -76,7 +64,6 @@ SU_EXPORT @protocol SPUUserDriver * Dismiss the user initiated update check from the user * * Dismiss whatever was started in -showUserInitiatedUpdateCheckWithCompletion: - * This is an appropriate time to reply with SPUUserInitiatedCheckDone if not having done so already */ - (void)dismissUserInitiatedUpdateCheck; @@ -194,8 +181,6 @@ SU_EXPORT @protocol SPUUserDriver * * @param downloadUpdateStatusCompletion A reply of SPUDownloadUpdateCanceled can be used to cancel * the download at any point before -showDownloadDidStartExtractingUpdate is invoked. - * A reply of SPUDownloadUpdateDone signifies that the download is done, which should not be invoked until - * -showDownloadDidStartExtractingUpdate */ - (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion; @@ -219,7 +204,6 @@ SU_EXPORT @protocol SPUUserDriver /*! * Show the user that the update finished downloading and started extracting * - * This is an appropriate time to reply with SPUDownloadUpdateDone if not done so already * Sparkle uses this to show an indeterminate progress bar. * * Note that an update can resume at this point after having been downloaded before, diff --git a/Sparkle/SPUUserDriverCoreComponent.m b/Sparkle/SPUUserDriverCoreComponent.m index b9f8db91..b1042077 100644 --- a/Sparkle/SPUUserDriverCoreComponent.m +++ b/Sparkle/SPUUserDriverCoreComponent.m @@ -67,10 +67,7 @@ - (void)completeUpdateCheckStatus { - if (self.updateCheckStatusCompletion != nil) { - self.updateCheckStatusCompletion(SPUUserInitiatedCheckDone); - self.updateCheckStatusCompletion = nil; - } + self.updateCheckStatusCompletion = nil; } #pragma mark Download Status @@ -90,10 +87,7 @@ - (void)completeDownloadStatus { - if (self.downloadStatusCompletion != nil) { - self.downloadStatusCompletion(SPUDownloadUpdateDone); - self.downloadStatusCompletion = nil; - } + self.downloadStatusCompletion = nil; } #pragma mark Simple Acknoledgments diff --git a/Sparkle/SPUUserInitiatedUpdateDriver.m b/Sparkle/SPUUserInitiatedUpdateDriver.m index dd1b0064..3c5cc1b6 100644 --- a/Sparkle/SPUUserInitiatedUpdateDriver.m +++ b/Sparkle/SPUUserInitiatedUpdateDriver.m @@ -52,7 +52,11 @@ [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) { switch (completionStatus) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" case SPUUserInitiatedCheckDone: + // Note this status is documented to have no effect +#pragma clang diagnostic pop break; case SPUUserInitiatedCheckCanceled: dispatch_async(dispatch_get_main_queue(), ^{ From 9052ea912d7902ca7162d489a8e69146a6baa8e7 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 14:43:34 -0700 Subject: [PATCH 02/12] Ensure permission request response is handled on main thread We were doing this before but I accidentally removed it in a recent commit. --- Sparkle/SPUUpdater.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index c4fe937c..2971837e 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -310,12 +310,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification __weak SPUUpdater *weakSelf = self; [self.userDriver showUpdatePermissionRequest:updatePermissionRequest reply:^(SUUpdatePermissionResponse *response) { - SPUUpdater *strongSelf = weakSelf; - if (strongSelf != nil) { - [strongSelf updatePermissionRequestFinishedWithResponse:response]; - // Schedule checks, but make sure we ignore the delayed call from KVO - [strongSelf resetUpdateCycle]; - } + dispatch_async(dispatch_get_main_queue(), ^{ + SPUUpdater *strongSelf = weakSelf; + if (strongSelf != nil) { + [strongSelf updatePermissionRequestFinishedWithResponse:response]; + // Schedule checks, but make sure we ignore the delayed call from KVO + [strongSelf resetUpdateCycle]; + } + }); }]; // We start the update checks and register as observer for changes after the prompt finishes From 0b634f4d768c8ede2567bf0ae49dcb64c30a2829 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 15:00:43 -0700 Subject: [PATCH 03/12] Update API documentation for instantiating/using updater --- Sparkle/SPUStandardUpdaterController.h | 6 ++---- Sparkle/SPUUpdater.h | 7 +++++++ Sparkle/SUUpdater.m | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Sparkle/SPUStandardUpdaterController.h b/Sparkle/SPUStandardUpdaterController.h index da1e011b..a877e485 100644 --- a/Sparkle/SPUStandardUpdaterController.h +++ b/Sparkle/SPUStandardUpdaterController.h @@ -32,11 +32,9 @@ NS_ASSUME_NONNULL_BEGIN up the updater's and user driver's delegates. This controller class may not be valuable to you if: - * You want to control or defer the instantiation of an SPUUpdater, or don't want to be tied into a nib's instantiation, or don't want to use a nib + * You want to control or defer starting the SPUUpdater, or don't want to be tied into a nib's instantiation, or don't want to use a nib * You want to target a bundle that's not the main bundle - * You want to provide a custom user interface, or perhaps one that provides little-to-none - * You don't want to use a convenience class that provides very little glue ;) - + * You want to provide a custom user interface (SPUUserDriver), or perhaps one that provides little-to-none */ SU_EXPORT @interface SPUStandardUpdaterController : NSObject diff --git a/Sparkle/SPUUpdater.h b/Sparkle/SPUUpdater.h index 33e256f2..ff896eb3 100644 --- a/Sparkle/SPUUpdater.h +++ b/Sparkle/SPUUpdater.h @@ -48,6 +48,13 @@ SU_EXPORT @interface SPUUpdater : NSObject */ - (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; +/*! + Use -initWithHostBundle:applicationBundle:userDriver:delegate: or SPUStandardUpdaterController standard adapter instead. + + If you want to drop an updater into a nib, use SPUStandardUpdaterController. + */ +- (instancetype)init NS_UNAVAILABLE; + /*! Starts the updater. diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 2217f78d..0065dde1 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -91,7 +91,7 @@ static NSMutableDictionary *sharedUpdaters = nil; // This will be used when the updater is instantiated in a nib such as MainMenu - (instancetype)init { - SULog(SULogLevelDefault, @"DEPRECATION: SUUpdater is now deprecated. Please use SPUStandardUpdaterController as a nib instantiated replacement, or SPUUpdater."); + SULog(SULogLevelDefault, @"DEPRECATION: SUUpdater is deprecated in Sparkle 2 but functional for transitional purposes. Please migrate to SPUStandardUpdaterController as a nib instantiated replacement, or SPUUpdater."); return [self initForBundle:[NSBundle mainBundle]]; } From bd1769e82e384649f722e712d4f2a0045d57ff99 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 15:17:53 -0700 Subject: [PATCH 04/12] Update SampleAppcast.xml to use edSignatures --- Resources/SampleAppcast.xml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Resources/SampleAppcast.xml b/Resources/SampleAppcast.xml index e16412e5..79eb5f3f 100755 --- a/Resources/SampleAppcast.xml +++ b/Resources/SampleAppcast.xml @@ -10,8 +10,7 @@ http://you.com/app/2.0.html Wed, 09 Jan 2006 19:20:11 +0000 - - + 10.9 @@ -21,8 +20,7 @@ http://you.com/app/1.5.html Wed, 01 Jan 2006 12:20:11 +0000 - - + 10.9 @@ -33,8 +31,7 @@ http://you.com/app/1.4.html Wed, 25 Dec 2005 12:20:11 +0000 - - + 10.9 From 5408ab10c1d1a0830496b9e21db8ef6460d6b604 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 19:28:46 -0700 Subject: [PATCH 05/12] Remove lesser used XPC Services for Test App Testing WebKit2 is more important than testing sandboxed downloader service. More people should be adding entitlements to their app for connection services, so we will do that in the test app too. --- Sparkle.xcodeproj/project.pbxproj | 39 ------------------- TestApplication/Sparkle-Test-App.entitlements | 7 ++++ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index d38c7db3..1b485c6e 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -622,20 +622,6 @@ remoteGlobalIDString = 721C24441CB753E6005440CB; remoteInfo = "Installer Progress"; }; - 724BB3821D3203A9005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB36B1D31D0B7005D534A; - remoteInfo = SparkleInstallerConnection; - }; - 724BB39C1D333832005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB3921D333832005D534A; - remoteInfo = InstallerStatus; - }; 726B2B621C645FC900388755 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -699,13 +685,6 @@ remoteGlobalIDString = 726E07AC1CAF08D6001A286B; remoteInfo = SparkleInstallerLauncher; }; - 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 726E07EE1CAF37BD001A286B; - remoteInfo = SparkleUpdateDownloader; - }; 72F94F6A1CC4A0C8002DEE68 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -2598,11 +2577,8 @@ ); dependencies = ( 61B5F91C09C4CF7200B25A18 /* PBXTargetDependency */, - 724BB3831D3203A9005D534A /* PBXTargetDependency */, 72F94F621CC48669002DEE68 /* PBXTargetDependency */, - 72F94F641CC48669002DEE68 /* PBXTargetDependency */, 726E4A201C86C88F00C57C6A /* PBXTargetDependency */, - 724BB39D1D333832005D534A /* PBXTargetDependency */, ); name = "Sparkle Test App"; productName = "Test Application"; @@ -3794,16 +3770,6 @@ target = 721C24441CB753E6005440CB /* Installer Progress */; targetProxy = 721D8A791D4952B60032E472 /* PBXContainerItemProxy */; }; - 724BB3831D3203A9005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; - targetProxy = 724BB3821D3203A9005D534A /* PBXContainerItemProxy */; - }; - 724BB39D1D333832005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; - targetProxy = 724BB39C1D333832005D534A /* PBXContainerItemProxy */; - }; 726B2B631C645FC900388755 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */; @@ -3849,11 +3815,6 @@ target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; targetProxy = 72F94F611CC48669002DEE68 /* PBXContainerItemProxy */; }; - 72F94F641CC48669002DEE68 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 726E07EE1CAF37BD001A286B /* SparkleDownloader */; - targetProxy = 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */; - }; 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; diff --git a/TestApplication/Sparkle-Test-App.entitlements b/TestApplication/Sparkle-Test-App.entitlements index 35049e47..b0c011b8 100644 --- a/TestApplication/Sparkle-Test-App.entitlements +++ b/TestApplication/Sparkle-Test-App.entitlements @@ -6,6 +6,13 @@ com.apple.security.network.server + com.apple.security.network.client + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + com.apple.security.temporary-exception.shared-preference.read-write org.sparkle-project.SparkleTestApp From 372d711d2003ea6820ac5bb7a1859edc002bb063 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 19:43:12 -0700 Subject: [PATCH 06/12] Remove ATS allow-exception scripts for debug / test app --- Configurations/ConfigCommonCoverage.xcconfig | 1 - Configurations/ConfigCommonDebug.xcconfig | 2 - Configurations/ConfigCommonRelease.xcconfig | 2 - .../set-ats-exceptions-downloader-service.sh | 12 ------ Configurations/set-ats-exceptions-test-app.sh | 12 ------ Sparkle.xcodeproj/project.pbxproj | 39 ------------------- TestApplication/TestApplication-Info.plist | 5 +++ 7 files changed, 5 insertions(+), 68 deletions(-) delete mode 100755 Configurations/set-ats-exceptions-downloader-service.sh delete mode 100755 Configurations/set-ats-exceptions-test-app.sh diff --git a/Configurations/ConfigCommonCoverage.xcconfig b/Configurations/ConfigCommonCoverage.xcconfig index 4eface42..6473d933 100644 --- a/Configurations/ConfigCommonCoverage.xcconfig +++ b/Configurations/ConfigCommonCoverage.xcconfig @@ -1,6 +1,5 @@ #include "ConfigCommonDebug.xcconfig" -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index cbf15592..a47e02c6 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -2,8 +2,6 @@ // Debug only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 04b5a510..7b16ab2e 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -2,8 +2,6 @@ // Release only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 0 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/set-ats-exceptions-downloader-service.sh b/Configurations/set-ats-exceptions-downloader-service.sh deleted file mode 100755 index 9b5fa1b9..00000000 --- a/Configurations/set-ats-exceptions-downloader-service.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# http://stackoverflow.com/questions/32390228/is-it-possible-to-disable-ats-in-ios-9-just-for-debug-environment -INFOPLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}" -case "${SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS}" in -"YES"|"1") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${INFOPLIST}" -;; -"NO"|"0") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads NO" "${INFOPLIST}" -;; -esac diff --git a/Configurations/set-ats-exceptions-test-app.sh b/Configurations/set-ats-exceptions-test-app.sh deleted file mode 100755 index 53ccfc36..00000000 --- a/Configurations/set-ats-exceptions-test-app.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# We should make sure ATS is off for the test app - -DOWNLOADER_INFO_PLIST="${TARGET_BUILD_DIR}"/"${CONTENTS_FOLDER_PATH}"/XPCServices/"${DOWNLOADER_BUNDLE_ID}".xpc/Contents/Info.plist - -#Only alter bundles if code signing is off, else we'll invalidate the signature on them -#If code signing is enabled (as in debug mode), then we rely on another script for turning ATS exceptions on for these services -#In release mode however, those services do not have ATS exceptions set up which is why we have to set up exceptions *here* -if [ -z "${CODE_SIGN_IDENTITY}" ] ; then - /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${DOWNLOADER_INFO_PLIST}" -fi diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 1b485c6e..a6247e8d 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -200,13 +200,11 @@ 7246E0A41C83B685003B4E75 /* SPUStandardUpdaterController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7246E0A21C83B685003B4E75 /* SPUStandardUpdaterController.m */; }; 724BB3711D31D0B7005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3731D31D0B7005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3721D31D0B7005D534A /* main.m */; }; - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3871D32A167005D534A /* SUXPCInstallerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */; }; 724BB3881D32A167005D534A /* SUXPCInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */; }; 724BB3891D32B915005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3981D333832005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; 724BB39A1D333832005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3991D333832005D534A /* main.m */; }; - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB3931D333832005D534A /* org.sparkle-project.InstallerStatus.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3A81D33461B005D534A /* SUXPCInstallerStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */; }; 724BB3A91D33461B005D534A /* SUXPCInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */; }; 724BB3AA1D3347C2005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; @@ -441,7 +439,6 @@ 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */; }; 72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */; }; 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* org.sparkle-project.Downloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; }; 72F9EC341D5BF542004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; }; @@ -784,10 +781,7 @@ dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices"; dstSubfolderSpec = 16; files = ( - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */, - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */, 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */, - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */, 726E4A211C86C88F00C57C6A /* TestAppHelper.xpc in Embed XPC Services */, ); name = "Embed XPC Services"; @@ -1276,8 +1270,6 @@ 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = ""; }; 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; }; - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-test-app.sh"; sourceTree = ""; }; - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-downloader-service.sh"; sourceTree = ""; }; 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; }; 729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = ""; }; 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = ""; }; @@ -2366,8 +2358,6 @@ EA1E285722B6622E004AA304 /* ed25519-Release.xcconfig */, EA1E285922B6622E004AA304 /* ed25519-Shared.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */, - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */, 14652F7919A93E5F00959E44 /* set-git-version-info.sh */, 720B4C2325EBFAFD005A0592 /* link-tools.sh */, 146EC84E19A68CF8004A50C5 /* Sparkle.podspec */, @@ -2571,7 +2561,6 @@ 61B5F90009C4CEE200B25A18 /* Frameworks */, 61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */, 726E4A261C86C88F00C57C6A /* Embed XPC Services */, - 729BB3CC1D501A8F007C4276 /* Run Script */, ); buildRules = ( ); @@ -2697,7 +2686,6 @@ 726E07EB1CAF37BD001A286B /* Sources */, 726E07EC1CAF37BD001A286B /* Frameworks */, 726E07ED1CAF37BD001A286B /* Resources */, - 729BB3D01D50354C007C4276 /* ShellScript */, ); buildRules = ( ); @@ -3207,33 +3195,6 @@ shellPath = /bin/sh; shellScript = "\"$SRCROOT/Configurations/link-tools.sh\"\n"; }; - 729BB3CC1D501A8F007C4276 /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-test-app.sh\"\n"; - }; - 729BB3D01D50354C007C4276 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-downloader-service.sh\"\n"; - }; 72A5D5F11D692C860009E5AC /* Run Script: Set Git Version Info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/TestApplication/TestApplication-Info.plist b/TestApplication/TestApplication-Info.plist index 428c815c..0672481c 100644 --- a/TestApplication/TestApplication-Info.plist +++ b/TestApplication/TestApplication-Info.plist @@ -30,5 +30,10 @@ http://localhost:1337/sparkletestcast.xml SUPublicEDKey eRFPLZuNM6m8bltmtpPX4fzKbufI1z6rKJHtgIIsllk= + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + From 895bb71faeb5af256de4c9046013352be11a9f59 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:03:59 -0700 Subject: [PATCH 07/12] Add InstallerStatus and InstallerConnection services to Distribution --- Sparkle.xcodeproj/project.pbxproj | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index a6247e8d..cd7b9deb 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -605,6 +605,20 @@ remoteGlobalIDString = 7205C43D1E13049400E370AE; remoteInfo = generate_appcast; }; + 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB36B1D31D0B7005D534A; + remoteInfo = SparkleInstallerConnection; + }; + 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB3921D333832005D534A; + remoteInfo = SparkleInstallerStatus; + }; 721D8A771D4952B60032E472 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -2500,6 +2514,8 @@ 72DBA37A1D5FDE95002594A8 /* PBXTargetDependency */, 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */, 72F94F6D1CC4A0C8002DEE68 /* PBXTargetDependency */, + 7218EC352623ED97008FECF3 /* PBXTargetDependency */, + 7218EC332623ED94008FECF3 /* PBXTargetDependency */, 1454BA1619637EDB00344E57 /* PBXTargetDependency */, 14732BCF1960F73500593899 /* PBXTargetDependency */, 7205C46B1E13070300E370AE /* PBXTargetDependency */, @@ -3721,6 +3737,16 @@ target = 7205C43D1E13049400E370AE /* generate_appcast */; targetProxy = 7205C46A1E13070300E370AE /* PBXContainerItemProxy */; }; + 7218EC332623ED94008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; + targetProxy = 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */; + }; + 7218EC352623ED97008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; + targetProxy = 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */; + }; 721D8A781D4952B60032E472 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72B398D11D3D879300EE297F /* Autoupdate */; From 07e96961bf40bcbb921f9c64df586aec08f84511 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:04:53 -0700 Subject: [PATCH 08/12] Sign altered app in release too for the test app --- TestApplication/SUTestApplicationDelegate.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index ad003e49..84aff79a 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -204,7 +204,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; - (void)signApplicationIfRequiredAtPath:(NSString *)applicationPath completion:(void (^)(void))completionBlock { -#ifdef DEBUG // This is unfortunately necessary for testing sandboxing NSXPCConnection *codeSignConnection = [[NSXPCConnection alloc] initWithServiceName:@"org.sparkle-project.TestAppHelper"]; codeSignConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(TestAppHelperProtocol)]; @@ -216,10 +215,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; completionBlock(); }]; -#else - (void)(applicationPath); // ignore unused warning - completionBlock(); -#endif } - (void)applicationWillTerminate:(NSNotification * __unused)notification From e7bc17b1928a31f3aaba01003d5d72fff26542c2 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 20:19:33 -0700 Subject: [PATCH 09/12] Use $(PRODUCT_BUNDLE_IDENTIFIER) for defaults exception for test app --- TestApplication/Sparkle-Test-App.entitlements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestApplication/Sparkle-Test-App.entitlements b/TestApplication/Sparkle-Test-App.entitlements index b0c011b8..b9e43ba8 100644 --- a/TestApplication/Sparkle-Test-App.entitlements +++ b/TestApplication/Sparkle-Test-App.entitlements @@ -15,7 +15,7 @@ com.apple.security.temporary-exception.shared-preference.read-write - org.sparkle-project.SparkleTestApp + $(PRODUCT_BUNDLE_IDENTIFIER) From eea87561ab13620cc1589fa1e7b2a63a0f818237 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 21:52:09 -0700 Subject: [PATCH 10/12] Update XPC Service signing script Add entitlements to InstallerConnection and InstallerStatus services and add option to specify bundle id in the now renamed codesign_xpc_service.py script. --- Configurations/codesign_xpc_service.py | 93 +++++++++++++++++++ Configurations/make-release-package.sh | 4 + ...e-project.InstallerConnection.entitlements | 12 +++ ...arkle-project.InstallerStatus.entitlements | 12 +++ Sparkle.xcodeproj/project.pbxproj | 6 ++ bin/codesign_embedded_executable | 46 --------- 6 files changed, 127 insertions(+), 46 deletions(-) create mode 100644 Configurations/codesign_xpc_service.py create mode 100644 InstallerConnection/org.sparkle-project.InstallerConnection.entitlements create mode 100644 InstallerStatus/org.sparkle-project.InstallerStatus.entitlements delete mode 100755 bin/codesign_embedded_executable diff --git a/Configurations/codesign_xpc_service.py b/Configurations/codesign_xpc_service.py new file mode 100644 index 00000000..6c3836db --- /dev/null +++ b/Configurations/codesign_xpc_service.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +import os, sys, subprocess, tempfile, pathlib + +PRODUCT_BUNDLE_ID_MACRO = "$(PRODUCT_BUNDLE_IDENTIFIER)" + +def log_message(message): + sys.stderr.write(message + "\n") + +#Surround a token with double quotes if it has a space in it +def sanitize(argument): + return ('"' + argument + '"' if ' ' in argument else argument) + +def _codesign_service(identity, path, entitlements_path=None): + command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) + log_message(" ".join(map(sanitize, command))) + + process = subprocess.Popen(command, stdout=subprocess.PIPE) + process.communicate() + if process.returncode != 0: + log_message("Error: Failed to codesign %s" % (path)) + sys.exit(1) + +def codesign_service(service_name, identity, path, entitlements_path=None): + #Sign the auxiliary executables (if any) + executables_path = os.path.join(path, "Contents/MacOS/") + if os.path.exists(executables_path): + for executable in os.listdir(executables_path): + if executable != service_name: + _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) + + #Sign the service bundle + _codesign_service(identity, path, entitlements_path) + +# Returns entitlements back with a bundle id applied if needed +def applied_entitlements_path(entitlements_path, bundle_id, temp_dir): + entitlements_str = pathlib.Path(entitlements_path).read_text() + if PRODUCT_BUNDLE_ID_MACRO in entitlements_str: + if bundle_id is None: + return None + else: + new_entitlements_str = entitlements_str.replace(PRODUCT_BUNDLE_ID_MACRO, bundle_id) + new_entitlements_path = os.path.join(temp_dir, os.path.basename(entitlements_path)) + pathlib.Path(new_entitlements_path).write_text(new_entitlements_str) + return new_entitlements_path + else: + return entitlements_path + +def print_usage(): + log_message("Usage:\n\t%s code-signing-identity [-b app-bundle-id] service1 service2 ..." % (sys.argv[0])) + log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/org.sparkle-project.InstallerLauncher.xpc" % (sys.argv[0])) + log_message("") + log_message("Use this script to sign XPC Services to include in your Sandboxed application.") + log_message("") + log_message("bundle-id is optional and only needs to be provided when signing InstallerConnection and InstallerStatus services. Most applications do not need to use these services and can provide additional entitlements to their application instead.") + log_message("") + log_message("This script may not be needed for common development workflows. Please visit https://sparkle-project.org/documentation/sandboxing/ for more details and instructions.") + +if __name__ == "__main__": + if len(sys.argv) < 3: + print_usage() + sys.exit(1) + + signing_identity = sys.argv[1] + remaining_args = sys.argv[2:] + bundle_id = None + if remaining_args[0] == '-b': + if len(remaining_args) < 3: + # We need the bundle-id and at least one XPC Service to sign + print_usage() + sys.exit(1) + else: + bundle_id = remaining_args[1] + services = remaining_args[2:] + else: + services = remaining_args + + with tempfile.TemporaryDirectory() as temp_dir: + for service in services: + parent, child = os.path.split(service) + service_name = os.path.splitext(child)[0] + entitlements_path = os.path.join(parent, service_name + ".entitlements") + if os.path.exists(entitlements_path): + service_entitlements_path = applied_entitlements_path(entitlements_path, bundle_id, temp_dir) + if service_entitlements_path is None: + print_usage() + log_message("") + log_message("Error: Bundle ID must be specified for signing %s. As noted in the usage above, you probably don't need to embed this service." % (service_name)) + sys.exit(1) + else: + service_entitlements_path = None + + codesign_service(service_name, signing_identity, service, service_entitlements_path) diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index ad52a215..6f28327b 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -26,6 +26,8 @@ if [ "$ACTION" = "" ] ; then cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin" + cp "$SRCROOT/Configurations/codesign_xpc_service.py" "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" + chmod 0755 "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging-spm" cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app" "$CONFIGURATION_BUILD_DIR/staging" @@ -43,6 +45,8 @@ if [ "$ACTION" = "" ] ; then cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" cp "$SRCROOT/Downloader/$DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerConnection/$INSTALLER_CONNECTION_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerStatus/$INSTALLER_STATUS_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" # Only copy dSYMs for Release builds, but don't check for the presence of the actual files # because missing dSYMs in a release build SHOULD trigger a build failure diff --git a/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements new file mode 100644 index 00000000..fa7d47e6 --- /dev/null +++ b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + + + diff --git a/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements new file mode 100644 index 00000000..0cceb6d0 --- /dev/null +++ b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + + + diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index cd7b9deb..069ab392 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -1020,6 +1020,9 @@ 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUInstallationType.h; sourceTree = ""; }; 72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = ""; }; 721652671D3C8FED00FD13D8 /* SUInstallerLauncherStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerLauncherStatus.h; path = InstallerLauncher/SUInstallerLauncherStatus.h; sourceTree = SOURCE_ROOT; }; + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerConnection.entitlements"; sourceTree = ""; }; + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerStatus.entitlements"; sourceTree = ""; }; + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = codesign_xpc_service.py; sourceTree = ""; }; 721BC2061D17A532002BC71E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 721BC2081D17A553002BC71E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 721BC20A1D17A5AD002BC71E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; @@ -2107,6 +2110,7 @@ 724BB36E1D31D0B7005D534A /* SUInstallerConnectionProtocol.h */, 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */, 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */, + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */, ); name = InstallerConnection; path = ../InstallerConnection; @@ -2123,6 +2127,7 @@ 7267E5DD1D3D8F5A00D1BF90 /* SUStatusInfoProtocol.h */, 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */, 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */, + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */, ); name = InstallerStatus; path = ../InstallerStatus; @@ -2372,6 +2377,7 @@ EA1E285722B6622E004AA304 /* ed25519-Release.xcconfig */, EA1E285922B6622E004AA304 /* ed25519-Shared.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */, 14652F7919A93E5F00959E44 /* set-git-version-info.sh */, 720B4C2325EBFAFD005A0592 /* link-tools.sh */, 146EC84E19A68CF8004A50C5 /* Sparkle.podspec */, diff --git a/bin/codesign_embedded_executable b/bin/codesign_embedded_executable deleted file mode 100755 index 2337949a..00000000 --- a/bin/codesign_embedded_executable +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -import os, sys, subprocess - -def log_message(message): - sys.stderr.write(message + "\n") - -#Surround a token with double quotes if it has a space in it -def sanitize(argument): - return ('"' + argument + '"' if ' ' in argument else argument) - -def _codesign_service(identity, path, entitlements_path=None): - command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) - log_message(" ".join(map(sanitize, command))) - - process = subprocess.Popen(command, stdout=subprocess.PIPE) - process.communicate() - if process.returncode != 0: - log_message("Error: Failed to codesign %s" % (path)) - sys.exit(1) - -def codesign_service(service_name, identity, path, entitlements_path=None): - #Sign the auxiliary executables (if any) - executables_path = os.path.join(path, "Contents/MacOS/") - if os.path.exists(executables_path): - for executable in os.listdir(executables_path): - if executable != service_name: - _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) - - #Sign the service bundle - _codesign_service(identity, path, entitlements_path) - -if __name__ == "__main__": - if len(sys.argv) < 3: - log_message("Usage:\n\t%s code-signing-identity executable1 executable1 ..." % (sys.argv[0])) - log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/*.xpc" % (sys.argv[0])) - sys.exit(1) - - signing_identity = sys.argv[1] - executables = sys.argv[2:] - - for executable in executables: - parent, child = os.path.split(executable) - service_name = os.path.splitext(child)[0] - entitlements_path = os.path.join(parent, service_name + ".entitlements") - codesign_service(service_name, signing_identity, executable, None if not os.path.exists(entitlements_path) else entitlements_path) From 2d9bf07b188753932dbea85453cb2ae05542a07d Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 23:15:02 -0700 Subject: [PATCH 11/12] Add new user driver methods to cancel update checks / downloads Remove SPUUserDriverCoreComponent dependency from sparkle-cli and the Test App too, which really wasn't helping at all. --- Sparkle/SPUStandardUserDriver.m | 16 +++---- Sparkle/SPUStatusCompletionResults.h | 22 +++++---- Sparkle/SPUUIBasedUpdateDriver.m | 39 +++++++++------- Sparkle/SPUUserDriver.h | 20 +++++--- Sparkle/SPUUserDriverCoreComponent.h | 10 ++-- Sparkle/SPUUserDriverCoreComponent.m | 51 ++++++--------------- Sparkle/SPUUserInitiatedUpdateDriver.m | 35 ++++++++------ TestApplication/SUPopUpTitlebarUserDriver.m | 35 ++++---------- sparkle-cli/SPUCommandLineUserDriver.m | 28 +++-------- 9 files changed, 110 insertions(+), 146 deletions(-) diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index b9c3ed0f..1256d26c 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -217,11 +217,11 @@ #pragma mark Check for Updates -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation { assert(NSThread.isMainThread); - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; + [self.coreComponent registerCancellation:cancellation]; self.checkingController = [[SUStatusController alloc] initWithHost:self.host]; [[self.checkingController window] center]; // Force the checking controller to load its window. @@ -248,7 +248,7 @@ - (void)cancelCheckForUpdates:(id)__unused sender { - [self.coreComponent cancelUpdateCheckStatus]; + [self.coreComponent cancel]; [self closeCheckingWindow]; } @@ -256,7 +256,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent completeUpdateCheckStatus]; + [self.coreComponent clearCancellation]; [self closeCheckingWindow]; } @@ -320,11 +320,11 @@ } } -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation { assert(NSThread.isMainThread); - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; + [self.coreComponent registerCancellation:cancellation]; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; @@ -333,7 +333,7 @@ - (void)cancelDownload:(id)__unused sender { - [self.coreComponent cancelDownloadStatus]; + [self.coreComponent cancel]; } - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength @@ -395,7 +395,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent completeDownloadStatus]; + [self.coreComponent clearCancellation]; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; diff --git a/Sparkle/SPUStatusCompletionResults.h b/Sparkle/SPUStatusCompletionResults.h index 98328381..0283c119 100644 --- a/Sparkle/SPUStatusCompletionResults.h +++ b/Sparkle/SPUStatusCompletionResults.h @@ -18,16 +18,6 @@ #import #endif -typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) { - SPUUserInitiatedCheckDone __deprecated_msg("Deprecated because SPUUserInitiatedCheckDone has no effect. Just don't reply with this status."), - SPUUserInitiatedCheckCanceled -}; - -typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) { - SPUDownloadUpdateDone __deprecated_msg("Deprecated because SPUDownloadUpdateDone has no effect. Just don't reply with this status."), - SPUDownloadUpdateCanceled -}; - typedef NS_ENUM(NSUInteger, SPUInstallUpdateStatus) { SPUInstallUpdateNow, SPUInstallAndRelaunchUpdateNow, @@ -45,4 +35,16 @@ typedef NS_ENUM(NSInteger, SPUInformationalUpdateAlertChoice) { SPUSkipThisInformationalVersionChoice }; +// Deprecated +typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) { + SPUUserInitiatedCheckDone, + SPUUserInitiatedCheckCanceled +}; + +// Deprecated +typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) { + SPUDownloadUpdateDone, + SPUDownloadUpdateCanceled +}; + #endif /* SPUStatusCompletionResults_h */ diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 9fd4eafc..d361509c 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -201,25 +201,32 @@ - (void)downloadDriverWillBeginDownload { - [self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) { - switch (downloadCompletionStatus) { + void (^cancelDownload)(void) = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) { + [self.updaterDelegate userDidCancelDownload:self.updater]; + } + + [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; + }); + }; + + if ([self.userDriver respondsToSelector:@selector(showDownloadInitiatedWithCancellation:)]) { + [self.userDriver showDownloadInitiatedWithCancellation:cancelDownload]; + } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - case SPUDownloadUpdateDone: - // Note this status is documented to have no effect + [self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) { + switch (downloadCompletionStatus) { #pragma clang diagnostic pop - break; - case SPUDownloadUpdateCanceled: - dispatch_async(dispatch_get_main_queue(), ^{ - if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) { - [self.updaterDelegate userDidCancelDownload:self.updater]; - } - - [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; - }); - break; - } - }]; + case SPUDownloadUpdateDone: + break; + case SPUDownloadUpdateCanceled: + cancelDownload(); + break; + } + }]; + } } - (void)downloadDriverDidReceiveExpectedContentLength:(uint64_t)expectedContentLength diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index a3ae4f63..00391c4a 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -55,10 +55,10 @@ SU_EXPORT @protocol SPUUserDriver * * Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar. * - * @param updateCheckStatusCompletion A reply that can be used to cancel the update check with SPUUserInitiatedCheckCanceled. + * @param cancellation Invoke this cancellation block to cancel the update check. * Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. */ -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion; +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation; /*! * Dismiss the user initiated update check from the user @@ -179,10 +179,9 @@ SU_EXPORT @protocol SPUUserDriver * * Let the user know that downloading the new update started. * - * @param downloadUpdateStatusCompletion A reply of SPUDownloadUpdateCanceled can be used to cancel - * the download at any point before -showDownloadDidStartExtractingUpdate is invoked. + * @param cancellation Invoke this cancellation block to cancel the download at any point before -showDownloadDidStartExtractingUpdate is invoked. */ -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion; +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation; /*! * Show the user the content length of the new update that will be downloaded @@ -267,16 +266,25 @@ SU_EXPORT @protocol SPUUserDriver /*! * Dismiss the current update installation * - * Stop and tear down everything. Reply to all outstanding reply/completion blocks. + * Stop and tear down everything. * Dismiss all update windows, alerts, progress, etc from the user. * Basically, stop everything that could have been started. Sparkle may invoke this when aborting or finishing an update. */ - (void)dismissUpdateInstallation; +/* + * Below are deprecated methods that have been replaced by better alternatives. + * The deprecated methods will be used if the alternatives have not been implemented yet. + * In the future support for using these deprecated methods may be removed however. + */ @optional - (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead"); +- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion __deprecated_msg("Implement -showUserInitiatedUpdateCheckWithCancellation: instead"); + +- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion __deprecated_msg("Implement -showDownloadInitiatedWithCancellation: instead"); + @end NS_ASSUME_NONNULL_END diff --git a/Sparkle/SPUUserDriverCoreComponent.h b/Sparkle/SPUUserDriverCoreComponent.h index 4ccfdab3..d6db4887 100644 --- a/Sparkle/SPUUserDriverCoreComponent.h +++ b/Sparkle/SPUUserDriverCoreComponent.h @@ -24,13 +24,9 @@ SU_EXPORT @interface SPUUserDriverCoreComponent : NSObject - (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler; - (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice; -- (void)registerUpdateCheckStatusHandler:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion; -- (void)cancelUpdateCheckStatus; -- (void)completeUpdateCheckStatus; - -- (void)registerDownloadStatusHandler:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion; -- (void)cancelDownloadStatus; -- (void)completeDownloadStatus; +- (void)registerCancellation:(void (^)(void))cancellation; +- (void)cancel; +- (void)clearCancellation; - (void)registerAcknowledgement:(void (^)(void))acknowledgement; - (void)acceptAcknowledgement; diff --git a/Sparkle/SPUUserDriverCoreComponent.m b/Sparkle/SPUUserDriverCoreComponent.m index b1042077..2aeb2ed9 100644 --- a/Sparkle/SPUUserDriverCoreComponent.m +++ b/Sparkle/SPUUserDriverCoreComponent.m @@ -14,8 +14,7 @@ @interface SPUUserDriverCoreComponent () @property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus); -@property (nonatomic, copy) void (^updateCheckStatusCompletion)(SPUUserInitiatedCheckStatus); -@property (nonatomic, copy) void (^downloadStatusCompletion)(SPUDownloadUpdateStatus); +@property (nonatomic, copy) void (^cancellation)(void); @property (nonatomic, copy) void (^acknowledgement)(void); @end @@ -23,8 +22,7 @@ @implementation SPUUserDriverCoreComponent @synthesize installUpdateHandler = _installUpdateHandler; -@synthesize updateCheckStatusCompletion = _updateCheckStatusCompletion; -@synthesize downloadStatusCompletion = _downloadStatusCompletion; +@synthesize cancellation = _cancellation; @synthesize acknowledgement = _acknowledgement; #pragma mark Install Updates @@ -50,44 +48,24 @@ } } -#pragma mark Update Check Status +#pragma mark Cancellation -- (void)registerUpdateCheckStatusHandler:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)registerCancellation:(void (^)(void))cancellation { - self.updateCheckStatusCompletion = updateCheckStatusCompletion; + self.cancellation = cancellation; } -- (void)cancelUpdateCheckStatus +- (void)cancel { - if (self.updateCheckStatusCompletion != nil) { - self.updateCheckStatusCompletion(SPUUserInitiatedCheckCanceled); - self.updateCheckStatusCompletion = nil; + if (self.cancellation != nil) { + self.cancellation(); + self.cancellation = nil; } } -- (void)completeUpdateCheckStatus +- (void)clearCancellation { - self.updateCheckStatusCompletion = nil; -} - -#pragma mark Download Status - -- (void)registerDownloadStatusHandler:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion -{ - self.downloadStatusCompletion = downloadUpdateStatusCompletion; -} - -- (void)cancelDownloadStatus -{ - if (self.downloadStatusCompletion != nil) { - self.downloadStatusCompletion(SPUDownloadUpdateCanceled); - self.downloadStatusCompletion = nil; - } -} - -- (void)completeDownloadStatus -{ - self.downloadStatusCompletion = nil; + self.cancellation = nil; } #pragma mark Simple Acknoledgments @@ -109,10 +87,9 @@ - (void)dismissUpdateInstallation { - [self acceptAcknowledgement]; - [self cancelUpdateCheckStatus]; - [self cancelDownloadStatus]; - [self dismissInstallAndRestart]; + self.acknowledgement = nil; + self.cancellation = nil; + self.installUpdateHandler = nil; } @end diff --git a/Sparkle/SPUUserInitiatedUpdateDriver.m b/Sparkle/SPUUserInitiatedUpdateDriver.m index 3c5cc1b6..5bcdaa28 100644 --- a/Sparkle/SPUUserInitiatedUpdateDriver.m +++ b/Sparkle/SPUUserInitiatedUpdateDriver.m @@ -50,23 +50,30 @@ } else { self.showingUserInitiatedProgress = YES; - [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) { - switch (completionStatus) { + void (^cancelUpdateCheck)(void) = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.showingUserInitiatedProgress) { + [self abortUpdate]; + } + }); + }; + + if ([self.userDriver respondsToSelector:@selector(showUserInitiatedUpdateCheckWithCancellation:)]) { + [self.userDriver showUserInitiatedUpdateCheckWithCancellation:cancelUpdateCheck]; + } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - case SPUUserInitiatedCheckDone: - // Note this status is documented to have no effect + [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) { #pragma clang diagnostic pop - break; - case SPUUserInitiatedCheckCanceled: - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.showingUserInitiatedProgress) { - [self abortUpdate]; - } - }); - break; - } - }]; + switch (completionStatus) { + case SPUUserInitiatedCheckDone: + break; + case SPUUserInitiatedCheckCanceled: + cancelUpdateCheck(); + break; + } + }]; + } [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO includesSkippedUpdates:YES]; } diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index d49fcb43..46d58477 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -13,7 +13,6 @@ @property (nonatomic, readonly) NSWindow *window; @property (nonatomic, nullable) SUInstallUpdateViewController *installUpdateViewController; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic) NSTitlebarAccessoryViewController *accessoryViewController; @property (nonatomic) BOOL addedAccessory; @property (nonatomic) NSButton *updateButton; @@ -27,7 +26,6 @@ @synthesize window = _window; @synthesize installUpdateViewController = _installUpdateViewController; -@synthesize coreComponent = _coreComponent; @synthesize accessoryViewController = _accessoryViewController; @synthesize addedAccessory = _addedAccessory; @synthesize updateButton = _updateButton; @@ -40,7 +38,6 @@ self = [super init]; if (self != nil) { _window = window; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -189,63 +186,52 @@ - (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler { - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; - - __weak SUPopUpTitlebarUserDriver *weakSelf = self; [self addUpdateButtonWithTitle:@"Install & Relaunch" action:^(NSButton *__unused button) { - [weakSelf.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + installUpdateHandler(SPUInstallAndRelaunchUpdateNow); }]; } #pragma mark Check for Updates -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; - [self addUpdateButtonWithTitle:@"Checking for Updates…"]; } - (void)dismissUserInitiatedUpdateCheck { - [self.coreComponent completeUpdateCheckStatus]; [self removeUpdateButton]; } #pragma mark Update Errors -- (void)acceptAcknowledgementAfterDelay +- (void)acceptAcknowledgementAfterDelay:(void (^)(void))acknowledgement { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // Installation will be dismissed shortly after this - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); }); } - (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSLog(@"Error: %@", error); [self addUpdateButtonWithTitle:@"Update Errored!" action:nil]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - [self addUpdateButtonWithTitle:@"No Update Available" action:nil]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } #pragma mark Download & Install Updates -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; } - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength @@ -272,7 +258,6 @@ - (void)showDownloadDidStartExtractingUpdate { - [self.coreComponent completeDownloadStatus]; [self addUpdateButtonWithTitle:@"Extracting…"]; } @@ -294,19 +279,15 @@ - (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - [self addUpdateButtonWithTitle:@"Installation Finished!"]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } #pragma mark Aborting Everything - (void)dismissUpdateInstallation { - [self.coreComponent dismissUpdateInstallation]; - [self removeUpdateButton]; } diff --git a/sparkle-cli/SPUCommandLineUserDriver.m b/sparkle-cli/SPUCommandLineUserDriver.m index 4f9c2c90..2ca61bdf 100644 --- a/sparkle-cli/SPUCommandLineUserDriver.m +++ b/sparkle-cli/SPUCommandLineUserDriver.m @@ -17,7 +17,6 @@ @property (nonatomic, nullable, readonly) SUUpdatePermissionResponse *updatePermissionResponse; @property (nonatomic, readonly) BOOL deferInstallation; @property (nonatomic, readonly) BOOL verbose; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic) uint64_t bytesDownloaded; @property (nonatomic) uint64_t bytesToDownload; @@ -28,7 +27,6 @@ @synthesize updatePermissionResponse = _updatePermissionResponse; @synthesize deferInstallation = _deferInstallation; @synthesize verbose = _verbose; -@synthesize coreComponent = _coreComponent; @synthesize bytesDownloaded = _bytesDownloaded; @synthesize bytesToDownload = _bytesToDownload; @@ -39,7 +37,6 @@ _updatePermissionResponse = updatePermissionResponse; _deferInstallation = deferInstallation; _verbose = verbose; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -62,9 +59,8 @@ } } -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; if (self.verbose) { fprintf(stderr, "Checking for Updates...\n"); } @@ -72,7 +68,6 @@ - (void)dismissUserInitiatedUpdateCheck { - [self.coreComponent completeUpdateCheckStatus]; } - (void)displayReleaseNotes:(const char * _Nullable)releaseNotes @@ -124,16 +119,15 @@ - (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply { - [self.coreComponent registerInstallUpdateHandler:reply]; [self showUpdateWithAppcastItem:appcastItem updateAdjective:@"resumable"]; if (self.deferInstallation) { if (self.verbose) { fprintf(stderr, "Deferring Installation.\n"); } - [self.coreComponent installUpdateWithChoice:SPUDismissUpdateInstallation]; + reply(SPUDismissUpdateInstallation); } else { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + reply(SPUInstallAndRelaunchUpdateNow); } } @@ -187,10 +181,8 @@ exit(EXIT_FAILURE); } -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; - if (self.verbose) { fprintf(stderr, "Downloading Update...\n"); } @@ -221,8 +213,6 @@ - (void)showDownloadDidStartExtractingUpdate { - [self.coreComponent completeDownloadStatus]; - if (self.verbose) { fprintf(stderr, "Extracting update...\n"); } @@ -237,15 +227,13 @@ - (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler { - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; - if (self.deferInstallation) { if (self.verbose) { fprintf(stderr, "Deferring Installation.\n"); } - [self.coreComponent installUpdateWithChoice:SPUDismissUpdateInstallation]; + installUpdateHandler(SPUDismissUpdateInstallation); } else { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + installUpdateHandler(SPUInstallAndRelaunchUpdateNow); } } @@ -258,13 +246,11 @@ - (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - if (self.verbose) { fprintf(stderr, "Installation Finished.\n"); } - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)dismissUpdateInstallation __attribute__((noreturn)) From cb10bb80466b94f5c0a0f5409d3d7513c6b00d5e Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 11 Apr 2021 23:31:04 -0700 Subject: [PATCH 12/12] Remove SPUUserDriverCoreComponent usage completely --- Sparkle.xcodeproj/project.pbxproj | 12 ---- Sparkle/SPUStandardUserDriver.m | 48 ++++++++------ Sparkle/SPUUserDriverCoreComponent.h | 36 ----------- Sparkle/SPUUserDriverCoreComponent.m | 95 ---------------------------- Sparkle/Sparkle.h | 1 - Sparkle/SparkleCore.h | 1 - 6 files changed, 27 insertions(+), 166 deletions(-) delete mode 100644 Sparkle/SPUUserDriverCoreComponent.h delete mode 100644 Sparkle/SPUUserDriverCoreComponent.m diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index d38c7db3..1a94c835 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -220,8 +220,6 @@ 725CB95B1C7121830064365A /* SPUStandardUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725CB9591C7121830064365A /* SPUStandardUserDriver.m */; }; 725F97771C8A62F500265BE4 /* SUAdHocCodeSigning.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */; }; 725F97781C8A65AC00265BE4 /* SUAdHocCodeSigning.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */; }; - 725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 725F977C1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */; }; 725F97841C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97831C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m */; }; 725F97A51C8B304D00265BE4 /* SUInstallUpdateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97A31C8B304D00265BE4 /* SUInstallUpdateViewController.m */; }; 725F97A61C8B304D00265BE4 /* SUInstallUpdateViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 725F97A41C8B304D00265BE4 /* SUInstallUpdateViewController.xib */; }; @@ -365,7 +363,6 @@ 72A5D5D71D6929F80009E5AC /* SUUpdatePermissionResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SUUpdatePermissionResponse.m */; }; 72A5D5D81D6929F80009E5AC /* SPUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */; }; 72A5D5D91D6929F90009E5AC /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; }; - 72A5D5DA1D6929F90009E5AC /* SPUUserDriverCoreComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */; }; 72A5D5DC1D692A4E0009E5AC /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; }; 72A5D5DE1D692ACC0009E5AC /* SparkleCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A5D5DD1D692ACC0009E5AC /* SparkleCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5DF1D692B570009E5AC /* SUAppcast.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5FB9409C4F04600B25A18 /* SUAppcast.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -379,7 +376,6 @@ 72A5D5E71D692BB00009E5AC /* SPUUpdatePermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 72DBA37B1D60CC34002594A8 /* SPUUpdatePermissionRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5E81D692BBB0009E5AC /* SUUpdatePermissionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SUUpdatePermissionResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5E91D692BC80009E5AC /* SPUUserDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 725CB9561C7120410064365A /* SPUUserDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 72A5D5EA1D692BC80009E5AC /* SPUUserDriverCoreComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5EB1D692BD40009E5AC /* SPUDownloadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5EF1D692C440009E5AC /* Autoupdate in Copy Tools */ = {isa = PBXBuildFile; fileRef = 72B398D21D3D879300EE297F /* Autoupdate */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 72A5D5F01D692C4B0009E5AC /* Updater.app in Copy Tools */ = {isa = PBXBuildFile; fileRef = 721C24451CB753E6005440CB /* Updater.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -1203,8 +1199,6 @@ 725CB9591C7121830064365A /* SPUStandardUserDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUStandardUserDriver.m; sourceTree = ""; }; 725F97741C8A62F500265BE4 /* SUAdHocCodeSigning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAdHocCodeSigning.h; sourceTree = ""; }; 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAdHocCodeSigning.m; sourceTree = ""; }; - 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUserDriverCoreComponent.h; sourceTree = ""; }; - 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUserDriverCoreComponent.m; sourceTree = ""; }; 725F97821C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPopUpTitlebarUserDriver.h; sourceTree = ""; }; 725F97831C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPopUpTitlebarUserDriver.m; sourceTree = ""; }; 725F97A21C8B304D00265BE4 /* SUInstallUpdateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUInstallUpdateViewController.h; sourceTree = ""; }; @@ -2153,8 +2147,6 @@ 726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */, 726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */, 725CB9561C7120410064365A /* SPUUserDriver.h */, - 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */, - 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */, ); name = "User Driver"; sourceTree = ""; @@ -2414,7 +2406,6 @@ 72A5D5E41D692B770009E5AC /* SPUUpdaterDelegate.h in Headers */, 72A5D5E31D692B770009E5AC /* SPUUpdaterSettings.h in Headers */, 72A5D5E91D692BC80009E5AC /* SPUUserDriver.h in Headers */, - 72A5D5EA1D692BC80009E5AC /* SPUUserDriverCoreComponent.h in Headers */, 72A5D5DF1D692B570009E5AC /* SUAppcast.h in Headers */, 72A5D5E01D692B570009E5AC /* SUAppcastItem.h in Headers */, 72A5D5E61D692BA20009E5AC /* SUErrors.h in Headers */, @@ -2462,7 +2453,6 @@ 723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */, 7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */, 725CB9571C7120410064365A /* SPUUserDriver.h in Headers */, - 725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */, 72B767DE1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.h in Headers */, 72F94F581CC44DE1002DEE68 /* SPUXPCServiceInfo.h in Headers */, 61B5FC0D09C4FC8200B25A18 /* SUAppcast.h in Headers */, @@ -3512,7 +3502,6 @@ 72A5D5D91D6929F90009E5AC /* SPUUpdaterTimer.m in Sources */, 72A5D5BB1D6929F80009E5AC /* SPUURLDownload.m in Sources */, 72A5D5BC1D6929F80009E5AC /* SPUURLRequest.m in Sources */, - 72A5D5DA1D6929F90009E5AC /* SPUUserDriverCoreComponent.m in Sources */, 72A5D5C81D6929F80009E5AC /* SPUUserInitiatedUpdateDriver.m in Sources */, 72A5D5AD1D6929F80009E5AC /* SPUXPCServiceInfo.m in Sources */, 72A5D5B91D6929F80009E5AC /* SUAppcast.m in Sources */, @@ -3624,7 +3613,6 @@ 72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */, 72B09CE81CE6BCBD0052EF9E /* SPUURLDownload.m in Sources */, 7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */, - 725F977C1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m in Sources */, 72B767DF1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.m in Sources */, 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */, 61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */, diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index 1256d26c..ec544826 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -7,7 +7,6 @@ // #import "SPUStandardUserDriver.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUStandardUserDriverDelegate.h" #import "SUAppcastItem.h" #import "SUVersionDisplayProtocol.h" @@ -23,9 +22,11 @@ @property (nonatomic, readonly) SUHost *host; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic, weak, nullable, readonly) id delegate; +@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus); +@property (nonatomic, copy) void (^cancellation)(void); + @property (nonatomic) SUStatusController *checkingController; @property (nonatomic) SUUpdateAlert *activeUpdateAlert; @property (nonatomic) SUStatusController *statusController; @@ -36,7 +37,8 @@ @implementation SPUStandardUserDriver @synthesize host = _host; -@synthesize coreComponent = _coreComponent; +@synthesize installUpdateHandler = _installUpdateHandler; +@synthesize cancellation = _cancellation; @synthesize delegate = _delegate; @synthesize checkingController = _checkingController; @synthesize activeUpdateAlert = _activeUpdateAlert; @@ -51,7 +53,6 @@ if (self != nil) { _host = [[SUHost alloc] initWithBundle:hostBundle]; _delegate = delegate; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -207,12 +208,15 @@ [[self.statusController window] makeKeyAndOrderFront:self]; [NSApp requestUserAttention:NSInformationalRequest]; - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; + self.installUpdateHandler = installUpdateHandler; } - (void)installAndRestart:(id)__unused sender { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + if (self.installUpdateHandler != nil) { + self.installUpdateHandler(SPUInstallAndRelaunchUpdateNow); + self.installUpdateHandler = nil; + } } #pragma mark Check for Updates @@ -221,7 +225,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent registerCancellation:cancellation]; + self.cancellation = cancellation; self.checkingController = [[SUStatusController alloc] initWithHost:self.host]; [[self.checkingController window] center]; // Force the checking controller to load its window. @@ -248,7 +252,10 @@ - (void)cancelCheckForUpdates:(id)__unused sender { - [self.coreComponent cancel]; + if (self.cancellation != nil) { + self.cancellation(); + self.cancellation = nil; + } [self closeCheckingWindow]; } @@ -256,7 +263,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent clearCancellation]; + self.cancellation = nil; [self closeCheckingWindow]; } @@ -266,28 +273,24 @@ { assert(NSThread.isMainThread); - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = SULocalizedString(@"Update Error!", nil); alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]]; [alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)]; [self showAlert:alert]; - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { assert(NSThread.isMainThread); - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSAlert *alert = [NSAlert alertWithError:error]; alert.alertStyle = NSAlertStyleInformational; [self showAlert:alert]; - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)showAlert:(NSAlert *)alert @@ -324,7 +327,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent registerCancellation:cancellation]; + self.cancellation = cancellation; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; @@ -333,7 +336,10 @@ - (void)cancelDownload:(id)__unused sender { - [self.coreComponent cancel]; + if (self.cancellation != nil) { + self.cancellation(); + self.cancellation = nil; + } } - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength @@ -395,7 +401,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent clearCancellation]; + self.cancellation = nil; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; @@ -426,8 +432,7 @@ assert(NSThread.isMainThread); // Deciding not to show anything here - [self.coreComponent registerAcknowledgement:acknowledgement]; - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } #pragma mark Aborting Everything @@ -447,7 +452,8 @@ { assert(NSThread.isMainThread); - [self.coreComponent dismissUpdateInstallation]; + self.installUpdateHandler = nil; + self.cancellation = nil; [self closeCheckingWindow]; diff --git a/Sparkle/SPUUserDriverCoreComponent.h b/Sparkle/SPUUserDriverCoreComponent.h deleted file mode 100644 index d6db4887..00000000 --- a/Sparkle/SPUUserDriverCoreComponent.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// SUUserDriverCoreComponent.h -// Sparkle -// -// Created by Mayur Pawashe on 3/4/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#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 "SPUStatusCompletionResults.h" -#import "SUExport.h" - -@protocol SPUStandardUserDriverDelegate; - -SU_EXPORT @interface SPUUserDriverCoreComponent : NSObject - -- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler; -- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice; - -- (void)registerCancellation:(void (^)(void))cancellation; -- (void)cancel; -- (void)clearCancellation; - -- (void)registerAcknowledgement:(void (^)(void))acknowledgement; -- (void)acceptAcknowledgement; - -- (void)dismissUpdateInstallation; - -@end diff --git a/Sparkle/SPUUserDriverCoreComponent.m b/Sparkle/SPUUserDriverCoreComponent.m deleted file mode 100644 index 2aeb2ed9..00000000 --- a/Sparkle/SPUUserDriverCoreComponent.m +++ /dev/null @@ -1,95 +0,0 @@ -// -// SUUserDriverCoreComponent.m -// Sparkle -// -// Created by Mayur Pawashe on 3/4/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import "SPUUserDriverCoreComponent.h" - - -#include "AppKitPrevention.h" - -@interface SPUUserDriverCoreComponent () - -@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus); -@property (nonatomic, copy) void (^cancellation)(void); -@property (nonatomic, copy) void (^acknowledgement)(void); - -@end - -@implementation SPUUserDriverCoreComponent - -@synthesize installUpdateHandler = _installUpdateHandler; -@synthesize cancellation = _cancellation; -@synthesize acknowledgement = _acknowledgement; - -#pragma mark Install Updates - -- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler -{ - self.installUpdateHandler = installUpdateHandler; -} - -- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice -{ - if (self.installUpdateHandler != nil) { - self.installUpdateHandler(choice); - self.installUpdateHandler = nil; - } -} - -- (void)dismissInstallAndRestart -{ - if (self.installUpdateHandler != nil) { - self.installUpdateHandler(SPUDismissUpdateInstallation); - self.installUpdateHandler = nil; - } -} - -#pragma mark Cancellation - -- (void)registerCancellation:(void (^)(void))cancellation -{ - self.cancellation = cancellation; -} - -- (void)cancel -{ - if (self.cancellation != nil) { - self.cancellation(); - self.cancellation = nil; - } -} - -- (void)clearCancellation -{ - self.cancellation = nil; -} - -#pragma mark Simple Acknoledgments - -- (void)registerAcknowledgement:(void (^)(void))acknowledgement -{ - self.acknowledgement = acknowledgement; -} - -- (void)acceptAcknowledgement -{ - if (self.acknowledgement != nil) { - self.acknowledgement(); - self.acknowledgement = nil; - } -} - -#pragma mark Aborting Everything - -- (void)dismissUpdateInstallation -{ - self.acknowledgement = nil; - self.cancellation = nil; - self.installUpdateHandler = nil; -} - -@end diff --git a/Sparkle/Sparkle.h b/Sparkle/Sparkle.h index a3ec078f..8ec3e01e 100644 --- a/Sparkle/Sparkle.h +++ b/Sparkle/Sparkle.h @@ -32,7 +32,6 @@ #import "SPUUserDriver.h" #import "SPUStandardUserDriver.h" #import "SPUStandardUserDriverDelegate.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUDownloadData.h" #import "SUUpdater.h" // deprecated diff --git a/Sparkle/SparkleCore.h b/Sparkle/SparkleCore.h index 5d3521e7..118672aa 100644 --- a/Sparkle/SparkleCore.h +++ b/Sparkle/SparkleCore.h @@ -29,7 +29,6 @@ #import "SPUUpdatePermissionRequest.h" #import "SUUpdatePermissionResponse.h" #import "SPUUserDriver.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUDownloadData.h" #pragma clang diagnostic pop