mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Pass majorUpdate information to user driver
We unify the user driver method showing the update to take a generic state object now. The current fields of the state object are its current stage, if it's user initiated, and if the update is a major one. We also remove deprecated code paths that were complex to support and will otherwise generate in compile errors if people adopt the new API.
This commit is contained in:
1 parent
a79f6b2a85
commit
d193f2e28b
16 files changed
+246
-326
No files matched your search
@@ -289,7 +289,9 @@
|
||||
7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; };
|
||||
7269E497264798200088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; };
|
||||
7269E4982648D3460088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; };
|
||||
726DF88E1C84277600188804 /* SPUStatusCompletionResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */; };
|
||||
7269E49B2648F7C00088C213 /* SPUUserUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */; };
|
||||
726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUserUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
726E075C1CA3A6D6001A286B /* SPUSecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E075A1CA3A6D6001A286B /* SPUSecureCoding.h */; };
|
||||
726E075D1CA3A6D6001A286B /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; };
|
||||
726E078D1CA891E9001A286B /* SPUUpdaterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E078B1CA891E9001A286B /* SPUUpdaterSettings.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -385,7 +387,7 @@
|
||||
72A5D5F41D692CF50009E5AC /* SparkleCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72A5D59C1D6927730009E5AC /* SparkleCore.framework */; };
|
||||
72A5D5F51D692CFE0009E5AC /* SparkleCore.framework in Copy Sparkle */ = {isa = PBXBuildFile; fileRef = 72A5D59C1D6927730009E5AC /* SparkleCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
72A5D5F81D692F2B0009E5AC /* SUExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 14652F8319A9759F00959E44 /* SUExport.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72A5D5F91D692F4C0009E5AC /* SPUStatusCompletionResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72A5D5F91D692F4C0009E5AC /* SPUUserUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUserUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72A5D5FB1D69312F0009E5AC /* SUBundleIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7214B8801D456A8500CB5CED /* SUBundleIcon.m */; };
|
||||
72A6F98A1C94E2D6005F404C /* SUUpdaterDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A6F9891C94E2D6005F404C /* SUUpdaterDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; };
|
||||
@@ -1251,8 +1253,10 @@
|
||||
7267E5FB1D3DD1B700D1BF90 /* SPUResumableUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUResumableUpdate.h; sourceTree = "<group>"; };
|
||||
7269E492264798200088C213 /* SPUSkippedUpdate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUSkippedUpdate.h; sourceTree = "<group>"; };
|
||||
7269E493264798200088C213 /* SPUSkippedUpdate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUSkippedUpdate.m; sourceTree = "<group>"; };
|
||||
7269E4992648F7C00088C213 /* SPUUserUpdateState.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUUserUpdateState.m; sourceTree = "<group>"; };
|
||||
7269E49C2648FC6C0088C213 /* SPUUserUpdateState+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SPUUserUpdateState+Private.h"; sourceTree = "<group>"; };
|
||||
726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUStatusCompletionResults.h; sourceTree = "<group>"; };
|
||||
726DF88D1C84277500188804 /* SPUUserUpdateState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUserUpdateState.h; sourceTree = "<group>"; };
|
||||
726E075A1CA3A6D6001A286B /* SPUSecureCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPUSecureCoding.h; path = Sparkle/SPUSecureCoding.h; sourceTree = SOURCE_ROOT; };
|
||||
726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPUSecureCoding.m; path = Sparkle/SPUSecureCoding.m; sourceTree = SOURCE_ROOT; };
|
||||
726E07681CA616A4001A286B /* libxar.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxar.tbd; path = usr/lib/libxar.tbd; sourceTree = SDKROOT; };
|
||||
@@ -2144,7 +2148,9 @@
|
||||
725CB9581C7121830064365A /* SPUStandardUserDriver.h */,
|
||||
725CB9591C7121830064365A /* SPUStandardUserDriver.m */,
|
||||
726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */,
|
||||
726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */,
|
||||
726DF88D1C84277500188804 /* SPUUserUpdateState.h */,
|
||||
7269E49C2648FC6C0088C213 /* SPUUserUpdateState+Private.h */,
|
||||
7269E4992648F7C00088C213 /* SPUUserUpdateState.m */,
|
||||
725CB9561C7120410064365A /* SPUUserDriver.h */,
|
||||
);
|
||||
name = "User Driver";
|
||||
@@ -2398,7 +2404,7 @@
|
||||
72B3DECE1E23479000457642 /* SPUInformationalUpdate.h in Headers */,
|
||||
72A5D5EB1D692BD40009E5AC /* SPUDownloadData.h in Headers */,
|
||||
721D588E25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.h in Headers */,
|
||||
72A5D5F91D692F4C0009E5AC /* SPUStatusCompletionResults.h in Headers */,
|
||||
72A5D5F91D692F4C0009E5AC /* SPUUserUpdateState.h in Headers */,
|
||||
72A5D5E71D692BB00009E5AC /* SPUUpdatePermissionRequest.h in Headers */,
|
||||
EA1E286F22B6661D004AA304 /* SUSignatures.h in Headers */,
|
||||
72A5D5E21D692B770009E5AC /* SPUUpdater.h in Headers */,
|
||||
@@ -2439,7 +2445,7 @@
|
||||
7246E0A31C83B685003B4E75 /* SPUStandardUpdaterController.h in Headers */,
|
||||
725CB95A1C7121830064365A /* SPUStandardUserDriver.h in Headers */,
|
||||
726E4A371C89116000C57C6A /* SPUStandardUserDriverDelegate.h in Headers */,
|
||||
726DF88E1C84277600188804 /* SPUStatusCompletionResults.h in Headers */,
|
||||
726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */,
|
||||
72B767DA1C9CD2E400A07552 /* SPUUIBasedUpdateDriver.h in Headers */,
|
||||
7229E1B61C97C91100CB50D0 /* SPUUpdateDriver.h in Headers */,
|
||||
72DBA37D1D60CC34002594A8 /* SPUUpdatePermissionRequest.h in Headers */,
|
||||
@@ -3487,6 +3493,7 @@
|
||||
72A5D5B01D6929F80009E5AC /* SUInstallerConnection.m in Sources */,
|
||||
72A5D5AE1D6929F80009E5AC /* SUInstallerLauncher.m in Sources */,
|
||||
72B3DED01E23479000457642 /* SPUInformationalUpdate.m in Sources */,
|
||||
7269E49B2648F7C00088C213 /* SPUUserUpdateState.m in Sources */,
|
||||
72A5D5B21D6929F80009E5AC /* SUInstallerStatus.m in Sources */,
|
||||
72A5D5C51D6929F80009E5AC /* SULog.m in Sources */,
|
||||
72A5D5C61D6929F80009E5AC /* SUOperatingSystem.m in Sources */,
|
||||
@@ -3589,6 +3596,7 @@
|
||||
72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */,
|
||||
61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */,
|
||||
7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */,
|
||||
7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */,
|
||||
725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */,
|
||||
7214B8821D456A8500CB5CED /* SUBundleIcon.m in Sources */,
|
||||
72DBA37F1D62C23E002594A8 /* SUCodeSigningVerifier.m in Sources */,
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SPUStatusCompletionResults.h"
|
||||
#import "SPUUserUpdateState.h"
|
||||
#import "SPUUpdateDriver.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Vendored
+2
-2
@@ -115,7 +115,7 @@
|
||||
|
||||
#pragma mark Update Found
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
weakSelf.activeUpdateAlert = nil;
|
||||
}];
|
||||
|
||||
[self setUpFocusForActiveUpdateAlertWithUserInitiation:userInitiated];
|
||||
[self setUpFocusForActiveUpdateAlertWithUserInitiation:state.userInitiated];
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData
|
||||
|
||||
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
//
|
||||
// SPUStatusCompletionResults.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/29/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPUStatusCompletionResults_h
|
||||
#define SPUStatusCompletionResults_h
|
||||
|
||||
#if __has_feature(modules)
|
||||
#if __has_warning("-Watimport-in-framework-header")
|
||||
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
|
||||
#endif
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <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
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) {
|
||||
SPUUserInitiatedCheckDone,
|
||||
SPUUserInitiatedCheckCanceled
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) {
|
||||
SPUDownloadUpdateDone,
|
||||
SPUDownloadUpdateCanceled
|
||||
};
|
||||
|
||||
#endif /* SPUStatusCompletionResults_h */
|
||||
Vendored
+86
-175
@@ -18,6 +18,7 @@
|
||||
#import "SPUResumableUpdate.h"
|
||||
#import "SPUDownloadDriver.h"
|
||||
#import "SPUSkippedUpdate.h"
|
||||
#import "SPUUserUpdateState+Private.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -162,175 +163,100 @@
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate
|
||||
{
|
||||
if (self.userInitiated) {
|
||||
[SPUSkippedUpdate clearSkippedUpdatesForHost:self.host];
|
||||
}
|
||||
|
||||
id <SPUUpdaterDelegate> updaterDelegate = self.updaterDelegate;
|
||||
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;
|
||||
}
|
||||
|
||||
if (self.userInitiated) {
|
||||
[SPUSkippedUpdate clearSkippedUpdatesForHost:self.host];
|
||||
}
|
||||
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated state:state reply:^(SPUUserUpdateChoice userChoice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// Rule out invalid choices
|
||||
SPUUserUpdateChoice validatedChoice;
|
||||
if (state == SPUUserUpdateStateInformational && userChoice == SPUUserUpdateChoiceInstall) {
|
||||
validatedChoice = SPUUserUpdateChoiceDismiss;
|
||||
} else {
|
||||
validatedChoice = userChoice;
|
||||
}
|
||||
|
||||
switch (validatedChoice) {
|
||||
case SPUUserUpdateChoiceInstall: {
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
[self.coreDriver extractDownloadedUpdate];
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem inBackground:NO];
|
||||
break;
|
||||
case SPUUserUpdateStateInformational:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateChoiceSkip: {
|
||||
[SPUSkippedUpdate skipUpdate:updateItem host:self.host];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
case SPUUserUpdateStateInformational:
|
||||
// Informational updates can be resumed too, so make sure we check
|
||||
// self.resumingDownloadedUpdate instead of the state we pass to user driver
|
||||
if (self.resumingDownloadedUpdate) {
|
||||
[self.coreDriver clearDownloadedUpdate];
|
||||
}
|
||||
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateChoiceDismiss: {
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
case SPUUserUpdateStateInformational: {
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateStateInstalling: {
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
SPUUserUpdateStage stage;
|
||||
if (updateItem.isInformationOnlyUpdate) {
|
||||
stage = SPUUserUpdateStageInformational;
|
||||
} else if (self.resumingDownloadedUpdate) {
|
||||
stage = SPUUserUpdateStageDownloaded;
|
||||
} else if (self.resumingInstallingUpdate) {
|
||||
stage = SPUUserUpdateStageInstalling;
|
||||
} else {
|
||||
// Legacy path that will be removed eventually
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
if (updateItem.isInformationOnlyUpdate) {
|
||||
assert(!self.resumingDownloadedUpdate);
|
||||
assert(!self.resumingInstallingUpdate);
|
||||
stage = SPUUserUpdateStageNotDownloaded;
|
||||
}
|
||||
|
||||
SPUUserUpdateState *state = [[SPUUserUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated majorUpdate:preventsAutoupdate];
|
||||
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem state:state reply:^(SPUUserUpdateChoice userChoice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[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:
|
||||
// Rule out invalid choices
|
||||
SPUUserUpdateChoice validatedChoice;
|
||||
if (stage == SPUUserUpdateStageInformational && userChoice == SPUUserUpdateChoiceInstall) {
|
||||
validatedChoice = SPUUserUpdateChoiceDismiss;
|
||||
} else {
|
||||
validatedChoice = userChoice;
|
||||
}
|
||||
|
||||
switch (validatedChoice) {
|
||||
case SPUUserUpdateChoiceInstall: {
|
||||
switch (stage) {
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
[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];
|
||||
case SPUUserUpdateStageInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
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:
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem 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];
|
||||
case SPUUserUpdateStageInformational:
|
||||
assert(false);
|
||||
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
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateChoiceSkip: {
|
||||
[SPUSkippedUpdate skipUpdate:updateItem host:self.host];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[self.updaterDelegate updater:self.updater userDidSkipThisVersion:updateItem];
|
||||
}
|
||||
|
||||
switch (stage) {
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
case SPUUserUpdateStageInformational:
|
||||
// Informational updates can be resumed too, so make sure we check
|
||||
// self.resumingDownloadedUpdate instead of the stage we pass to user driver
|
||||
if (self.resumingDownloadedUpdate) {
|
||||
[self.coreDriver clearDownloadedUpdate];
|
||||
}
|
||||
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
|
||||
break;
|
||||
case SPUUserUpdateStageInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateChoiceDismiss: {
|
||||
switch (stage) {
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
case SPUUserUpdateStageInformational: {
|
||||
[self.delegate uiDriverIsRequestingAbortUpdateWithError:nil];
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateStageInstalling: {
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) {
|
||||
[self.delegate uiDriverDidShowUpdate];
|
||||
@@ -365,22 +291,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
if ([self.userDriver respondsToSelector:@selector(showDownloadInitiatedWithCancellation:)]) {
|
||||
[self.userDriver showDownloadInitiatedWithCancellation:cancelDownload];
|
||||
} else {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) {
|
||||
switch (downloadCompletionStatus) {
|
||||
#pragma clang diagnostic pop
|
||||
case SPUDownloadUpdateDone:
|
||||
break;
|
||||
case SPUDownloadUpdateCanceled:
|
||||
cancelDownload();
|
||||
break;
|
||||
}
|
||||
}];
|
||||
}
|
||||
[self.userDriver showDownloadInitiatedWithCancellation:cancelDownload];
|
||||
}
|
||||
|
||||
- (void)downloadDriverDidReceiveExpectedContentLength:(uint64_t)expectedContentLength
|
||||
|
||||
Vendored
+13
-22
@@ -15,7 +15,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import "SPUStatusCompletionResults.h"
|
||||
#import "SPUUserUpdateState.h"
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -60,28 +60,31 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*
|
||||
* @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 state The current state of the update.
|
||||
* The state.stage values are:
|
||||
* 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.
|
||||
* SPUUserUpdateStateInformational - Update is only informational and has no download. You can direct the user to the infoURL property of the appcastItem in their web browser. Use this to check if an update is informational, instead of using the informationOnlyUpdate property of the appcast item.
|
||||
*
|
||||
* state.userInitiated indicates if the update was initiated by the user or if it was automatically scheduled in the background.
|
||||
* state.majorUpdate indicates if the update is a major or paid upgrade.
|
||||
*
|
||||
* 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").
|
||||
* If the state.stage 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 after dismissing until the next time an update is shown to the user.
|
||||
* If the state is SPUUserUpdateStateInstalling, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated.
|
||||
* If the state.stage is SPUUserUpdateStateDownloaded, the downloaded update is kept after dismissing until the next time an update is shown to the user.
|
||||
* If the state.stage is SPUUserUpdateStateInstalling, the installing update is also preserved after dismissing. In this state however, the update will also 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 installation is also canceled when the update is skipped.
|
||||
* If state.majorUpdate is YES, the major update and any minor updates to that major release are skipped.
|
||||
* If the state.stage is SPUUserUpdateStateInstalling, the installation is also canceled when the update is skipped.
|
||||
*/
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user the release notes for the new update
|
||||
@@ -256,24 +259,12 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
@optional
|
||||
|
||||
// Clients should move to non-deprecated methods
|
||||
// Deprecated methods are only (temporarily) kept around for binary compatibility reasons
|
||||
|
||||
- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion __deprecated_msg("Implement -showUserInitiatedUpdateCheckWithCancellation: instead");
|
||||
|
||||
- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion __deprecated_msg("Implement -showDownloadInitiatedWithCancellation: instead");
|
||||
// Deprecated methods are only (temporarily) kept around for compatibility reasons
|
||||
|
||||
- (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead");
|
||||
|
||||
- (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");
|
||||
|
||||
- (void)dismissUserInitiatedUpdateCheck __deprecated_msg("Transition to new UI appropriately when a new update is shown, when no update is found, or when an update error occurs.");;
|
||||
|
||||
@end
|
||||
|
||||
+3
-21
@@ -51,33 +51,15 @@
|
||||
[self abortUpdateWithError:error];
|
||||
} else {
|
||||
self.showingUserInitiatedProgress = YES;
|
||||
self.showingUpdate = YES;
|
||||
|
||||
void (^cancelUpdateCheck)(void) = ^{
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCancellation:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.showingUserInitiatedProgress) {
|
||||
[self abortUpdate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.showingUpdate = YES;
|
||||
|
||||
if ([self.userDriver respondsToSelector:@selector(showUserInitiatedUpdateCheckWithCancellation:)]) {
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCancellation:cancelUpdateCheck];
|
||||
} else {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) {
|
||||
#pragma clang diagnostic pop
|
||||
switch (completionStatus) {
|
||||
case SPUUserInitiatedCheckDone:
|
||||
break;
|
||||
case SPUUserInitiatedCheckCanceled:
|
||||
cancelUpdateCheck();
|
||||
break;
|
||||
}
|
||||
}];
|
||||
}
|
||||
}];
|
||||
|
||||
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO];
|
||||
}
|
||||
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// SPUUserUpdateState+Private.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 5/9/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPUUserUpdateState_Private_h
|
||||
#define SPUUserUpdateState_Private_h
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUUserUpdateState (Private)
|
||||
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpdate:(BOOL)majorUpdate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* SPUUserUpdateState_Private_h */
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// SPUUserUpdateState.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/29/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPUUserUpdateState_h
|
||||
#define SPUUserUpdateState_h
|
||||
|
||||
#if __has_feature(modules)
|
||||
#if __has_warning("-Watimport-in-framework-header")
|
||||
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
|
||||
#endif
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) {
|
||||
SPUUserUpdateChoiceSkip,
|
||||
SPUUserUpdateChoiceInstall,
|
||||
SPUUserUpdateChoiceDismiss,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateStage) {
|
||||
SPUUserUpdateStageNotDownloaded,
|
||||
SPUUserUpdateStageDownloaded,
|
||||
SPUUserUpdateStageInstalling,
|
||||
SPUUserUpdateStageInformational
|
||||
};
|
||||
|
||||
SU_EXPORT @interface SPUUserUpdateState : NSObject
|
||||
|
||||
@property (nonatomic, readonly) SPUUserUpdateStage stage;
|
||||
@property (nonatomic, readonly) BOOL userInitiated;
|
||||
@property (nonatomic, readonly) BOOL majorUpdate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* SPUUserUpdateState_h */
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// SPUUserUpdateState.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 5/9/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUUserUpdateState.h"
|
||||
#import "SPUUserUpdateState+Private.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SPUUserUpdateState
|
||||
|
||||
@synthesize stage = _stage;
|
||||
@synthesize userInitiated = _userInitiated;
|
||||
@synthesize majorUpdate = _majorUpdate;
|
||||
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpdate:(BOOL)majorUpdate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_stage = stage;
|
||||
_userInitiated = userInitiated;
|
||||
_majorUpdate = majorUpdate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+2
-2
@@ -11,7 +11,7 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SPUStatusCompletionResults.h"
|
||||
#import "SPUUserUpdateState.h"
|
||||
|
||||
@protocol SUUpdateAlertDelegate;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
@property (nonatomic, weak, readonly) id <SUVersionDisplay> versionDisplayer;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))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
+6
-6
@@ -36,7 +36,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
@property (strong) SUHost *host;
|
||||
@property (nonatomic) BOOL allowsAutomaticUpdates;
|
||||
@property (nonatomic, copy, nullable) void(^completionBlock)(SPUUserUpdateChoice);
|
||||
@property (nonatomic) SPUUserUpdateState state;
|
||||
@property (nonatomic) SPUUserUpdateState *state;
|
||||
|
||||
@property (strong) NSProgressIndicator *releaseNotesSpinner;
|
||||
|
||||
@@ -80,7 +80,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@synthesize webView = _webView;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice))block
|
||||
- (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) {
|
||||
@@ -362,7 +362,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
}
|
||||
}
|
||||
|
||||
if (self.state == SPUUserUpdateStateInstalling) {
|
||||
if (self.state.stage == SPUUserUpdateStageInstalling) {
|
||||
// We're going to be relaunching pretty instantaneously
|
||||
self.installButton.title = SULocalizedString(@"Install and Relaunch", nil);
|
||||
|
||||
@@ -400,7 +400,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
|
||||
}
|
||||
else if (self.state == SPUUserUpdateStateDownloaded || self.state == SPUUserUpdateStateInstalling)
|
||||
else if (self.state.stage == SPUUserUpdateStageDownloaded || self.state.stage == SPUUserUpdateStageInstalling)
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]];
|
||||
}
|
||||
@@ -428,13 +428,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.state == SPUUserUpdateStateNotDownloaded) {
|
||||
if (self.state.stage == SPUUserUpdateStageNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. This is an important update; would you like to download it now?", @"Description text for SUUpdateAlert when the critical update is downloadable."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the critical update has already been downloaded and ready to install."), self.host.name, updateItemVersion];
|
||||
}
|
||||
} else {
|
||||
if (self.state == SPUUserUpdateStateNotDownloaded) {
|
||||
if (self.state.stage == SPUUserUpdateStageNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", @"Description text for SUUpdateAlert when the update is downloadable."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", @"Description text for SUUpdateAlert when the update has already been downloaded and ready to install."), self.host.name, updateItemVersion];
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
@interface SUInstallUpdateViewController : NSViewController
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
- (void)showReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
@property (nonatomic, readonly) SUAppcastItem *appcastItem;
|
||||
@property (nonatomic, nullable) NSAttributedString *preloadedReleaseNotes;
|
||||
@property (nonatomic, copy) void (^reply)(SPUUserUpdateChoice);
|
||||
@property (nonatomic, readonly) BOOL skippable;
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,14 +25,12 @@
|
||||
@synthesize preloadedReleaseNotes = _preloadedReleaseNotes;
|
||||
@synthesize appcastItem = _appcastItem;
|
||||
@synthesize reply = _reply;
|
||||
@synthesize skippable = _skippable;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
self = [super initWithNibName:@"SUInstallUpdateViewController" bundle:nil];
|
||||
if (self != nil) {
|
||||
_appcastItem = appcastItem;
|
||||
_skippable = skippable;
|
||||
self.reply = reply;
|
||||
}
|
||||
return self;
|
||||
@@ -43,8 +40,6 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.skipUpdatesButton.enabled = self.skippable;
|
||||
|
||||
[[self.textView enclosingScrollView] setDrawsBackground:NO];
|
||||
[self.textView setDrawsBackground:NO];
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
#pragma mark Update Found
|
||||
|
||||
- (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem skippable:(BOOL)skippable reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
- (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
NSPopover *popover = [[NSPopover alloc] init];
|
||||
popover.behavior = NSPopoverBehaviorTransient;
|
||||
@@ -115,7 +115,7 @@
|
||||
__weak SUPopUpTitlebarUserDriver *weakSelf = self;
|
||||
__block NSButton *actionButton = nil;
|
||||
|
||||
SUInstallUpdateViewController *viewController = [[SUInstallUpdateViewController alloc] initWithAppcastItem:appcastItem skippable:skippable reply:^(SPUUserUpdateChoice choice) {
|
||||
SUInstallUpdateViewController *viewController = [[SUInstallUpdateViewController alloc] initWithAppcastItem:appcastItem reply:^(SPUUserUpdateChoice choice) {
|
||||
reply(choice);
|
||||
|
||||
[popover close];
|
||||
@@ -133,10 +133,10 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateInformational:
|
||||
switch (state.stage) {
|
||||
case SPUUserUpdateStageInformational:
|
||||
// Todo: show user interface for this
|
||||
NSLog(@"Found info URL: %@", appcastItem.infoURL);
|
||||
|
||||
@@ -146,12 +146,10 @@
|
||||
reply(SPUUserUpdateChoiceDismiss);
|
||||
|
||||
break;
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:YES reply:reply];
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
[self showUpdateWithAppcastItem:appcastItem skippable:NO reply:reply];
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
case SPUUserUpdateStageInstalling:
|
||||
[self showUpdateWithAppcastItem:appcastItem reply:reply];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,18 +97,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply
|
||||
{
|
||||
switch (state) {
|
||||
case SPUUserUpdateStateNotDownloaded:
|
||||
switch (state.stage) {
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"new"];
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
break;
|
||||
case SPUUserUpdateStateDownloaded:
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
[self showUpdateWithAppcastItem:appcastItem updateAdjective:@"downloaded"];
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
break;
|
||||
case SPUUserUpdateStateInstalling:
|
||||
case SPUUserUpdateStageInstalling:
|
||||
if (self.deferInstallation) {
|
||||
if (self.verbose) {
|
||||
fprintf(stderr, "Deferring Installation.\n");
|
||||
@@ -118,7 +118,7 @@
|
||||
reply(SPUUserUpdateChoiceInstall);
|
||||
}
|
||||
break;
|
||||
case SPUUserUpdateStateInformational:
|
||||
case SPUUserUpdateStageInformational:
|
||||
fprintf(stderr, "Found information for new update: %s\n", appcastItem.infoURL.absoluteString.UTF8String);
|
||||
reply(SPUUserUpdateChoiceDismiss);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user