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