mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Making Sparkle more XPC friendly
We support NSSecureCoding for SUAppcastItem and SUHost Callbacks from XPC <-> Host app now async to main GCD queue. This is needed for everything to be thread safe. Todo: NSDate parsing sucks and is temporarily disabled. In particular, we're using deprecated methods to read the dates, which don't support NSSecureCoding. The other problem is that the dates are really useless technically and we shouldn't sort by them.
This commit is contained in:
1 parent
a9f1e2d919
commit
1cfbffa74c
10 files changed
+260
-109
No files matched your search
Vendored
+3
-1
@@ -172,7 +172,9 @@
|
||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
||||
NSString *string = node.stringValue;
|
||||
if (string) {
|
||||
NSDate *date = [NSDate dateWithNaturalLanguageString:string];
|
||||
#warning This NSDate method is deprecated and doesn't supporte NSSecureCoding... replace it, don't use the date at all, or change the encode/decoding. sigh
|
||||
//NSDate *date = [NSDate dateWithNaturalLanguageString:string];
|
||||
NSDate *date = nil;
|
||||
if (date)
|
||||
dict[name] = date;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -12,7 +12,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
|
||||
Vendored
+83
@@ -45,6 +45,89 @@
|
||||
@synthesize versionString;
|
||||
@synthesize propertiesDictionary;
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self != nil) {
|
||||
//self.date = [decoder decodeObjectOfClass:[NSDate class] forKey:@"date"];
|
||||
self.deltaUpdates = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSDictionary class], [NSString class]]] forKey:@"deltaUpdates"];
|
||||
self.displayVersionString = [decoder decodeObjectOfClass:[NSString class] forKey:@"displayVersionString"];
|
||||
self.DSASignature = [decoder decodeObjectOfClass:[NSString class] forKey:@"DSASignature"];
|
||||
self.fileURL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"fileURL"];
|
||||
self.infoURL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"infoURL"];
|
||||
self.itemDescription = [decoder decodeObjectOfClass:[NSString class] forKey:@"itemDescription"];
|
||||
self.maximumSystemVersion = [decoder decodeObjectOfClass:[NSString class] forKey:@"maximumSystemVersion"];
|
||||
self.minimumSystemVersion = [decoder decodeObjectOfClass:[NSString class] forKey:@"minimumSystemVersion"];
|
||||
self.releaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"releaseNotesURL"];
|
||||
self.title = [decoder decodeObjectOfClass:[NSString class] forKey:@"title"];
|
||||
self.versionString = [decoder decodeObjectOfClass:[NSString class] forKey:@"versionString"];
|
||||
self.propertiesDictionary = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class], [NSDate class], [NSArray class]]] forKey:@"propertiesDictionary"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||
{
|
||||
// if (self.date != nil) {
|
||||
// [encoder encodeObject:self.date forKey:@"date"];
|
||||
// }
|
||||
|
||||
if (self.deltaUpdates != nil) {
|
||||
[encoder encodeObject:self.deltaUpdates forKey:@"deltaUpdates"];
|
||||
}
|
||||
|
||||
if (self.displayVersionString != nil) {
|
||||
[encoder encodeObject:self.displayVersionString forKey:@"displayVersionString"];
|
||||
}
|
||||
|
||||
if (self.DSASignature != nil) {
|
||||
[encoder encodeObject:self.DSASignature forKey:@"DSASignature"];
|
||||
}
|
||||
|
||||
if (self.fileURL != nil) {
|
||||
[encoder encodeObject:self.fileURL forKey:@"fileURL"];
|
||||
}
|
||||
|
||||
if (self.infoURL != nil) {
|
||||
[encoder encodeObject:self.infoURL forKey:@"infoURL"];
|
||||
}
|
||||
|
||||
if (self.itemDescription != nil) {
|
||||
[encoder encodeObject:self.itemDescription forKey:@"itemDescription"];
|
||||
}
|
||||
|
||||
if (self.maximumSystemVersion != nil) {
|
||||
[encoder encodeObject:self.maximumSystemVersion forKey:@"maximumSystemVersion"];
|
||||
}
|
||||
|
||||
if (self.minimumSystemVersion != nil) {
|
||||
[encoder encodeObject:self.minimumSystemVersion forKey:@"minimumSystemVersion"];
|
||||
}
|
||||
|
||||
if (self.releaseNotesURL != nil) {
|
||||
[encoder encodeObject:self.releaseNotesURL forKey:@"releaseNotesURL"];
|
||||
}
|
||||
|
||||
if (self.title != nil) {
|
||||
[encoder encodeObject:self.title forKey:@"title"];
|
||||
}
|
||||
|
||||
if (self.versionString != nil) {
|
||||
[encoder encodeObject:self.versionString forKey:@"versionString"];
|
||||
}
|
||||
|
||||
if (self.propertiesDictionary != nil) {
|
||||
[encoder encodeObject:self.propertiesDictionary forKey:@"propertiesDictionary"];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
return self.propertiesDictionary[SURSSElementEnclosure][SUAppcastAttributeDeltaFrom] != nil;
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@interface SUHost : NSObject
|
||||
@interface SUHost : NSObject<NSSecureCoding>
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
|
||||
Vendored
+25
@@ -26,6 +26,31 @@
|
||||
@synthesize defaultsDomain;
|
||||
@synthesize usesStandardUserDefaults;
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
NSURL *bundleURL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"bundleURL"];
|
||||
if (bundleURL == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSBundle *aBundle = [NSBundle bundleWithURL:bundleURL];
|
||||
if (aBundle == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [[[self class] alloc] initWithBundle:aBundle];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||
{
|
||||
[encoder encodeObject:self.bundle.bundleURL forKey:@"bundleURL"];
|
||||
}
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
if ((self = [super init]))
|
||||
|
||||
Vendored
+125
-86
@@ -67,32 +67,36 @@
|
||||
|
||||
- (void)requestUpdatePermissionWithSystemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply
|
||||
{
|
||||
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:systemProfile reply:reply];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:systemProfile reply:reply];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem versionDisplayer:(id<SUVersionDisplay>)versionDisplayer reply:(void (^)(SUUpdateAlertChoice))reply
|
||||
{
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
reply(choice);
|
||||
self.updateAlert = nil;
|
||||
}];
|
||||
|
||||
[self.updateAlert setVersionDisplayer:versionDisplayer];
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[[self.updateAlert window] setHidesOnDeactivate:NO];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:appcastItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
reply(choice);
|
||||
self.updateAlert = nil;
|
||||
}];
|
||||
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
|
||||
if ([NSApp isActive])
|
||||
[[self.updateAlert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
[self.updateAlert setVersionDisplayer:versionDisplayer];
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[[self.updateAlert window] setHidesOnDeactivate:NO];
|
||||
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
|
||||
if ([NSApp isActive])
|
||||
[[self.updateAlert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
@@ -103,14 +107,16 @@
|
||||
|
||||
- (void)showExtractionFinishedAndReadyToInstallAndRelaunch:(void (^)(void))installUpdateAndRelaunch
|
||||
{
|
||||
[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.installAndRestart = installUpdateAndRelaunch;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[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.installAndRestart = installUpdateAndRelaunch;
|
||||
});
|
||||
}
|
||||
|
||||
// temporary
|
||||
@@ -124,13 +130,22 @@
|
||||
|
||||
- (void)showUserInitiatedUpdateCheckWithCancelCallback:(void (^)(void))cancelUpdateCheck
|
||||
{
|
||||
self.cancelUpdateCheck = cancelUpdateCheck;
|
||||
|
||||
self.checkingController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[[self.checkingController window] center]; // Force the checking controller to load its window.
|
||||
[self.checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
|
||||
[self.checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[self.checkingController showWindow:self];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.cancelUpdateCheck = cancelUpdateCheck;
|
||||
|
||||
self.checkingController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[[self.checkingController window] center]; // Force the checking controller to load its window.
|
||||
[self.checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
|
||||
[self.checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[self.checkingController showWindow:self];
|
||||
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
if ([self.host isBackgroundApplication])
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// temporary...
|
||||
@@ -144,22 +159,26 @@
|
||||
|
||||
- (void)dismissUserInitiatedUpdateCheck
|
||||
{
|
||||
self.cancelUpdateCheck = nil;
|
||||
|
||||
if (self.checkingController != nil)
|
||||
{
|
||||
[[self.checkingController window] close];
|
||||
self.checkingController = nil;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.cancelUpdateCheck = nil;
|
||||
|
||||
if (self.checkingController != nil)
|
||||
{
|
||||
[[self.checkingController window] close];
|
||||
self.checkingController = nil;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showUpdaterError:(NSError *)error
|
||||
{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"Update Error!", nil);
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
|
||||
[self showAlert:alert];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"Update Error!", nil);
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
|
||||
[self showAlert:alert];
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL)showsUpdateErrorModally
|
||||
@@ -169,11 +188,13 @@
|
||||
|
||||
- (void)showUpdateNotFound
|
||||
{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
[self showAlert:alert];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
[self showAlert:alert];
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL)showsUpdateNotFoundModally
|
||||
@@ -183,22 +204,26 @@
|
||||
|
||||
- (void)showAlert:(NSAlert *)alert
|
||||
{
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([self.host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
[alert setIcon:[self.host icon]];
|
||||
[alert runModal];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([self.host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
[alert setIcon:[self.host icon]];
|
||||
[alert runModal];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))cancelDownload
|
||||
{
|
||||
self.cancelDownload = cancelDownload;
|
||||
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[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];
|
||||
[self.statusController showWindow:self];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.cancelDownload = cancelDownload;
|
||||
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[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];
|
||||
[self.statusController showWindow:self];
|
||||
});
|
||||
}
|
||||
|
||||
// temporary
|
||||
@@ -212,12 +237,16 @@
|
||||
|
||||
- (void)openInfoURLForAppcastItem:(SUAppcastItem *)appcastItem
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[appcastItem infoURL]];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[appcastItem infoURL]];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showDownloadDidReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
[self.statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
});
|
||||
}
|
||||
|
||||
- (NSString *)localizedStringFromByteCount:(long long)value
|
||||
@@ -248,41 +277,51 @@
|
||||
|
||||
- (void)showDownloadDidReceiveDataOfLength:(NSUInteger)length
|
||||
{
|
||||
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
|
||||
if ([self.statusController maxProgressValue] > 0.0)
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue], [self localizedStringFromByteCount:(long long)self.statusController.maxProgressValue]]];
|
||||
else
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue]]];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
|
||||
if ([self.statusController maxProgressValue] > 0.0)
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue], [self localizedStringFromByteCount:(long long)self.statusController.maxProgressValue]]];
|
||||
else
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue]]];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showDownloadFinishedAndStartedExtractingUpdate
|
||||
{
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showExtractionReceivedProgress:(double)progress
|
||||
{
|
||||
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
|
||||
if ([self.statusController maxProgressValue] == 0.0) {
|
||||
[self.statusController setMaxProgressValue:1];
|
||||
}
|
||||
[self.statusController setProgressValue:progress];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
|
||||
if ([self.statusController maxProgressValue] == 0.0) {
|
||||
[self.statusController setMaxProgressValue:1];
|
||||
}
|
||||
[self.statusController setProgressValue:progress];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showInstallingUpdate
|
||||
{
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dismissUpdateInstallation
|
||||
{
|
||||
if (self.statusController)
|
||||
{
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.statusController)
|
||||
{
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+14
-9
@@ -11,7 +11,6 @@
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
@implementation SUUIBasedUpdateDriver
|
||||
@@ -41,7 +40,9 @@
|
||||
}
|
||||
|
||||
[self.updater.userUpdaterDriver showUpdateFoundWithAppcastItem:self.updateItem versionDisplayer:versDisp reply:^(SUUpdateAlertChoice choice) {
|
||||
[self updateAlertFinishedWithChoice:choice];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self updateAlertFinishedWithChoice:choice];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -67,13 +68,15 @@
|
||||
case SUInstallUpdateChoice:
|
||||
{
|
||||
[self.updater.userUpdaterDriver showDownloadInitiatedWithCancelCallback:^{
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(userDidCancelDownload:)]) {
|
||||
[[self.updater delegate] userDidCancelDownload:self.updater];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(userDidCancelDownload:)]) {
|
||||
[[self.updater delegate] userDidCancelDownload:self.updater];
|
||||
}
|
||||
}
|
||||
}
|
||||
[self abortUpdate];
|
||||
[self abortUpdate];
|
||||
});
|
||||
}];
|
||||
|
||||
[self downloadUpdate];
|
||||
@@ -130,7 +133,9 @@
|
||||
}
|
||||
|
||||
[self.updater.userUpdaterDriver showExtractionFinishedAndReadyToInstallAndRelaunch:^{
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -197,7 +197,9 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
}
|
||||
|
||||
[self.userUpdaterDriver requestUpdatePermissionWithSystemProfile:profileInfo reply:^(SUUpdatePermissionPromptResult *result) {
|
||||
[self updatePermissionPromptFinishedWithResult:result];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self updatePermissionPromptFinishedWithResult:result];
|
||||
});
|
||||
}];
|
||||
|
||||
// We start the update checks and register as observer for changes after the prompt finishes
|
||||
|
||||
+4
-9
@@ -31,21 +31,16 @@
|
||||
self.canceled = YES;
|
||||
}
|
||||
|
||||
#warning assign user driver's host in a superclass of this method, possibly the UI driver.. IDK
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[self.updater.userUpdaterDriver showUserInitiatedUpdateCheckWithCancelCallback:^{
|
||||
[self cancelCheckForUpdates:nil];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cancelCheckForUpdates:nil];
|
||||
});
|
||||
}];
|
||||
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
|
||||
#warning Figure out how to deal with this scenario
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
if ([aHost isBackgroundApplication])
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
self.updater.userUpdaterDriver = [[SULoggerUpdateDriver alloc] initWithHost:[[SUHost alloc] initWithBundle:[NSBundle mainBundle]]];
|
||||
self.updater.userUpdaterDriver = [[/* SUSparkleUserUpdaterDriver */ SULoggerUpdateDriver alloc] initWithHost:[[SUHost alloc] initWithBundle:[NSBundle mainBundle]]];
|
||||
}
|
||||
|
||||
- (NSString *)windowNibName
|
||||
|
||||
Reference in new issue
Block a user