From 45e695155258fd84a82dc409113ed9ee0e601e87 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 28 Feb 2016 22:10:58 -0500 Subject: [PATCH] User updater driver is now aware about updates being in progress or not --- Sparkle/SUSparkleUserUpdaterDriver.h | 2 ++ Sparkle/SUSparkleUserUpdaterDriver.m | 14 ++++++++++++++ Sparkle/SUUpdater.m | 3 +++ Sparkle/SUUserUpdaterDriver.h | 2 ++ 4 files changed, 21 insertions(+) diff --git a/Sparkle/SUSparkleUserUpdaterDriver.h b/Sparkle/SUSparkleUserUpdaterDriver.h index 66d08c71..990e556f 100644 --- a/Sparkle/SUSparkleUserUpdaterDriver.h +++ b/Sparkle/SUSparkleUserUpdaterDriver.h @@ -15,6 +15,8 @@ - (instancetype)initWithHost:(SUHost *)host handlesTermination:(BOOL)handlesTermination delegate:(id )delegate; +@property (nonatomic, readonly, getter=isUpdateInProgress) BOOL updateInProgress; + - (NSApplicationTerminateReply)sendApplicationTerminationSignal; @end diff --git a/Sparkle/SUSparkleUserUpdaterDriver.m b/Sparkle/SUSparkleUserUpdaterDriver.m index 1e4e01c5..04e4f3ac 100644 --- a/Sparkle/SUSparkleUserUpdaterDriver.m +++ b/Sparkle/SUSparkleUserUpdaterDriver.m @@ -38,6 +38,8 @@ @property (nonatomic, readonly) SUHost *host; @property (nonatomic, readonly) BOOL handlesTermination; +@property (nonatomic) BOOL updaterInProgress; + @property (nonatomic) NSTimer *checkUpdateTimer; @property (nonatomic, copy) void (^checkForUpdatesReply)(SUUpdateCheckTimerStatus); @@ -61,6 +63,7 @@ @synthesize host = _host; @synthesize handlesTermination = _handlesTermination; @synthesize delegate = _delegate; +@synthesize updaterInProgress = _updaterInProgress; @synthesize checkUpdateTimer = _checkUpdateTimer; @synthesize checkForUpdatesReply = _checkForUpdatesReply; @synthesize checkingController = _checkingController; @@ -85,6 +88,15 @@ return self; } +#pragma mark Is Update Busy? + +- (void)showUpdateInProgress:(BOOL)isUpdateInProgress +{ + dispatch_async(dispatch_get_main_queue(), ^{ + self.updaterInProgress = isUpdateInProgress; + }); +} + #pragma mark Check Updates Timer - (BOOL)isDelegateResponsibleForUpdateChecking @@ -533,6 +545,8 @@ // Make sure everything we call here does not dispatch async to main queue // because we are already on the main queue (and I've been bitten in the past by this before) + self.updaterInProgress = NO; + [self _invalidateUpdateCheckTimer]; [self cancelCheckForUpdates]; diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 3e58428a..b2ce74ce 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -165,6 +165,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification if ([note object] == self.driver && [self.driver finished]) { self.driver = nil; + [self.userUpdaterDriver showUpdateInProgress:NO]; [self updateLastUpdateCheckDate]; [self scheduleNextUpdateCheck]; } @@ -342,6 +343,8 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, SU [self scheduleNextUpdateCheck]; return; } + + [self.userUpdaterDriver showUpdateInProgress:YES]; [self checkIfConfiguredProperly]; diff --git a/Sparkle/SUUserUpdaterDriver.h b/Sparkle/SUUserUpdaterDriver.h index 79091dca..405b3029 100644 --- a/Sparkle/SUUserUpdaterDriver.h +++ b/Sparkle/SUUserUpdaterDriver.h @@ -56,6 +56,8 @@ typedef NS_ENUM(NSUInteger, SUInstallUpdateStatus) { @property (nonatomic, readonly, weak) id delegate; +- (void)showUpdateInProgress:(BOOL)isUpdateInProgress; + - (void)startUpdateCheckTimerWithNextTimeInterval:(NSTimeInterval)timeInterval reply:(void (^)(SUUpdateCheckTimerStatus))reply; - (void)invalidateUpdateCheckTimer;