Compare commits

..
1 Commits
Author SHA1 Message Date
Justin Simpson e9334fec2b Added swift friendly function 2017-02-22 14:49:02 -05:00
6 changed files with 41 additions and 83 deletions

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.14.2"
s.version = "1.14.0"
s.summary = "A software update framework for OS X"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
}
s.platform = :osx, '10.7'
s.source = { :http => "https://s3.amazonaws.com/tunnelbear/sparkle/Sparkle-#{s.version}.tar.bz2" }
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Sparkle.framework'
+15 -9
View File
@@ -43,14 +43,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)showUpdateAlert
{
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate suppressSparkleUI])
{
[self automaticUpdateAlertFinishedWithChoice:SUInstallLaterChoice];
return;
}
// NSLog(@"[Sparkle showUpdateAlert]");
self.interruptible = NO;
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) {
[self automaticUpdateAlertFinishedWithChoice:choice];
@@ -94,11 +86,25 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
}
//For Swift
else if ([updaterDelegate respondsToSelector:@selector(updater: willInstallUpdateOnQuit:immediateInstallationBlock:)])
{
BOOL relaunch = YES;
BOOL showUI = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[invocation invoke];
}];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([self.updateItem isCriticalUpdate])
{
// NSLog(@"[Sparkle update deemed critical]");
[self showUpdateAlert];
}
else
-1
View File
@@ -27,7 +27,6 @@ typedef NS_ENUM(OSStatus, SUError) {
// Download phase errors.
SUTemporaryDirectoryError = 2000,
SUDownloadError = 2001,
SUHostDirectoryNotWritable = 2002,
// Extraction phase errors.
SUUnarchivingError = 3000,
+12 -17
View File
@@ -52,17 +52,15 @@
- (void)didFindValidUpdate
{
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:respondWithChoice:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem respondWithChoice:^(SUDUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice];
}];
return;
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
}
else if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
if (self.automaticallyInstallUpdates) {
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
return;
}
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:choice];
}];
@@ -116,18 +114,15 @@
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
case SUInstallUpdateChoice:
if(![[self.updater delegate] suppressSparkleUI]) {
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];
}
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];
[self downloadUpdate];
break;
case SUOpenInfoURLChoice:
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem releaseNotesURL]];
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem infoURL]];
[self abortUpdate];
break;
+9 -23
View File
@@ -14,13 +14,6 @@
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
typedef NS_ENUM(NSInteger, SUDUpdateAlertChoice) {
SUDInstallUpdateChoice,
SUDRemindMeLaterChoice,
SUDSkipThisVersionChoice,
SUDOpenInfoURLChoice
};
@class SUAppcastItem, SUAppcast;
@protocol SUUpdaterDelegate;
@@ -153,13 +146,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
@protocol SUUpdaterDelegate <NSObject>
@optional
/*!
Suppress sparkle UI. This should prevent any Sparkle UI from popping up.
Updates should be handled by the host.
*/
-(BOOL)suppressSparkleUI;
/*!
Returns whether to allow Sparkle to pop up.
@@ -229,15 +215,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
/*!
Called when a valid update is found by the update driver and provides delegate ability to respond.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param responseBlock The block carrying the users response to update.
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item respondWithChoice:(void (^)(SUDUpdateAlertChoice))responseBlock;
/*!
Called when a valid update is not found.
@@ -368,6 +345,15 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
/*!
Called when an update is scheduled to be silentyl installed on quit. Swift compatible.
\param updater the SUUpdater instance.
\param item The appcast item corresponding to the udpate that is proposed to be installed.
\param restartBlock Can be used to trigger an immediate silent install and relaunch.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)()) restartBlock;
/*!
Calls after an update that was scheduled to be silently installed on quit has been canceled.
+3 -31
View File
@@ -314,30 +314,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// Background update checks should only happen if we have a network connection.
// Wouldn't want to annoy users on dial-up by establishing a connection every
// hour or so:
BOOL canAutomaticallyDownloadUpdates = [self automaticallyDownloadsUpdates];
if (!canAutomaticallyDownloadUpdates)
{
// TB: App is in a non writable directory
if ([self.delegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
NSError *error =
[NSError errorWithDomain:SUSparkleErrorDomain code:SUHostDirectoryNotWritable
userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"Host directory is not writable", nil)}];
[self.delegate updater:nil didAbortWithError:error];
}
return;
}
SUUpdateDriver *theUpdateDriver;
if (canAutomaticallyDownloadUpdates || [self.delegate suppressSparkleUI])
{
theUpdateDriver = [[SUAutomaticUpdateDriver alloc] initWithUpdater:self];
}
else {
theUpdateDriver = [[SUScheduledUpdateDriver alloc] initWithUpdater:self];
}
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
// NSLog(@"[Sparkle driver class: %@]", [theUpdateDriver class]);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver];
});
@@ -365,8 +343,6 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)installUpdatesIfAvailable
{
// NSLog(@"[Sparkle installUpdatesIfAvailable]");
if (self.driver && [self.driver isInterruptible]) {
[self.driver abortUpdate];
}
@@ -480,15 +456,11 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
{
// If the host doesn't allow automatic updates, don't ever let them happen
if (!self.host.allowsAutomaticUpdates) {
// NSLog(@"Host denied automatic updates");
return NO;
}
// Otherwise, automatically downloading updates is allowed. Does the user want it?
BOOL automatic = [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
// NSLog(@"Automatic updates %@", automatic ? @"enabled" : @"disabled");
return automatic;
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
}
- (void)setFeedURL:(NSURL *)feedURL