mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Update SUVersionDisplay to allow including build versions and update information (#2321)
This commit is contained in:
10 files changed
+303
-50
No files matched your search
@@ -360,6 +360,10 @@
|
||||
72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; };
|
||||
72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */; };
|
||||
72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */; };
|
||||
72AEB1D429A1A74E0033883E /* SPUStandardVersionDisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = 72AEB1D229A1A74E0033883E /* SPUStandardVersionDisplay.h */; };
|
||||
72AEB1D529A1A74E0033883E /* SPUStandardVersionDisplay.m in Sources */ = {isa = PBXBuildFile; fileRef = 72AEB1D329A1A74E0033883E /* SPUStandardVersionDisplay.m */; };
|
||||
72AEB1D829A1CB510033883E /* SPUNoUpdateFoundInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 72AEB1D629A1CB510033883E /* SPUNoUpdateFoundInfo.h */; };
|
||||
72AEB1D929A1CB510033883E /* SPUNoUpdateFoundInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72AEB1D729A1CB510033883E /* SPUNoUpdateFoundInfo.m */; };
|
||||
72B3DEC91E23472200457642 /* SPUDownloadedUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B3DEC71E23472200457642 /* SPUDownloadedUpdate.h */; };
|
||||
72B3DECA1E23472200457642 /* SPUDownloadedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B3DEC81E23472200457642 /* SPUDownloadedUpdate.m */; };
|
||||
72B3DECD1E23479000457642 /* SPUInformationalUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B3DECB1E23479000457642 /* SPUInformationalUpdate.h */; };
|
||||
@@ -1342,6 +1346,10 @@
|
||||
72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.bz2; sourceTree = "<group>"; };
|
||||
72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.xz; sourceTree = "<group>"; };
|
||||
72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.dmg; sourceTree = "<group>"; };
|
||||
72AEB1D229A1A74E0033883E /* SPUStandardVersionDisplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUStandardVersionDisplay.h; sourceTree = "<group>"; };
|
||||
72AEB1D329A1A74E0033883E /* SPUStandardVersionDisplay.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUStandardVersionDisplay.m; sourceTree = "<group>"; };
|
||||
72AEB1D629A1CB510033883E /* SPUNoUpdateFoundInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUNoUpdateFoundInfo.h; sourceTree = "<group>"; };
|
||||
72AEB1D729A1CB510033883E /* SPUNoUpdateFoundInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUNoUpdateFoundInfo.m; sourceTree = "<group>"; };
|
||||
72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Sparkle Unit Tests-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
72B09CE91CEA18900052EF9E /* bscommon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bscommon.c; sourceTree = "<group>"; };
|
||||
72B09CEA1CEA18900052EF9E /* bscommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bscommon.h; sourceTree = "<group>"; };
|
||||
@@ -1975,7 +1983,6 @@
|
||||
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
|
||||
723C8A521E2D60DB00C14942 /* SUTouchBarButtonGroup.h */,
|
||||
723C8A531E2D60DB00C14942 /* SUTouchBarButtonGroup.m */,
|
||||
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */,
|
||||
);
|
||||
name = "User Interface";
|
||||
sourceTree = "<group>";
|
||||
@@ -2026,6 +2033,11 @@
|
||||
727F340A2605321D00020E85 /* SULog+NSError.m */,
|
||||
726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */,
|
||||
726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */,
|
||||
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */,
|
||||
72AEB1D229A1A74E0033883E /* SPUStandardVersionDisplay.h */,
|
||||
72AEB1D329A1A74E0033883E /* SPUStandardVersionDisplay.m */,
|
||||
72AEB1D629A1CB510033883E /* SPUNoUpdateFoundInfo.h */,
|
||||
72AEB1D729A1CB510033883E /* SPUNoUpdateFoundInfo.m */,
|
||||
);
|
||||
includeInIndex = 1;
|
||||
name = "Other Sources";
|
||||
@@ -2485,6 +2497,7 @@
|
||||
72B767E21C9CE90A00A07552 /* SPUCoreBasedUpdateDriver.h in Headers */,
|
||||
72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */,
|
||||
72EF30C12675CF38008CE987 /* SPUAppcastItemState.h in Headers */,
|
||||
72AEB1D429A1A74E0033883E /* SPUStandardVersionDisplay.h in Headers */,
|
||||
7229E1BD1C98EFF200CB50D0 /* SPUDownloadDriver.h in Headers */,
|
||||
7267E5FD1D3DD1B700D1BF90 /* SPUResumableUpdate.h in Headers */,
|
||||
7267E5B61D3D8AEE00D1BF90 /* SPUInstallationInfo.h in Headers */,
|
||||
@@ -2521,6 +2534,7 @@
|
||||
72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */,
|
||||
7269E494264798200088C213 /* SPUSkippedUpdate.h in Headers */,
|
||||
723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */,
|
||||
72AEB1D829A1CB510033883E /* SPUNoUpdateFoundInfo.h in Headers */,
|
||||
725CB9571C7120410064365A /* SPUUserDriver.h in Headers */,
|
||||
72B767DE1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.h in Headers */,
|
||||
72F94F581CC44DE1002DEE68 /* SPUXPCServiceInfo.h in Headers */,
|
||||
@@ -3587,6 +3601,7 @@
|
||||
72EF30C02675CF38008CE987 /* SPUAppcastItemStateResolver.m in Sources */,
|
||||
61B5F8EE09C4CE3C00B25A18 /* SPUUpdater.m in Sources */,
|
||||
720E217C1D0D00BF003A311C /* SPUUpdaterCycle.m in Sources */,
|
||||
72AEB1D529A1A74E0033883E /* SPUStandardVersionDisplay.m in Sources */,
|
||||
726E078E1CA891E9001A286B /* SPUUpdaterSettings.m in Sources */,
|
||||
721D588F25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.m in Sources */,
|
||||
72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */,
|
||||
@@ -3614,6 +3629,7 @@
|
||||
7286EE6028CEC84900163C1D /* SUPlainTextReleaseNotesView.m in Sources */,
|
||||
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
|
||||
72B3DECA1E23472200457642 /* SPUDownloadedUpdate.m in Sources */,
|
||||
72AEB1D929A1CB510033883E /* SPUNoUpdateFoundInfo.m in Sources */,
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
|
||||
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */,
|
||||
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
|
||||
|
||||
Vendored
+10
-12
@@ -19,6 +19,9 @@
|
||||
#import "SPUAppcastItemState.h"
|
||||
#import "SUAppcastItem+Private.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SPUStandardVersionDisplay.h"
|
||||
#import "SPUNoUpdateFoundInfo.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -184,10 +187,11 @@
|
||||
{
|
||||
if (!_aborted) {
|
||||
NSString *localizedDescription;
|
||||
NSString *recoverySuggestion;
|
||||
|
||||
#if SPARKLE_COPY_LOCALIZATIONS
|
||||
NSBundle *sparkleBundle = SUSparkleBundle();
|
||||
#else
|
||||
NSBundle *sparkleBundle = nil;
|
||||
#endif
|
||||
|
||||
SPUNoUpdateFoundReason reason;
|
||||
@@ -197,16 +201,12 @@
|
||||
// This means the user is a 'newer than latest' version. give a slight hint to the user instead of wrongly claiming this version is identical to the latest feed version.
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"You’re up-to-date!", SPARKLE_TABLE, sparkleBundle, "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.\n(You are currently running version %@.)", SPARKLE_TABLE, sparkleBundle, nil), [_host name], latestAppcastItem.displayVersionString, [_host displayVersion]];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonOnNewerThanLatestVersion;
|
||||
break;
|
||||
case NSOrderedSame:
|
||||
// No new update is available and we're on the latest
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"You’re up-to-date!", SPARKLE_TABLE, sparkleBundle, "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.", SPARKLE_TABLE, sparkleBundle, nil), [_host name], [_host displayVersion]];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonOnLatestVersion;
|
||||
break;
|
||||
case NSOrderedAscending:
|
||||
@@ -215,21 +215,15 @@
|
||||
if (!latestAppcastItem.minimumOperatingSystemVersionIsOK) {
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"Your macOS version is too old", SPARKLE_TABLE, sparkleBundle, nil);
|
||||
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ is available but your macOS version is too old to install it. At least macOS %3$@ is required.", SPARKLE_TABLE, sparkleBundle, nil), [_host name], latestAppcastItem.displayVersionString, latestAppcastItem.minimumSystemVersion];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonSystemIsTooOld;
|
||||
} else if (!latestAppcastItem.maximumOperatingSystemVersionIsOK) {
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"Your macOS version is too new", SPARKLE_TABLE, sparkleBundle, nil);
|
||||
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ is available but your macOS version is too new for this update. This update only supports up to macOS %3$@.", SPARKLE_TABLE, sparkleBundle, nil), [_host name], latestAppcastItem.displayVersionString, latestAppcastItem.maximumSystemVersion];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonSystemIsTooNew;
|
||||
} else {
|
||||
// We shouldn't realistically get here
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"You’re up-to-date!", SPARKLE_TABLE, sparkleBundle, "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.", SPARKLE_TABLE, sparkleBundle, nil), [_host name], [_host displayVersion]];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonUnknown;
|
||||
}
|
||||
break;
|
||||
@@ -240,11 +234,15 @@
|
||||
// There could be update items on channels the updater is not subscribed to for example. But we can't tell the user about them.
|
||||
// There could also only be update items available for other platforms or none at all.
|
||||
localizedDescription = SULocalizedStringFromTableInBundle(@"You’re up-to-date!", SPARKLE_TABLE, sparkleBundle, "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.", SPARKLE_TABLE, sparkleBundle, nil), [_host name], [_host displayVersion]];
|
||||
|
||||
reason = SPUNoUpdateFoundReasonOnLatestVersion;
|
||||
}
|
||||
|
||||
// We use the standard version displayer here to construct a reason string,
|
||||
// but it's possible for the user driver to override this before displaying if they wish
|
||||
id<SUVersionDisplay> versionDisplayer = [SPUStandardVersionDisplay standardVersionDisplay];
|
||||
NSString *recoverySuggestion = SPUNoUpdateFoundRecoverySuggestion(reason, latestAppcastItem, _host, versionDisplayer, sparkleBundle);
|
||||
|
||||
NSString *recoveryOption = SULocalizedStringFromTableInBundle(@"OK", SPARKLE_TABLE, sparkleBundle, nil);
|
||||
|
||||
NSMutableDictionary *userInfo =
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// SPUNoUpdateFoundInfo.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created on 2/18/23.
|
||||
// Copyright © 2023 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
@class SUAppcastItem;
|
||||
@class SUHost;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSString *SPUNoUpdateFoundRecoverySuggestion(SPUNoUpdateFoundReason reason, SUAppcastItem * _Nullable latestAppcastItem, SUHost *host, id<SUVersionDisplay> versionDisplayer, NSBundle * _Nullable sparkleBundle);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// SPUNoUpdateFoundInfo.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created on 2/18/23.
|
||||
// Copyright © 2023 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUNoUpdateFoundInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUlog.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
NSString *SPUNoUpdateFoundRecoverySuggestion(SPUNoUpdateFoundReason reason, SUAppcastItem *latestAppcastItem, SUHost *host, id<SUVersionDisplay> versionDisplayer, NSBundle *sparkleBundle)
|
||||
{
|
||||
#if !SPARKLE_COPY_LOCALIZATIONS
|
||||
(void)sparkleBundle;
|
||||
#endif
|
||||
|
||||
NSString *hostDisplayVersion;
|
||||
NSString *latestAppcastItemDisplayVersion;
|
||||
|
||||
switch (reason) {
|
||||
case SPUNoUpdateFoundReasonUnknown:
|
||||
case SPUNoUpdateFoundReasonOnLatestVersion:
|
||||
if ([versionDisplayer respondsToSelector:@selector(formatBundleDisplayVersion:withBundleVersion:matchingUpdate:)]) {
|
||||
hostDisplayVersion = [versionDisplayer formatBundleDisplayVersion:host.displayVersion withBundleVersion:host.version matchingUpdate:latestAppcastItem];
|
||||
} else {
|
||||
hostDisplayVersion = host.displayVersion;
|
||||
}
|
||||
|
||||
// This is not later used
|
||||
latestAppcastItemDisplayVersion = nil;
|
||||
break;
|
||||
case SPUNoUpdateFoundReasonOnNewerThanLatestVersion:
|
||||
case SPUNoUpdateFoundReasonSystemIsTooOld:
|
||||
case SPUNoUpdateFoundReasonSystemIsTooNew:
|
||||
assert(latestAppcastItem != nil);
|
||||
|
||||
hostDisplayVersion = host.displayVersion;
|
||||
|
||||
if ([versionDisplayer respondsToSelector:@selector(formatUpdateDisplayVersionFromUpdate:andBundleDisplayVersion:withBundleVersion:)]) {
|
||||
latestAppcastItemDisplayVersion = [versionDisplayer formatUpdateDisplayVersionFromUpdate:latestAppcastItem andBundleDisplayVersion:&hostDisplayVersion withBundleVersion:host.version];
|
||||
} else {
|
||||
// Legacy -formatVersion:andVersion: was never supported for this path so we don't need to call it
|
||||
latestAppcastItemDisplayVersion = latestAppcastItem.displayVersionString;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
NSString *recoverySuggestion;
|
||||
switch (reason) {
|
||||
case SPUNoUpdateFoundReasonUnknown:
|
||||
case SPUNoUpdateFoundReasonOnLatestVersion:
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.", SPARKLE_TABLE, sparkleBundle, nil), host.name, hostDisplayVersion];
|
||||
break;
|
||||
case SPUNoUpdateFoundReasonOnNewerThanLatestVersion:
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is currently the newest version available.\n(You are currently running version %@.)", SPARKLE_TABLE, sparkleBundle, nil), host.name, latestAppcastItemDisplayVersion, hostDisplayVersion];
|
||||
break;
|
||||
case SPUNoUpdateFoundReasonSystemIsTooOld:
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ is available but your macOS version is too old to install it. At least macOS %3$@ is required.", SPARKLE_TABLE, sparkleBundle, nil), host.name, latestAppcastItemDisplayVersion, latestAppcastItem.minimumSystemVersion];
|
||||
break;
|
||||
case SPUNoUpdateFoundReasonSystemIsTooNew:
|
||||
recoverySuggestion = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ is available but your macOS version is too new for this update. This update only supports up to macOS %3$@.", SPARKLE_TABLE, sparkleBundle, nil), host.name, latestAppcastItemDisplayVersion, latestAppcastItem.maximumSystemVersion];
|
||||
break;
|
||||
}
|
||||
return recoverySuggestion;
|
||||
}
|
||||
Vendored
+40
-10
@@ -22,7 +22,9 @@
|
||||
#import "SPUUserUpdateState.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SPUStandardVersionDisplay.h"
|
||||
#import "SULog.h"
|
||||
#import "SPUNoUpdateFoundInfo.h"
|
||||
#include <time.h>
|
||||
#include <mach/mach_time.h>
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
@@ -334,12 +336,14 @@ static const NSTimeInterval SUScheduledUpdateIdleEventLeewayInterval = DEBUG ? 3
|
||||
[self closeCheckingWindow];
|
||||
|
||||
id<SPUStandardUserDriverDelegate> delegate = _delegate;
|
||||
id <SUVersionDisplay> versionDisplayer = nil;
|
||||
id<SUVersionDisplay> customVersionDisplayer = nil;
|
||||
|
||||
if ([delegate respondsToSelector:@selector(standardUserDriverRequestsVersionDisplayer)]) {
|
||||
versionDisplayer = [delegate standardUserDriverRequestsVersionDisplayer];
|
||||
customVersionDisplayer = [delegate standardUserDriverRequestsVersionDisplayer];
|
||||
}
|
||||
|
||||
id<SUVersionDisplay> versionDisplayer = (customVersionDisplayer != nil) ? customVersionDisplayer : [SPUStandardVersionDisplay standardVersionDisplay];
|
||||
|
||||
BOOL needsToObserveUserAttention = [delegate respondsToSelector:@selector(standardUserDriverDidReceiveUserAttentionForUpdate:)];
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
@@ -582,25 +586,51 @@ static const NSTimeInterval SUScheduledUpdateIdleEventLeewayInterval = DEBUG ? 3
|
||||
|
||||
[self closeCheckingWindow];
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithError:error];
|
||||
id <SPUStandardUserDriverDelegate> delegate = _delegate;
|
||||
|
||||
id<SUVersionDisplay> customVersionDisplayer;
|
||||
if ([delegate respondsToSelector:@selector(standardUserDriverRequestsVersionDisplayer)]) {
|
||||
customVersionDisplayer = [delegate standardUserDriverRequestsVersionDisplayer];
|
||||
} else {
|
||||
customVersionDisplayer = nil;
|
||||
}
|
||||
|
||||
SPUNoUpdateFoundReason reason = (SPUNoUpdateFoundReason)[(NSNumber *)error.userInfo[SPUNoUpdateFoundReasonKey] integerValue];
|
||||
|
||||
SUAppcastItem *latestAppcastItem = error.userInfo[SPULatestAppcastItemFoundKey];
|
||||
|
||||
#if SPARKLE_COPY_LOCALIZATIONS
|
||||
NSBundle *sparkleBundle = SUSparkleBundle();
|
||||
#else
|
||||
NSBundle *sparkleBundle = nil;
|
||||
#endif
|
||||
|
||||
// If we have a custom version displayer, then override the recovery suggestion using the
|
||||
// proper version display
|
||||
NSError *presentationError;
|
||||
if (customVersionDisplayer != nil) {
|
||||
NSString *recoverySuggestion = SPUNoUpdateFoundRecoverySuggestion(reason, latestAppcastItem, _host, customVersionDisplayer, sparkleBundle);
|
||||
|
||||
NSMutableDictionary<NSErrorUserInfoKey, id> *userInfo = [error.userInfo mutableCopy];
|
||||
userInfo[NSLocalizedRecoverySuggestionErrorKey] = recoverySuggestion;
|
||||
|
||||
presentationError = [NSError errorWithDomain:error.domain code:error.code userInfo:[userInfo copy]];
|
||||
} else {
|
||||
presentationError = error;
|
||||
}
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithError:presentationError];
|
||||
alert.alertStyle = NSAlertStyleInformational;
|
||||
|
||||
// Can we give more information to the user?
|
||||
SPUNoUpdateFoundReason reason = (SPUNoUpdateFoundReason)[(NSNumber *)error.userInfo[SPUNoUpdateFoundReasonKey] integerValue];
|
||||
|
||||
void (^secondaryAction)(void) = nil;
|
||||
SUAppcastItem *latestAppcastItem = error.userInfo[SPULatestAppcastItemFoundKey];
|
||||
if (latestAppcastItem != nil) {
|
||||
#if SPARKLE_COPY_LOCALIZATIONS
|
||||
NSBundle *sparkleBundle = SUSparkleBundle();
|
||||
#endif
|
||||
switch (reason) {
|
||||
case SPUNoUpdateFoundReasonOnLatestVersion:
|
||||
case SPUNoUpdateFoundReasonOnNewerThanLatestVersion: {
|
||||
// Show the user the past version history if available
|
||||
|
||||
// Check if the delegate allows showing the Version History
|
||||
id <SPUStandardUserDriverDelegate> delegate = _delegate;
|
||||
BOOL shouldShowVersionHistory = (![delegate respondsToSelector:@selector(standardUserDriverShouldShowVersionHistoryForAppcastItem:)] || [delegate standardUserDriverShouldShowVersionHistoryForAppcastItem:latestAppcastItem]);
|
||||
|
||||
if (shouldShowVersionHistory) {
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SPUStandardVersionDisplay.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created on 2/18/23.
|
||||
// Copyright © 2023 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUStandardVersionDisplay : NSObject <SUVersionDisplay>
|
||||
|
||||
+ (instancetype)standardVersionDisplay;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// SPUStandardVersionDisplay.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created on 2/18/23.
|
||||
// Copyright © 2023 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUStandardVersionDisplay.h"
|
||||
#import "SUAppcastItem.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SPUStandardVersionDisplay
|
||||
|
||||
+ (instancetype)standardVersionDisplay
|
||||
{
|
||||
static SPUStandardVersionDisplay *versionDisplay = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
versionDisplay = [[SPUStandardVersionDisplay alloc] init];
|
||||
});
|
||||
return versionDisplay;
|
||||
}
|
||||
|
||||
- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion
|
||||
{
|
||||
NSString *outUpdateDisplayVersion;
|
||||
NSString *outBundleDisplayVersion;
|
||||
|
||||
NSString *updateDisplayVersion = update.displayVersionString;
|
||||
NSString *bundleDisplayVersion = *inOutBundleDisplayVersion;
|
||||
|
||||
NSString *updateVersion = update.versionString;
|
||||
|
||||
// If the display versions are the same, then append the internal versions to differentiate them
|
||||
if ([updateDisplayVersion isEqualToString:bundleDisplayVersion]) {
|
||||
outUpdateDisplayVersion = [updateDisplayVersion stringByAppendingFormat:@" (%@)", updateVersion];
|
||||
outBundleDisplayVersion = [bundleDisplayVersion stringByAppendingFormat:@" (%@)", bundleVersion];
|
||||
} else {
|
||||
outUpdateDisplayVersion = updateDisplayVersion;
|
||||
outBundleDisplayVersion = bundleDisplayVersion;
|
||||
}
|
||||
|
||||
*inOutBundleDisplayVersion = outBundleDisplayVersion;
|
||||
|
||||
return outUpdateDisplayVersion;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+1
-1
@@ -20,7 +20,7 @@
|
||||
@class SUAppcastItem, SPUDownloadData, SUHost;
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUUpdateAlert : NSWindowController
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice, NSRect, BOOL))completionBlock didBecomeKeyBlock:(void (^)(void))didBecomeKeyBlock;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id<SUVersionDisplay>)versionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice, NSRect, BOOL))completionBlock didBecomeKeyBlock:(void (^)(void))didBecomeKeyBlock;
|
||||
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
- (void)showReleaseNotesFailedToDownload;
|
||||
|
||||
Vendored
+17
-17
@@ -44,8 +44,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
NSProgressIndicator *_releaseNotesSpinner;
|
||||
NSBox *_darkBackgroundView;
|
||||
id<SUReleaseNotesView> _releaseNotesView;
|
||||
|
||||
__weak id <SUVersionDisplay> _versionDisplayer;
|
||||
id<SUVersionDisplay> _versionDisplayer;
|
||||
|
||||
IBOutlet NSButton *_installButton;
|
||||
IBOutlet NSButton *_laterButton;
|
||||
@@ -62,13 +61,13 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
BOOL _observingAppearance;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id <SUVersionDisplay>)aVersionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice, NSRect, BOOL))completionBlock didBecomeKeyBlock:(void (^)(void))didBecomeKeyBlock
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id<SUVersionDisplay>)versionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice, NSRect, BOOL))completionBlock didBecomeKeyBlock:(void (^)(void))didBecomeKeyBlock
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdateAlert"];
|
||||
if (self != nil) {
|
||||
_host = aHost;
|
||||
_updateItem = item;
|
||||
_versionDisplayer = aVersionDisplayer;
|
||||
_versionDisplayer = versionDisplayer;
|
||||
|
||||
_state = state;
|
||||
_completionBlock = [completionBlock copy];
|
||||
@@ -463,15 +462,16 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
NSString *updateItemVersion = [_updateItem displayVersionString];
|
||||
NSString *hostVersion = [_host displayVersion];
|
||||
// Display more info if the version strings are the same; useful for betas.
|
||||
id<SUVersionDisplay> versionDisplayer = _versionDisplayer;
|
||||
if (versionDisplayer == nil && [updateItemVersion isEqualToString:hostVersion] ) {
|
||||
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [_updateItem versionString]];
|
||||
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", _host.version];
|
||||
NSString *updateItemDisplayVersion = [_updateItem displayVersionString];
|
||||
NSString *hostDisplayVersion = [_host displayVersion];
|
||||
|
||||
if ([_versionDisplayer respondsToSelector:@selector(formatUpdateDisplayVersionFromUpdate:andBundleDisplayVersion:withBundleVersion:)]) {
|
||||
updateItemDisplayVersion = [_versionDisplayer formatUpdateDisplayVersionFromUpdate:_updateItem andBundleDisplayVersion:&hostDisplayVersion withBundleVersion:_host.version];
|
||||
} else {
|
||||
[versionDisplayer formatVersion:&updateItemVersion andVersion:&hostVersion];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[_versionDisplayer formatVersion:&updateItemDisplayVersion andVersion:&hostDisplayVersion];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
// We display a different summary depending on if it's an "info-only" item, or a "critical update" item, or if we've already downloaded the update and just need to relaunch
|
||||
@@ -482,18 +482,18 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
#endif
|
||||
|
||||
if (_updateItem.informationOnlyUpdate) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. Would you like to learn more about this update on the web?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update informational with no download."), _host.name, updateItemVersion, hostVersion];
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. Would you like to learn more about this update on the web?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update informational with no download."), _host.name, updateItemDisplayVersion, hostDisplayVersion];
|
||||
} else if (_updateItem.criticalUpdate) {
|
||||
if (_state.stage == SPUUserUpdateStageNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. This is an important update; would you like to download it now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the critical update is downloadable."), _host.name, updateItemVersion, hostVersion];
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. This is an important update; would you like to download it now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the critical update is downloadable."), _host.name, updateItemDisplayVersion, hostDisplayVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%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?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the critical update has already been downloaded and ready to install."), _host.name, updateItemVersion];
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%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?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the critical update has already been downloaded and ready to install."), _host.name, updateItemDisplayVersion];
|
||||
}
|
||||
} else {
|
||||
if (_state.stage == SPUUserUpdateStageNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. Would you like to download it now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update is downloadable."), _host.name, updateItemVersion, hostVersion];
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%@ %@ is now available—you have %@. Would you like to download it now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update is downloadable."), _host.name, updateItemDisplayVersion, hostDisplayVersion];
|
||||
} else {
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update has already been downloaded and ready to install."), _host.name, updateItemVersion];
|
||||
finalString = [NSString stringWithFormat:SULocalizedStringFromTableInBundle(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", SPARKLE_TABLE, sparkleBundle, @"Description text for SUUpdateAlert when the update has already been downloaded and ready to install."), _host.name, updateItemDisplayVersion];
|
||||
}
|
||||
}
|
||||
return finalString;
|
||||
|
||||
Vendored
+53
-9
@@ -18,17 +18,61 @@
|
||||
#import <Sparkle/SUExport.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
Applies special display formatting to version numbers.
|
||||
*/
|
||||
SU_EXPORT @protocol SUVersionDisplay
|
||||
@class SUAppcastItem;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Formats two version strings.
|
||||
|
||||
Both versions are provided so that important distinguishing information
|
||||
can be displayed while also leaving out unnecessary/confusing parts.
|
||||
Applies special display formatting to version numbers of the bundle to update and the update before presenting them to the user.
|
||||
*/
|
||||
- (void)formatVersion:(NSString *_Nonnull*_Nonnull)inOutVersionA andVersion:(NSString *_Nonnull*_Nonnull)inOutVersionB;
|
||||
SU_EXPORT @protocol SUVersionDisplay <NSObject>
|
||||
|
||||
/**
|
||||
Formats an update's version string and bundle's version string for display.
|
||||
|
||||
This method is used to format both the display version of the update and the display version of the bundle to update.
|
||||
|
||||
The display versions returned by this method are then used for presenting to the user when a new update is available,
|
||||
or when the user cannot download/install the latest update for a specific reason, or when the user has a newer version
|
||||
installed than the latest known version in the update feed.
|
||||
|
||||
On input, the `update.displayVersionString` and `*inOutBundleDisplayVersion` may be the same, but the
|
||||
`update.versionString` and `bundleVersion` will differ. To differentiate between these display versions, you may
|
||||
choose to return different display version strings for the update and bundle.
|
||||
|
||||
@param update The update to format the update display version from. You can query `update.displayVersionString` and `update.versionString` to retrieve the update's version information.
|
||||
@param inOutBundleDisplayVersion On input, the display version string (or `CFBundleShortVersionString`) of the bundle to update. On output, this is the display version string of the bundle to show to the user.
|
||||
@param bundleVersion The version (or CFBundleVersion) of the bundle to update.
|
||||
@return A new display version string of the `update.displayVersionString` to show to the user.
|
||||
*/
|
||||
- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion;
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
Formats a bundle's version string for display.
|
||||
|
||||
This method is used to format the display version of the bundle.
|
||||
This method may be used when no new update is available and the user is already on the latest known version.
|
||||
In this case, no new update version is shown to the user.
|
||||
|
||||
This method is optional. If it's not implemented, Sparkle will default to using the `bundleDisplayVersion` passed to this method.
|
||||
|
||||
@param bundleDisplayVersion The display version string (or `CFBundleShortVersionString`) of the bundle to update.
|
||||
@param bundleVersion The version (or `CFBundleVersion`) of the bundle to update.
|
||||
@param matchingUpdate The update in the feed that corresponds to the current bundle, or `nil` if no matching update item could be found in the feed.
|
||||
@return A new display version string of the bundle to show to the user.
|
||||
*/
|
||||
- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate;
|
||||
|
||||
/**
|
||||
Formats two version strings.
|
||||
|
||||
Both versions are provided so that important distinguishing information
|
||||
can be displayed while also leaving out unnecessary/confusing parts.
|
||||
*/
|
||||
- (void)formatVersion:(NSString *_Nonnull*_Nonnull)inOutVersionA andVersion:(NSString *_Nonnull*_Nonnull)inOutVersionB __deprecated_msg("Please use -formatUpdateDisplayVersionFromUpdate:andBundleDisplayVersion:withBundleVersion:");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in new issue
Block a user