mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Merge showUpdateFount: methods into single one
Handling the different variations with different completion blocks is a pain when ultimately clients want to display a mostly unified user interface.
This commit is contained in:
1 parent
2d0b9ae356
commit
e64253be0b
13 files changed
+285
-340
No files matched your search
Vendored
+1
-1
@@ -99,7 +99,7 @@
|
||||
if (self.willInstallSilently && [updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)]) {
|
||||
__weak SPUAutomaticUpdateDriver *weakSelf = self;
|
||||
installationHandledByDelegate = [updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
|
||||
[weakSelf.coreDriver finishInstallationWithResponse:SPUInstallAndRelaunchUpdateNow displayingUserInterface:NO];
|
||||
[weakSelf.coreDriver finishInstallationWithResponse:SPUUserUpdateChoiceInstall displayingUserInterface:NO];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)clearDownloadedUpdate;
|
||||
|
||||
- (void)finishInstallationWithResponse:(SPUInstallUpdateStatus)installUpdateStatus displayingUserInterface:(BOOL)displayingUserInterface;
|
||||
- (void)finishInstallationWithResponse:(SPUUserUpdateChoice)installUpdateStatus displayingUserInterface:(BOOL)displayingUserInterface;
|
||||
|
||||
- (void)abortUpdateAndShowNextUpdateImmediately:(BOOL)shouldShowUpdateImmediately error:(nullable NSError *)error;
|
||||
|
||||
|
||||
Vendored
+5
-7
@@ -297,16 +297,14 @@
|
||||
[self.delegate installerDidFinishPreparationAndWillInstallImmediately:willInstallImmediately silently:willInstallSilently];
|
||||
}
|
||||
|
||||
- (void)finishInstallationWithResponse:(SPUInstallUpdateStatus)installUpdateStatus displayingUserInterface:(BOOL)displayingUserInterface
|
||||
- (void)finishInstallationWithResponse:(SPUUserUpdateChoice)response displayingUserInterface:(BOOL)displayingUserInterface
|
||||
{
|
||||
switch (installUpdateStatus) {
|
||||
case SPUDismissUpdateInstallation:
|
||||
switch (response) {
|
||||
case SPUUserUpdateChoiceDismiss:
|
||||
case SPUUserUpdateChoiceSkip:
|
||||
[self.delegate coreDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
case SPUInstallUpdateNow:
|
||||
[self.installerDriver installWithToolAndRelaunch:NO displayingUserInterface:displayingUserInterface];
|
||||
break;
|
||||
case SPUInstallAndRelaunchUpdateNow:
|
||||
case SPUUserUpdateChoiceInstall:
|
||||
[self.installerDriver installWithToolAndRelaunch:YES displayingUserInterface:displayingUserInterface];
|
||||
break;
|
||||
}
|
||||
|
||||
Vendored
+10
-54
@@ -28,7 +28,7 @@
|
||||
|
||||
@property (nonatomic, weak, nullable, readonly) id <SPUStandardUserDriverDelegate> delegate;
|
||||
|
||||
@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus);
|
||||
@property (nonatomic, copy) void (^installUpdateHandler)(SPUUserUpdateChoice);
|
||||
@property (nonatomic, copy) void (^cancellation)(void);
|
||||
|
||||
@property (nonatomic) SUStatusController *checkingController;
|
||||
@@ -124,68 +124,24 @@
|
||||
|
||||
#pragma mark Update Found
|
||||
|
||||
- (void)showUpdateFoundWithAlertHandler:(SUUpdateAlert *(^)(SPUStandardUserDriver *, SUHost *, id<SUVersionDisplay>))alertHandler userInitiated:(BOOL)userInitiated
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
id <SUVersionDisplay> versionDisplayer = nil;
|
||||
if ([self.delegate respondsToSelector:@selector(standardUserDriverRequestsVersionDisplayer)]) {
|
||||
versionDisplayer = [self.delegate standardUserDriverRequestsVersionDisplayer];
|
||||
}
|
||||
|
||||
__weak SPUStandardUserDriver *weakSelf = self;
|
||||
SUHost *host = self.host;
|
||||
self.activeUpdateAlert = alertHandler(weakSelf, host, versionDisplayer);
|
||||
self.activeUpdateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem state:state host:self.host versionDisplayer:versionDisplayer completionBlock:^(SPUUserUpdateChoice choice) {
|
||||
reply(choice);
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
|
||||
[self setUpFocusForActiveUpdateAlertWithUserInitiation:userInitiated];
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
[self showUpdateFoundWithAlertHandler:^SUUpdateAlert *(SPUStandardUserDriver *weakSelf, SUHost *host, id<SUVersionDisplay> versionDisplayer) {
|
||||
return [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem alreadyDownloaded:NO host:host versionDisplayer:versionDisplayer completionBlock:^(SPUUpdateAlertChoice choice) {
|
||||
reply(choice);
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
} userInitiated:userInitiated];
|
||||
}
|
||||
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
[self showUpdateFoundWithAlertHandler:^SUUpdateAlert *(SPUStandardUserDriver *weakSelf, SUHost *host, id<SUVersionDisplay> versionDisplayer) {
|
||||
return [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem alreadyDownloaded:YES host:host versionDisplayer:versionDisplayer completionBlock:^(SPUUpdateAlertChoice choice) {
|
||||
reply(choice);
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
} userInitiated:userInitiated];
|
||||
}
|
||||
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
[self showUpdateFoundWithAlertHandler:^SUUpdateAlert *(SPUStandardUserDriver *weakSelf, SUHost *host, id<SUVersionDisplay> versionDisplayer) {
|
||||
return [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:host versionDisplayer:versionDisplayer resumableCompletionBlock:^(SPUInstallUpdateStatus choice) {
|
||||
reply(choice);
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
} userInitiated:userInitiated];
|
||||
}
|
||||
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
[self showUpdateFoundWithAlertHandler:^SUUpdateAlert *(SPUStandardUserDriver *weakSelf, SUHost *host, id<SUVersionDisplay> versionDisplayer) {
|
||||
return [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:host versionDisplayer:versionDisplayer informationalCompletionBlock:^(SPUInformationalUpdateAlertChoice choice) {
|
||||
reply(choice);
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
} userInitiated:userInitiated];
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
@@ -205,7 +161,7 @@
|
||||
|
||||
#pragma mark Install & Relaunch Update
|
||||
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))installUpdateHandler
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
@@ -222,7 +178,7 @@
|
||||
- (void)installAndRestart:(id)__unused sender
|
||||
{
|
||||
if (self.installUpdateHandler != nil) {
|
||||
self.installUpdateHandler(SPUInstallAndRelaunchUpdateNow);
|
||||
self.installUpdateHandler(SPUUserUpdateChoiceInstall);
|
||||
self.installUpdateHandler = nil;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+22
-5
@@ -18,23 +18,40 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
// The value ordering here intentionally aligns with replacing SPUInstallUpdateStatus
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) {
|
||||
SPUUserUpdateChoiceSkip,
|
||||
SPUUserUpdateChoiceInstall,
|
||||
SPUUserUpdateChoiceDismiss,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateState) {
|
||||
SPUUserUpdateStateNotDownloaded,
|
||||
SPUUserUpdateStateDownloaded,
|
||||
SPUUserUpdateStateInstalling,
|
||||
SPUUserUpdateStateInformational
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSInteger, SPUInformationalUpdateAlertChoice) {
|
||||
SPUDismissInformationalNoticeChoice,
|
||||
SPUSkipThisInformationalVersionChoice
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSUInteger, SPUInstallUpdateStatus) {
|
||||
SPUInstallUpdateNow,
|
||||
SPUInstallAndRelaunchUpdateNow,
|
||||
SPUDismissUpdateInstallation
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSInteger, SPUUpdateAlertChoice) {
|
||||
SPUInstallUpdateChoice,
|
||||
SPUInstallLaterChoice,
|
||||
SPUSkipThisVersionChoice
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUInformationalUpdateAlertChoice) {
|
||||
SPUDismissInformationalNoticeChoice,
|
||||
SPUSkipThisInformationalVersionChoice
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) {
|
||||
SPUUserInitiatedCheckDone,
|
||||
|
||||
Vendored
+130
-57
@@ -108,77 +108,150 @@
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem preventsAutoupdate:(BOOL)preventsAutoupdate
|
||||
{
|
||||
id <SPUUpdaterDelegate> updaterDelegate = self.updaterDelegate;
|
||||
|
||||
if (updateItem.isInformationOnlyUpdate) {
|
||||
assert(!self.resumingDownloadedUpdate);
|
||||
assert(!self.resumingInstallingUpdate);
|
||||
if ([self.userDriver respondsToSelector:@selector(showUpdateFoundWithAppcastItem:userInitiated:state:reply:)]) {
|
||||
SPUUserUpdateState state;
|
||||
if (updateItem.isInformationOnlyUpdate) {
|
||||
state = SPUUserUpdateStateInformational;
|
||||
} else if (self.resumingDownloadedUpdate) {
|
||||
state = SPUUserUpdateStateDownloaded;
|
||||
} else if (self.resumingInstallingUpdate) {
|
||||
state = SPUUserUpdateStateInstalling;
|
||||
} else {
|
||||
state = SPUUserUpdateStateNotDownloaded;
|
||||
}
|
||||
|
||||
[self.userDriver showInformationalUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInformationalUpdateAlertChoice choice) {
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated state:state reply:^(SPUUserUpdateChoice userChoice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
switch (choice) {
|
||||
case SPUSkipThisInformationalVersionChoice:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUDismissInformationalNoticeChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
|
||||
// Rule out invalid choices
|
||||
SPUUserUpdateChoice validatedChoice;
|
||||
if ((state == SPUUserUpdateStateInstalling && userChoice == SPUUserUpdateChoiceSkip) || (state == SPUUserUpdateStateInformational && userChoice == SPUUserUpdateChoiceInstall)) {
|
||||
validatedChoice = SPUUserUpdateChoiceDismiss;
|
||||
} else {
|
||||
validatedChoice = userChoice;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else if (self.resumingDownloadedUpdate) {
|
||||
[self.userDriver showDownloadedUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
[self.coreDriver extractDownloadedUpdate];
|
||||
|
||||
switch (validatedChoice) {
|
||||
case SPUUserUpdateChoiceInstall:
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
[self.coreDriver extractDownloadedUpdate];
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem inBackground:NO];
|
||||
break;
|
||||
case SPUUserUpdateStateInformational:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
[self.coreDriver clearDownloadedUpdate];
|
||||
case SPUUserUpdateChoiceSkip:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUInstallLaterChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else if (!self.resumingInstallingUpdate) {
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem inBackground:NO];
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUInstallLaterChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
|
||||
break;
|
||||
case SPUUserUpdateChoiceDismiss:
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
case SPUUserUpdateStateInformational:
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else {
|
||||
[self.userDriver showResumableUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInstallUpdateStatus choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
});
|
||||
}];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
if (updateItem.isInformationOnlyUpdate) {
|
||||
assert(!self.resumingDownloadedUpdate);
|
||||
assert(!self.resumingInstallingUpdate);
|
||||
|
||||
[self.userDriver showInformationalUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInformationalUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
switch (choice) {
|
||||
case SPUSkipThisInformationalVersionChoice:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUDismissInformationalNoticeChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else if (self.resumingDownloadedUpdate) {
|
||||
[self.userDriver showDownloadedUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
[self.coreDriver extractDownloadedUpdate];
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
[self.coreDriver clearDownloadedUpdate];
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUInstallLaterChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else if (!self.resumingInstallingUpdate) {
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem inBackground:NO];
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
// Fall through
|
||||
case SPUInstallLaterChoice:
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
} else {
|
||||
[self.userDriver showResumableUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUserUpdateChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
});
|
||||
}];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) {
|
||||
@@ -257,9 +330,9 @@
|
||||
- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)__unused willInstallSilently
|
||||
{
|
||||
if (!willInstallImmediately) {
|
||||
[self.userDriver showReadyToInstallAndRelaunch:^(SPUInstallUpdateStatus installUpdateStatus) {
|
||||
[self.userDriver showReadyToInstallAndRelaunch:^(SPUUserUpdateChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.coreDriver finishInstallationWithResponse:installUpdateStatus displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
Vendored
+44
-63
@@ -68,68 +68,34 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
- (void)dismissUserInitiatedUpdateCheck;
|
||||
|
||||
/*!
|
||||
* Show the user a new update is found and can be downloaded and installed
|
||||
* Show the user a new update is found.
|
||||
*
|
||||
* Let the user know a new update is found and ask them what they want to do.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUInstallUpdateChoice begins downloading and installing the new update.
|
||||
*
|
||||
* A reply of SPUInstallLaterChoice reminds the user later of the update, which can act as a "do nothing" option.
|
||||
*
|
||||
* A reply of SPUSkipThisVersionChoice skips this particular version and won't bother the user again,
|
||||
* unless they initiate an update check themselves.
|
||||
*/
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user a new update has been downloaded and can be installed
|
||||
*
|
||||
* This method behaves just like -showUpdateFoundWithAppcastItem:reply: except the update has already been downloaded.
|
||||
*/
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user an update that has started installing can be resumed and installed immediately
|
||||
*
|
||||
* Let the user know an update that has already been downloaded and started installing can be resumed.
|
||||
* Note at this point the update cannot be canceled.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUInstallAndRelaunchUpdateNow installs the update immediately and relaunches the new update.
|
||||
* Note: the application is not relaunched if it was not running before installing the update.
|
||||
* A reply of SPUInstallUpdateNow installs the update immediately but does not relaunch the new update.
|
||||
* A reply of SPUDismissUpdateInstallation dismisses the update installation. Note the update will attempt to finish installation
|
||||
* after the application terminates.
|
||||
*/
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply;
|
||||
|
||||
/*!
|
||||
* Show the user a new informational only update has been found
|
||||
*
|
||||
* Let the user know a new informational update is found and ask them what they want to do.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update.
|
||||
* The infoURL property for the appcastItem may be of interest.
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUDismissInformationalNoticeChoice dismisses this notice.
|
||||
* An implementor may decide to invoke another action before dismissing the notice.
|
||||
* @param state The current state of the update.
|
||||
* SPUUserUpdateStateNotDownloaded - Update has not been downloaded yet.
|
||||
* SPUUserUpdateStateDownloaded - Update has already been downloaded but not started installing yet.
|
||||
* SPUUserUpdateStateInstalling - Update has been downloaded and already started installing.
|
||||
* SPUUserUpdateStateInformational - Update is only informational and has no download. You can direct the user to the the infoURL property of the appcastItem in their web browser. The informationOnlyUpdate property of the appcastItem will be YES.
|
||||
*
|
||||
* A reply of SPUSkipThisInformationalVersionChoice skips this particular version and won't bother the user again,
|
||||
* unless they initiate an update check themselves.
|
||||
* Additionally, you may want to check the criticalUpdate property of the appcastItem to let the user know if the update is critical.
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUUserUpdateChoiceInstall begins or resumes downloading or installing the update.
|
||||
* If the state is SPUUserUpdateStateInstalling, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch").
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceDismiss dismisses the update for the time being. The user may be reminded of the update at a later point.
|
||||
* If the state is SPUUserUpdateStateDownloaded, the downloaded update is kept upon dismissing until the next time an update is shown to the user.
|
||||
* If the state is SPUUserUpdateStateInstalling, the installing update is also preserved upon dismissing. In this state however, the update will still be installed after the application is terminated.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceSkip skips this particular version and won't notify the user again, unless they initiate an update check themselves.
|
||||
* If the state is SPUUserUpdateStateInstalling, the update cannot be skipped, only dismissed or installed.
|
||||
*/
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply;
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user the release notes for the new update
|
||||
@@ -220,19 +186,20 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
- (void)showExtractionReceivedProgress:(double)progress;
|
||||
|
||||
/*!
|
||||
* Show the user that the update is ready to install
|
||||
* Show the user that the update is ready to install & relaunch
|
||||
*
|
||||
* Let the user know that the update is ready and ask them whether they want to install or not.
|
||||
* Note if the target application is already terminated and an update can be performed silently, this method may not be invoked.
|
||||
* Let the user know that the update is ready to install and relaunch, and ask them whether they want to proceed.
|
||||
* Note if the target application has already terminated, this method may not be invoked.
|
||||
*
|
||||
* @param installUpdateHandler
|
||||
* A reply of SPUInstallAndRelaunchUpdateNow installs the update immediately and relaunches the new update.
|
||||
* Note: the application is not relaunched if it was not running before installing the update.
|
||||
* A reply of SPUInstallUpdateNow installes the update immediately but does not relaunch the new update.
|
||||
* A reply of SPUDismissUpdateInstallation dismisses the update installation. Note the update may still be installed after
|
||||
* the application terminates, however there is not a strong guarantee that this will happen.
|
||||
* @param reply
|
||||
* A reply of SPUUserUpdateChoiceInstall installs the update and relaunches the new update immediately.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceDismiss dismisses the update installation for the time being. Note the update may still be installed automatically after
|
||||
* the application terminates.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceSkip acts the same as dismissing. This update which has started installing cannot be skipped.
|
||||
*/
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler;
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user that the update is installing
|
||||
@@ -282,6 +249,10 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
@optional
|
||||
|
||||
// Clients should move to non-deprecated methods
|
||||
// Deprecated methods are only (temporarily) kept around for binary compatibility reasons
|
||||
#if DEBUG
|
||||
|
||||
- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion __deprecated_msg("Implement -showUserInitiatedUpdateCheckWithCancellation: instead");
|
||||
|
||||
- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion __deprecated_msg("Implement -showDownloadInitiatedWithCancellation: instead");
|
||||
@@ -290,6 +261,16 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateInstalledAndRelaunched:acknowledgement: instead");
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply __deprecated_msg("Implement -showUpdateFoundWithAppcastItem:userInitiated:state:reply: instead");
|
||||
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply __deprecated_msg("Implement -showUpdateFoundWithAppcastItem:userInitiated:state:reply: instead");
|
||||
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUserUpdateChoice))reply __deprecated_msg("Implement -showUpdateFoundWithAppcastItem:userInitiated:state:reply: instead");
|
||||
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply __deprecated_msg("Implement -showUpdateFoundWithAppcastItem:userInitiated:state:reply: instead");
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+1
-5
@@ -20,11 +20,7 @@
|
||||
|
||||
@property (nonatomic, weak, readonly) id <SUVersionDisplay> versionDisplayer;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item alreadyDownloaded:(BOOL)alreadyDownloaded host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUpdateAlertChoice))block;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer resumableCompletionBlock:(void (^)(SPUInstallUpdateStatus))block;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer informationalCompletionBlock:(void (^)(SPUInformationalUpdateAlertChoice))block;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block;
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
- (void)showReleaseNotesFailedToDownload;
|
||||
|
||||
Vendored
+17
-74
@@ -33,12 +33,10 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
@interface SUUpdateAlert () <NSTouchBarDelegate>
|
||||
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (nonatomic) BOOL alreadyDownloaded;
|
||||
@property (strong) SUHost *host;
|
||||
@property (nonatomic) BOOL allowsAutomaticUpdates;
|
||||
@property (nonatomic, copy, nullable) void(^completionBlock)(SPUUpdateAlertChoice);
|
||||
@property (nonatomic, copy, nullable) void(^resumableCompletionBlock)(SPUInstallUpdateStatus);
|
||||
@property (nonatomic, copy, nullable) void(^informationalCompletionBlock)(SPUInformationalUpdateAlertChoice);
|
||||
@property (nonatomic, copy, nullable) void(^completionBlock)(SPUUserUpdateChoice);
|
||||
@property (nonatomic) SPUUserUpdateState state;
|
||||
|
||||
@property (strong) NSProgressIndicator *releaseNotesSpinner;
|
||||
|
||||
@@ -60,9 +58,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
@implementation SUUpdateAlert
|
||||
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize alreadyDownloaded = _alreadyDownloaded;
|
||||
@synthesize resumableCompletionBlock = _resumableCompletionBlock;
|
||||
@synthesize informationalCompletionBlock = _informationalCompletionBlock;
|
||||
@synthesize state = _state;
|
||||
@synthesize versionDisplayer;
|
||||
|
||||
@synthesize updateItem;
|
||||
@@ -84,7 +80,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@synthesize webView = _webView;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdateAlert"];
|
||||
if (self != nil) {
|
||||
@@ -92,6 +88,9 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
updateItem = item;
|
||||
versionDisplayer = aVersionDisplayer;
|
||||
|
||||
_state = state;
|
||||
_completionBlock = [block copy];
|
||||
|
||||
SPUUpdaterSettings *updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:host.bundle];
|
||||
_allowsAutomaticUpdates = updaterSettings.allowsAutomaticUpdates && !item.isInformationOnlyUpdate;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
@@ -99,45 +98,13 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item alreadyDownloaded:(BOOL)alreadyDownloaded host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUpdateAlertChoice))block
|
||||
{
|
||||
self = [self initWithAppcastItem:item host:aHost versionDisplayer:aVersionDisplayer];
|
||||
if (self != nil)
|
||||
{
|
||||
_completionBlock = [block copy];
|
||||
_alreadyDownloaded = alreadyDownloaded;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer resumableCompletionBlock:(void (^)(SPUInstallUpdateStatus))block
|
||||
{
|
||||
self = [self initWithAppcastItem:item host:aHost versionDisplayer:aVersionDisplayer];
|
||||
if (self != nil)
|
||||
{
|
||||
_resumableCompletionBlock = [block copy];
|
||||
_alreadyDownloaded = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer informationalCompletionBlock:(void (^)(SPUInformationalUpdateAlertChoice))block
|
||||
{
|
||||
self = [self initWithAppcastItem:item host:aHost versionDisplayer:aVersionDisplayer];
|
||||
if (self != nil)
|
||||
{
|
||||
_informationalCompletionBlock = [block copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)disableKeyboardShortcutForInstallButton {
|
||||
self.installButton.keyEquivalent = @"";
|
||||
}
|
||||
|
||||
- (void)endWithSelection:(SPUUpdateAlertChoice)choice
|
||||
- (void)endWithSelection:(SPUUserUpdateChoice)choice
|
||||
{
|
||||
[self.webView stopLoading];
|
||||
[self.webView.view removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
|
||||
@@ -146,52 +113,29 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
if (self.completionBlock != nil) {
|
||||
self.completionBlock(choice);
|
||||
self.completionBlock = nil;
|
||||
} else if (self.resumableCompletionBlock != nil) {
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
self.resumableCompletionBlock(SPUInstallAndRelaunchUpdateNow);
|
||||
break;
|
||||
case SPUInstallLaterChoice:
|
||||
self.resumableCompletionBlock(SPUDismissUpdateInstallation);
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
abort();
|
||||
}
|
||||
self.resumableCompletionBlock = nil;
|
||||
} else if (self.informationalCompletionBlock != nil) {
|
||||
switch (choice) {
|
||||
case SPUInstallLaterChoice:
|
||||
self.informationalCompletionBlock(SPUDismissInformationalNoticeChoice);
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
self.informationalCompletionBlock(SPUSkipThisInformationalVersionChoice);
|
||||
break;
|
||||
case SPUInstallUpdateChoice:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)installUpdate:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SPUInstallUpdateChoice];
|
||||
[self endWithSelection:SPUUserUpdateChoiceInstall];
|
||||
}
|
||||
|
||||
- (IBAction)openInfoURL:(id)__unused sender
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:self.updateItem.infoURL];
|
||||
|
||||
[self endWithSelection:SPUInstallLaterChoice];
|
||||
[self endWithSelection:SPUUserUpdateChoiceDismiss];
|
||||
}
|
||||
|
||||
- (IBAction)skipThisVersion:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SPUSkipThisVersionChoice];
|
||||
[self endWithSelection:SPUUserUpdateChoiceSkip];
|
||||
}
|
||||
|
||||
- (IBAction)remindMeLater:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SPUInstallLaterChoice];
|
||||
[self endWithSelection:SPUUserUpdateChoiceDismiss];
|
||||
}
|
||||
|
||||
- (void)displayReleaseNotes
|
||||
@@ -407,8 +351,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
}
|
||||
}
|
||||
|
||||
BOOL startedInstalling = (self.resumableCompletionBlock != nil);
|
||||
if (startedInstalling) {
|
||||
if (self.state == SPUUserUpdateStateInstalling) {
|
||||
// An already downloaded & resumable update can't be skipped
|
||||
self.skipButton.hidden = YES;
|
||||
|
||||
@@ -434,7 +377,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
- (BOOL)windowShouldClose:(NSNotification *) __unused note
|
||||
{
|
||||
[self endWithSelection:SPUInstallLaterChoice];
|
||||
[self endWithSelection:SPUUserUpdateChoiceDismiss];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -449,7 +392,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
|
||||
}
|
||||
else if (self.alreadyDownloaded)
|
||||
else if (self.state == SPUUserUpdateStateDownloaded || self.state == SPUUserUpdateStateInstalling)
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]];
|
||||
}
|
||||
@@ -477,13 +420,13 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
if (self.updateItem.isInformationOnlyUpdate) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?", @"Description text for SUUpdateAlert when the update informational with no download."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else if ([self.updateItem isCriticalUpdate]) {
|
||||
if (!self.alreadyDownloaded) {
|
||||
if (self.state == SPUUserUpdateStateNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. This is an important update; would you like to download it now?", @"Description text for SUUpdateAlert when the critical update is downloadable."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the critical update has already been downloaded and ready to install."), self.host.name, updateItemVersion];
|
||||
}
|
||||
} else {
|
||||
if (!self.alreadyDownloaded) {
|
||||
if (self.state == SPUUserUpdateStateNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", @"Description text for SUUpdateAlert when the update is downloadable."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the update has already been downloaded and ready to install."), self.host.name, updateItemVersion];
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
@interface SUInstallUpdateViewController : NSViewController
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUpdateAlertChoice))reply;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
- (void)showReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
@property (nonatomic) IBOutlet NSTextView *textView;
|
||||
@property (nonatomic, readonly) SUAppcastItem *appcastItem;
|
||||
@property (nonatomic, nullable) NSAttributedString *preloadedReleaseNotes;
|
||||
@property (nonatomic, copy) void (^reply)(SPUUpdateAlertChoice);
|
||||
@property (nonatomic, copy) void (^reply)(SPUUserUpdateChoice);
|
||||
@property (nonatomic, readonly) BOOL skippable;
|
||||
|
||||
@end
|
||||
@@ -28,7 +28,7 @@
|
||||
@synthesize reply = _reply;
|
||||
@synthesize skippable = _skippable;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
self = [super initWithNibName:@"SUInstallUpdateViewController" bundle:nil];
|
||||
if (self != nil) {
|
||||
@@ -109,7 +109,7 @@
|
||||
- (IBAction)installUpdate:(id)__unused sender
|
||||
{
|
||||
if (self.reply != nil) {
|
||||
self.reply(SPUInstallUpdateChoice);
|
||||
self.reply(SPUUserUpdateChoiceInstall);
|
||||
self.reply = nil;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@
|
||||
- (IBAction)installUpdateLater:(id)__unused sender
|
||||
{
|
||||
if (self.reply != nil) {
|
||||
self.reply(SPUInstallLaterChoice);
|
||||
self.reply(SPUUserUpdateChoiceDismiss);
|
||||
self.reply = nil;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@
|
||||
- (IBAction)skipUpdate:(id)__unused sender
|
||||
{
|
||||
if (self.reply != nil) {
|
||||
self.reply(SPUSkipThisVersionChoice);
|
||||
self.reply(SPUUserUpdateChoiceSkip);
|
||||
self.reply = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
#pragma mark Update Found
|
||||
|
||||
- (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
- (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
NSPopover *popover = [[NSPopover alloc] init];
|
||||
popover.behavior = NSPopoverBehaviorTransient;
|
||||
@@ -121,7 +121,7 @@
|
||||
__weak SUPopUpTitlebarUserDriver *weakSelf = self;
|
||||
__block NSButton *actionButton = nil;
|
||||
|
||||
SUInstallUpdateViewController *viewController = [[SUInstallUpdateViewController alloc] initWithAppcastItem:appcastItem skippable:skippable reply:^(SPUUpdateAlertChoice choice) {
|
||||
SUInstallUpdateViewController *viewController = [[SUInstallUpdateViewController alloc] initWithAppcastItem:appcastItem skippable:skippable reply:^(SPUUserUpdateChoice choice) {
|
||||
reply(choice);
|
||||
|
||||
[popover close];
|
||||
@@ -139,38 +139,24 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:YES reply:reply];
|
||||
}
|
||||
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:YES reply:reply];
|
||||
}
|
||||
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:NO reply:^(SPUUpdateAlertChoice choice) {
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
reply(SPUInstallAndRelaunchUpdateNow);
|
||||
break;
|
||||
case SPUInstallLaterChoice:
|
||||
reply(SPUDismissUpdateInstallation);
|
||||
break;
|
||||
case SPUSkipThisVersionChoice:
|
||||
abort();
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply
|
||||
{
|
||||
// Todo: show user interface for this
|
||||
NSLog(@"Found info URL: %@", appcastItem.infoURL);
|
||||
|
||||
reply(SPUDismissInformationalNoticeChoice);
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateInformational:
|
||||
// Todo: show user interface for this
|
||||
NSLog(@"Found info URL: %@", appcastItem.infoURL);
|
||||
|
||||
reply(SPUUserUpdateChoiceDismiss);
|
||||
|
||||
break;
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:YES reply:reply];
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:YES reply:reply];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
@@ -184,10 +170,10 @@
|
||||
|
||||
#pragma mark Install & Relaunch Update
|
||||
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))installUpdateHandler
|
||||
{
|
||||
[self addUpdateButtonWithTitle:@"Install & Relaunch" action:^(NSButton *__unused button) {
|
||||
installUpdateHandler(SPUInstallAndRelaunchUpdateNow);
|
||||
installUpdateHandler(SPUUserUpdateChoiceInstall);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -105,39 +105,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"new"];
|
||||
reply(SPUInstallUpdateChoice);
|
||||
}
|
||||
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"downloaded"];
|
||||
reply(SPUInstallUpdateChoice);
|
||||
}
|
||||
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply
|
||||
{
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"resumable"];
|
||||
|
||||
if (self.deferInstallation) {
|
||||
if (self.verbose) {
|
||||
fprintf(stderr, "Deferring Installation.\n");
|
||||
}
|
||||
reply(SPUDismissUpdateInstallation);
|
||||
} else {
|
||||
reply(SPUInstallAndRelaunchUpdateNow);
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"new"];
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
break;
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"downloaded"];
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
if (self.deferInstallation) {
|
||||
if (self.verbose) {
|
||||
fprintf(stderr, "Deferring Installation.\n");
|
||||
}
|
||||
reply(SPUUserUpdateChoiceDismiss);
|
||||
} else {
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
}
|
||||
break;
|
||||
case SPUUserUpdateStateInformational:
|
||||
fprintf(stderr, "Found information for new update: %s\n", appcastItem.infoURL.absoluteString.UTF8String);
|
||||
reply(SPUUserUpdateChoiceDismiss);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply
|
||||
{
|
||||
fprintf(stderr, "Found information for new update: %s\n", appcastItem.infoURL.absoluteString.UTF8String);
|
||||
|
||||
reply(SPUDismissInformationalNoticeChoice);
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
{
|
||||
if (self.verbose) {
|
||||
@@ -225,15 +220,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))installUpdateHandler
|
||||
{
|
||||
if (self.deferInstallation) {
|
||||
if (self.verbose) {
|
||||
fprintf(stderr, "Deferring Installation.\n");
|
||||
}
|
||||
installUpdateHandler(SPUDismissUpdateInstallation);
|
||||
installUpdateHandler(SPUUserUpdateChoiceDismiss);
|
||||
} else {
|
||||
installUpdateHandler(SPUInstallAndRelaunchUpdateNow);
|
||||
installUpdateHandler(SPUUserUpdateChoiceInstall);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user