From 4a3f0ad9846c4fe8b8929633e8e6e7c3533d2b44 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 28 Feb 2016 02:00:57 -0500 Subject: [PATCH] Pass the SUHost into the driver's constructor --- Sparkle/SUBasicUpdateDriver.h | 2 +- Sparkle/SUBasicUpdateDriver.m | 8 ++++---- Sparkle/SUUIBasedUpdateDriver.h | 2 +- Sparkle/SUUIBasedUpdateDriver.m | 4 ++-- Sparkle/SUUpdateDriver.h | 4 ++-- Sparkle/SUUpdateDriver.m | 6 +++--- Sparkle/SUUpdater.m | 10 +++++----- Sparkle/SUUserInitiatedUpdateDriver.m | 5 ++--- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.h b/Sparkle/SUBasicUpdateDriver.h index 8c6960d8..deae8476 100644 --- a/Sparkle/SUBasicUpdateDriver.h +++ b/Sparkle/SUBasicUpdateDriver.h @@ -21,7 +21,7 @@ @property (strong, readonly) NSURLDownload *download; @property (copy, readonly) NSString *downloadPath; -- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host; +- (void)checkForUpdatesAtURL:(NSURL *)URL; - (BOOL)isItemNewer:(SUAppcastItem *)ui; - (BOOL)hostSupportsItem:(SUAppcastItem *)ui; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 076dacdf..cab9ea76 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -49,12 +49,12 @@ @synthesize postponedOnce; -- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost +- (void)checkForUpdatesAtURL:(NSURL *)URL { - [super checkForUpdatesAtURL:URL host:aHost]; - if ([aHost isRunningOnReadOnlyVolume]) + [super checkForUpdatesAtURL:URL]; + if ([self.host isRunningOnReadOnlyVolume]) { - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]]; + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [self.host name]] }]]; return; } diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index 88d8fd47..e128c89d 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -17,7 +17,7 @@ @interface SUUIBasedUpdateDriver : SUBasicUpdateDriver -- (instancetype)initWithUpdater:(SUUpdater *)updater; +- (instancetype)initWithUpdater:(SUUpdater *)updater host:(SUHost *)host; @end diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index a0acae98..86494a85 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -15,9 +15,9 @@ @implementation SUUIBasedUpdateDriver -- (instancetype)initWithUpdater:(SUUpdater *)anUpdater +- (instancetype)initWithUpdater:(SUUpdater *)anUpdater host:(SUHost *)aHost { - if ((self = [super initWithUpdater:anUpdater])) { + if ((self = [super initWithUpdater:anUpdater host:aHost])) { self.automaticallyInstallUpdates = NO; } return self; diff --git a/Sparkle/SUUpdateDriver.h b/Sparkle/SUUpdateDriver.h index 738626d8..2db89d9f 100644 --- a/Sparkle/SUUpdateDriver.h +++ b/Sparkle/SUUpdateDriver.h @@ -19,8 +19,8 @@ extern NSString *const SUUpdateDriverFinishedNotification; @property (readonly, weak) SUUpdater *updater; @property (strong) SUHost *host; -- (instancetype)initWithUpdater:(SUUpdater *)updater; -- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host; +- (instancetype)initWithUpdater:(SUUpdater *)updater host:(SUHost *)host; +- (void)checkForUpdatesAtURL:(NSURL *)URL; - (void)abortUpdate; @property (getter=isInterruptible, readonly) BOOL interruptible; diff --git a/Sparkle/SUUpdateDriver.m b/Sparkle/SUUpdateDriver.m index 345a0040..18050afd 100644 --- a/Sparkle/SUUpdateDriver.m +++ b/Sparkle/SUUpdateDriver.m @@ -29,20 +29,20 @@ NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; @synthesize appcastURL; @synthesize automaticallyInstallUpdates; -- (instancetype)initWithUpdater:(SUUpdater *)anUpdater +- (instancetype)initWithUpdater:(SUUpdater *)anUpdater host:(SUHost *)aHost { if ((self = [super init])) { self.updater = anUpdater; + self.host = aHost; } return self; } - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; } -- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h +- (void)checkForUpdatesAtURL:(NSURL *)URL { self.appcastURL = URL; - self.host = h; } - (void)abortUpdate diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index b98bf7bd..c1ac54db 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -275,7 +275,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD // 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]; + SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self host:self.host]; // We don't want the rechability check to act on the driver if the updater is going near death __weak SUUpdater *updater = self; @@ -296,12 +296,12 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD [self.driver abortUpdate]; } - [self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]]; + [self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self host:self.host]]; } - (void)checkForUpdateInformation { - [self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self]]; + [self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self host:self.host]]; } - (void)installUpdatesIfAvailable @@ -310,7 +310,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD [self.driver abortUpdate]; } - SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]; + SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self host:self.host]; theUpdateDriver.automaticallyInstallUpdates = YES; [self checkForUpdatesWithDriver:theUpdateDriver]; } @@ -342,7 +342,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD NSURL *theFeedURL = [self parameterizedFeedURL]; if (theFeedURL) // Use a NIL URL to cancel quietly. - [self.driver checkForUpdatesAtURL:theFeedURL host:self.host]; + [self.driver checkForUpdatesAtURL:theFeedURL]; else [self.driver abortUpdate]; } diff --git a/Sparkle/SUUserInitiatedUpdateDriver.m b/Sparkle/SUUserInitiatedUpdateDriver.m index fd987d13..09fe61c5 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.m +++ b/Sparkle/SUUserInitiatedUpdateDriver.m @@ -33,8 +33,7 @@ } } -#warning assign user driver's host in a superclass of this method, possibly the UI driver.. IDK -- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost +- (void)checkForUpdatesAtURL:(NSURL *)URL { [self.updater.userUpdaterDriver showUserInitiatedUpdateCheckWithCompletion:^(SUUserInitiatedCheckStatus completionStatus) { switch (completionStatus) { @@ -48,7 +47,7 @@ } }]; - [super checkForUpdatesAtURL:URL host:aHost]; + [super checkForUpdatesAtURL:URL]; } - (void)appcastDidFinishLoading:(SUAppcast *)ac