mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Show the present update during updater progress too
This includes updater permission request, downloading updates, downloading appcast, installing update, and so on.
This commit is contained in:
1 parent
6b3d2af21a
commit
d9e0265d76
8 files changed
+41
-38
No files matched your search
Vendored
+1
-1
@@ -67,7 +67,7 @@
|
||||
|
||||
- (BOOL)showingUpdate
|
||||
{
|
||||
return self.uiDriver.showingUpdate;
|
||||
return self.showedUpdate;
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error
|
||||
|
||||
Vendored
+15
-7
@@ -93,7 +93,7 @@
|
||||
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
|
||||
if ([NSApp isActive]) {
|
||||
[self.activeUpdateAlert setInstallButtonFocus:userInitiated];
|
||||
[self.activeUpdateAlert.window makeKeyAndOrderFront:self];
|
||||
[self.activeUpdateAlert showWindow:nil];
|
||||
} else {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
{
|
||||
[self.activeUpdateAlert.window makeKeyAndOrderFront:self];
|
||||
[self.activeUpdateAlert showWindow:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
@@ -188,7 +188,13 @@
|
||||
|
||||
- (void)showUpdateInFocus
|
||||
{
|
||||
[self setUpFocusForActiveUpdateAlertWithUserInitiation:YES];
|
||||
if (self.activeUpdateAlert != nil) {
|
||||
[self setUpFocusForActiveUpdateAlertWithUserInitiation:YES];
|
||||
} else if (self.permissionPrompt != nil) {
|
||||
[self.permissionPrompt showWindow:nil];
|
||||
} else if (self.statusController != nil) {
|
||||
[self.statusController showWindow:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Install & Relaunch Update
|
||||
@@ -197,11 +203,13 @@
|
||||
{
|
||||
assert(NSThread.isMainThread);
|
||||
|
||||
[self createAndShowStatusController];
|
||||
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
|
||||
[self.statusController setProgressValue:1.0]; // Fill the bar.
|
||||
[self.statusController setButtonEnabled:YES];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Install and Relaunch", nil) target:self action:@selector(installAndRestart:) isDefault:YES];
|
||||
[[self.statusController window] makeKeyAndOrderFront:self];
|
||||
|
||||
[NSApp requestUserAttention:NSInformationalRequest];
|
||||
|
||||
self.installUpdateHandler = installUpdateHandler;
|
||||
@@ -311,7 +319,7 @@
|
||||
|
||||
#pragma mark Download & Install Updates
|
||||
|
||||
- (void)showStatusController
|
||||
- (void)createAndShowStatusController
|
||||
{
|
||||
if (self.statusController == nil) {
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
@@ -325,7 +333,7 @@
|
||||
|
||||
self.cancellation = cancellation;
|
||||
|
||||
[self showStatusController];
|
||||
[self createAndShowStatusController];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
}
|
||||
@@ -399,7 +407,7 @@
|
||||
|
||||
self.cancellation = nil;
|
||||
|
||||
[self showStatusController];
|
||||
[self createAndShowStatusController];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:nil action:nil isDefault:NO];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
|
||||
Vendored
-2
@@ -41,8 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
@property (nonatomic, readonly) BOOL showingUpdate;
|
||||
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
Vendored
-12
@@ -33,7 +33,6 @@
|
||||
@property (nonatomic) BOOL resumingInstallingUpdate;
|
||||
@property (nonatomic) BOOL resumingDownloadedUpdate;
|
||||
@property (nonatomic) BOOL preventsInstallerInteraction;
|
||||
@property (nonatomic) BOOL showingUpdate;
|
||||
|
||||
@end
|
||||
|
||||
@@ -49,7 +48,6 @@
|
||||
@synthesize resumingInstallingUpdate = _resumingInstallingUpdate;
|
||||
@synthesize resumingDownloadedUpdate = _resumingDownloadedUpdate;
|
||||
@synthesize preventsInstallerInteraction = _preventsInstallerInteraction;
|
||||
@synthesize showingUpdate = _showingUpdate;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate
|
||||
{
|
||||
@@ -117,8 +115,6 @@
|
||||
|
||||
[self.userDriver showInformationalUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInformationalUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.showingUpdate = NO;
|
||||
|
||||
switch (choice) {
|
||||
case SPUSkipThisInformationalVersionChoice:
|
||||
[self.host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
@@ -136,8 +132,6 @@
|
||||
} else if (self.resumingDownloadedUpdate) {
|
||||
[self.userDriver showDownloadedUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.showingUpdate = NO;
|
||||
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
@@ -160,8 +154,6 @@
|
||||
} else if (!self.resumingInstallingUpdate) {
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUUpdateAlertChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.showingUpdate = NO;
|
||||
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SPUInstallUpdateChoice:
|
||||
@@ -183,16 +175,12 @@
|
||||
} else {
|
||||
[self.userDriver showResumableUpdateFoundWithAppcastItem:updateItem userInitiated:self.userInitiated reply:^(SPUInstallUpdateStatus choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.showingUpdate = NO;
|
||||
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
self.showingUpdate = YES;
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) {
|
||||
[self.delegate uiDriverDidShowUpdate];
|
||||
}
|
||||
|
||||
Vendored
+3
-2
@@ -119,7 +119,7 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
/*!
|
||||
A property indicating whether or not updates can be checked by the user.
|
||||
|
||||
An update check can be made by the user when an update session isn't in progress, or when an update is presently being shown.
|
||||
An update check can be made by the user when an update session isn't in progress, or when an update or its progress is being shown to the user.
|
||||
|
||||
This property is suitable to use for menu item validation for seeing if -checkForUpdates can be invoked.
|
||||
|
||||
@@ -131,7 +131,8 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
A property indicating whether or not an update session is in progress.
|
||||
|
||||
An update session is in progress when the appcast is being downloaded, an update is being downloaded,
|
||||
an update is being shown, or the installer is being started. An active session is when Sparkle's fired scheduler is running.
|
||||
an update is being shown, update permission is being requested, or the installer is being started.
|
||||
An active session is when Sparkle's fired scheduler is running.
|
||||
|
||||
Note an update session may be inactive even though Sparkle's installer (ran as a separate process) may be running,
|
||||
or even though the update has been downloaded but the installation has been deferred. In both of these cases, an update session
|
||||
|
||||
Vendored
+10
-2
@@ -56,6 +56,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (nonatomic) BOOL startedUpdater;
|
||||
@property (nonatomic, nullable) id<SPUResumableUpdate> resumableUpdate;
|
||||
@property (nonatomic) BOOL sessionInProgress;
|
||||
@property (nonatomic) BOOL showingPermissionRequest;
|
||||
|
||||
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
|
||||
|
||||
@@ -80,6 +81,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@synthesize startedUpdater = _startedUpdater;
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
@synthesize sessionInProgress = _sessionInProgress;
|
||||
@synthesize showingPermissionRequest = _showingPermissionRequest;
|
||||
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
|
||||
@synthesize loggedATSWarning = _loggedATSWarning;
|
||||
@synthesize loggedDSAWarning = _loggedDSAWarning;
|
||||
@@ -307,11 +309,17 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
SPUUpdatePermissionRequest *updatePermissionRequest = [[SPUUpdatePermissionRequest alloc] initWithSystemProfile:profileInfo];
|
||||
|
||||
self.showingPermissionRequest = YES;
|
||||
self.sessionInProgress = YES;
|
||||
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
[self.userDriver showUpdatePermissionRequest:updatePermissionRequest reply:^(SUUpdatePermissionResponse *response) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.sessionInProgress = NO;
|
||||
strongSelf.showingPermissionRequest = NO;
|
||||
|
||||
[strongSelf updatePermissionRequestFinishedWithResponse:response];
|
||||
// Schedule checks, but make sure we ignore the delayed call from KVO
|
||||
[strongSelf resetUpdateCycle];
|
||||
@@ -358,7 +366,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
- (BOOL)canCheckForUpdates
|
||||
{
|
||||
return self.startedUpdater && (self.driver.showingUpdate || !self.sessionInProgress);
|
||||
return self.startedUpdater && (self.showingPermissionRequest || self.driver.showingUpdate || !self.sessionInProgress);
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately
|
||||
@@ -466,7 +474,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
- (void)checkForUpdates
|
||||
{
|
||||
if (self.driver.showingUpdate) {
|
||||
if (self.showingPermissionRequest || self.driver.showingUpdate) {
|
||||
if ([self.userDriver respondsToSelector:@selector(showUpdateInFocus)]) {
|
||||
[self.userDriver showUpdateInFocus];
|
||||
}
|
||||
|
||||
Vendored
+8
-7
@@ -124,13 +124,6 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user currently presented update in utmost focus
|
||||
*
|
||||
* Sparkle uses this to make its update frontmost again
|
||||
*/
|
||||
- (void)showUpdateInFocus;
|
||||
|
||||
/*!
|
||||
* Show the user the release notes for the new update
|
||||
*
|
||||
@@ -263,6 +256,14 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
* Show the user the current presented update or its progress in utmost focus
|
||||
*
|
||||
* The user wishes to check for updates while the user is being shown update progress.
|
||||
* Bring whatever is on screen to frontmost focus (permission request, update information, downloading or extraction status, choice to install update, etc).
|
||||
*/
|
||||
- (void)showUpdateInFocus;
|
||||
|
||||
/*!
|
||||
* Dismiss the current update installation
|
||||
*
|
||||
|
||||
+4
-5
@@ -18,6 +18,7 @@
|
||||
@property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver;
|
||||
@property (nonatomic, readonly) id<SPUUserDriver> userDriver;
|
||||
@property (nonatomic) BOOL showingUserInitiatedProgress;
|
||||
@property (nonatomic) BOOL showingUpdate;
|
||||
@property (nonatomic) BOOL aborted;
|
||||
|
||||
@end
|
||||
@@ -27,6 +28,7 @@
|
||||
@synthesize uiDriver = _uiDriver;
|
||||
@synthesize userDriver = _userDriver;
|
||||
@synthesize showingUserInitiatedProgress = _showingUserInitiatedProgress;
|
||||
@synthesize showingUpdate = _showingUpdate;
|
||||
@synthesize aborted = _aborted;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
@@ -58,6 +60,8 @@
|
||||
});
|
||||
};
|
||||
|
||||
self.showingUpdate = YES;
|
||||
|
||||
if ([self.userDriver respondsToSelector:@selector(showUserInitiatedUpdateCheckWithCancellation:)]) {
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCancellation:cancelUpdateCheck];
|
||||
} else {
|
||||
@@ -91,11 +95,6 @@
|
||||
[self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
}
|
||||
|
||||
- (BOOL)showingUpdate
|
||||
{
|
||||
return self.uiDriver.showingUpdate;
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
|
||||
{
|
||||
[self abortUpdateWithError:error];
|
||||
|
||||
Reference in new issue
Block a user