Compare commits

...
Author SHA1 Message Date
Marcus Ososbase 5064a9e26c 1.14.2 2016-11-01 14:25:00 -04:00
mosobase f6dbebb0e2 Merge pull request #1 from mosobase/ui-suppresion
Patched loophole that allowed Sparkle to present UI even though it wa…
2016-11-01 14:23:01 -04:00
Marcus Ososbase 85478fc2bb Patched loophole that allowed Sparkle to present UI even though it was suppressed
Added some log statements for future debugging if necessary
2016-10-31 15:12:08 -04:00
Marcus Osobase b3ce4141d1 Automatically download update and wait until restart to install 2016-05-05 16:07:51 -04:00
Marcus Osobase 2095b97ae3 Allow delegate to decide how to proceed with new update 2016-05-03 15:56:09 -04:00
Marcus Osobase aae539bc9b Dont show update window 2016-05-03 11:54:36 -04:00
6 changed files with 83 additions and 17 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.0"
s.version = "1.14.2"
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://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source = { :http => "https://s3.amazonaws.com/tunnelbear/sparkle/Sparkle-#{s.version}.tar.bz2" }
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Sparkle.framework'
+9
View File
@@ -43,6 +43,14 @@ 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];
@@ -90,6 +98,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
// 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,6 +27,7 @@ typedef NS_ENUM(OSStatus, SUError) {
// Download phase errors.
SUTemporaryDirectoryError = 2000,
SUDownloadError = 2001,
SUHostDirectoryNotWritable = 2002,
// Extraction phase errors.
SUUnarchivingError = 3000,
+17 -12
View File
@@ -52,15 +52,17 @@
- (void)didFindValidUpdate
{
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
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.automaticallyInstallUpdates) {
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
return;
else if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
}
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:choice];
}];
@@ -114,15 +116,18 @@
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice) {
case SUInstallUpdateChoice:
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];
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 downloadUpdate];
break;
case SUOpenInfoURLChoice:
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem infoURL]];
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem releaseNotesURL]];
[self abortUpdate];
break;
+23
View File
@@ -14,6 +14,13 @@
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
typedef NS_ENUM(NSInteger, SUDUpdateAlertChoice) {
SUDInstallUpdateChoice,
SUDRemindMeLaterChoice,
SUDSkipThisVersionChoice,
SUDOpenInfoURLChoice
};
@class SUAppcastItem, SUAppcast;
@protocol SUUpdaterDelegate;
@@ -146,6 +153,13 @@ 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.
@@ -215,6 +229,15 @@ 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.
+31 -3
View File
@@ -314,8 +314,30 @@ 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:
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
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];
}
// NSLog(@"[Sparkle driver class: %@]", [theUpdateDriver class]);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver];
});
@@ -343,6 +365,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)installUpdatesIfAvailable
{
// NSLog(@"[Sparkle installUpdatesIfAvailable]");
if (self.driver && [self.driver isInterruptible]) {
[self.driver abortUpdate];
}
@@ -456,11 +480,15 @@ 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?
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
BOOL automatic = [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
// NSLog(@"Automatic updates %@", automatic ? @"enabled" : @"disabled");
return automatic;
}
- (void)setFeedURL:(NSURL *)feedURL