From 4a26c395d8173fc613bf64dc381356784085e0b9 Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 29 Feb 2016 01:42:16 -0500 Subject: [PATCH] Add no-AppKit guards against all "core" files Also move system shut off handling to the user driver. Observing system shut off is difficult without AppKit, and a client may want to observe for varying types of events. I suppose this is consistent with application termination notifications though. --- Sparkle/SUAppcast.m | 4 +++ Sparkle/SUAppcastItem.m | 4 +++ Sparkle/SUAutomaticUpdateDriver.h | 1 - Sparkle/SUAutomaticUpdateDriver.m | 31 +++++++++++++++------ Sparkle/SUBasicUpdateDriver.m | 4 +++ Sparkle/SUBinaryDeltaApply.m | 4 +++ Sparkle/SUBinaryDeltaCommon.m | 4 +++ Sparkle/SUBinaryDeltaCreate.m | 4 +++ Sparkle/SUBinaryDeltaTool.m | 4 +++ Sparkle/SUBinaryDeltaUnarchiver.m | 4 +++ Sparkle/SUCodeSigningVerifier.m | 4 +++ Sparkle/SUConstants.m | 4 +++ Sparkle/SUDSAVerifier.m | 4 +++ Sparkle/SUDiskImageUnarchiver.m | 4 +++ Sparkle/SUFileManager.m | 4 +++ Sparkle/SUGuidedPackageInstaller.h | 1 - Sparkle/SUGuidedPackageInstaller.m | 5 ++++ Sparkle/SUHost.m | 4 +++ Sparkle/SUInstaller.m | 5 ++++ Sparkle/SULog.m | 4 +++ Sparkle/SUOperatingSystem.m | 4 +++ Sparkle/SUPackageInstaller.m | 4 +++ Sparkle/SUPipedUnarchiver.m | 3 ++ Sparkle/SUPlainInstaller.m | 4 +++ Sparkle/SUProbingUpdateDriver.m | 4 +++ Sparkle/SUScheduledUpdateDriver.m | 4 +++ Sparkle/SUSparkleUserUpdaterDriver.m | 40 +++++++++++++++++++++++++++ Sparkle/SUStandardVersionComparator.m | 4 +++ Sparkle/SUSystemProfiler.m | 4 +++ Sparkle/SUUIBasedUpdateDriver.h | 1 - Sparkle/SUUIBasedUpdateDriver.m | 4 +++ Sparkle/SUUnarchiver.m | 4 +++ Sparkle/SUUnarchiver_Private.h | 4 +++ Sparkle/SUUpdateDriver.m | 4 +++ Sparkle/SUUpdater.m | 7 +++-- Sparkle/SUUserInitiatedUpdateDriver.m | 4 +++ Sparkle/SUUserUpdaterDriver.h | 8 ++++++ 37 files changed, 196 insertions(+), 14 deletions(-) diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 927253f2..021ffcec 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -17,6 +17,10 @@ #import "SUErrors.h" #import "SULocalizations.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface NSXMLElement (SUAppcastExtensions) @property (readonly, copy) NSDictionary *attributesAsDictionary; @end diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index e49d3216..46cc6106 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -15,6 +15,10 @@ #import "SULog.h" #import "SUConstants.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUAppcastItem () @property (copy, readwrite) NSString *title; @property (copy, readwrite) NSString *dateString; diff --git a/Sparkle/SUAutomaticUpdateDriver.h b/Sparkle/SUAutomaticUpdateDriver.h index 7ff9dbf0..38255561 100644 --- a/Sparkle/SUAutomaticUpdateDriver.h +++ b/Sparkle/SUAutomaticUpdateDriver.h @@ -11,7 +11,6 @@ #import #import "SUBasicUpdateDriver.h" -#import "SUAutomaticUpdateAlert.h" @interface SUAutomaticUpdateDriver : SUBasicUpdateDriver diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 7a79b63d..9e27aaba 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -13,6 +13,11 @@ #import "SUConstants.h" #import "SUErrors.h" #import "SUAppcastItem.h" +#import "SULog.h" + +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif // If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise. static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7; @@ -52,7 +57,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)installUpdateWithTerminationStatus:(NSNumber *)terminationStatus { - switch ((SUApplicationTerminationStatus)(terminationStatus.integerValue)) { + switch ((SUApplicationTerminationStatus)(terminationStatus.unsignedIntegerValue)) { case SUApplicationStoppedObservingTermination: if (self.willUpdateOnTermination) { [self abortUpdate]; @@ -76,7 +81,10 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [self performSelectorOnMainThread:@selector(installUpdateWithTerminationStatus:) withObject:@(terminationStatus) waitUntilDone:YES]; }]; - [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; + [self.updater.userUpdaterDriver registerSystemPowerOff:^(SUSystemPowerOffStatus systemPowerOffStatus) { + // See above comment for why we use -performSelectorOnMainThread:withObject:waitUntilDone: + [self performSelectorOnMainThread:@selector(systemWillPowerOff:) withObject:@(systemPowerOffStatus) waitUntilDone:YES]; + }]; self.willUpdateOnTermination = YES; @@ -115,8 +123,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 self.willUpdateOnTermination = NO; [self.updater.userUpdaterDriver unregisterApplicationTermination]; - - [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil]; + [self.updater.userUpdaterDriver unregisterSystemPowerOff]; id updaterDelegate = [self.updater delegate]; if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)]) @@ -177,11 +184,19 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI]; } -- (void)systemWillPowerOff:(NSNotification *)__unused note +- (void)systemWillPowerOff:(NSNumber *)systemPowerOffStatus { - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{ - NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil) - }]]; + if (self.willUpdateOnTermination) { + switch ((SUSystemPowerOffStatus)(systemPowerOffStatus.unsignedIntegerValue)) { + case SUStoppedObservingSystemPowerOff: + [self abortUpdate]; + break; + case SUSystemWillPowerOff: + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil) }]]; + break; + } + } } - (void)abortUpdateWithError:(NSError *)error diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 039b85ca..baa73e4e 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -26,6 +26,10 @@ #import "SULocalizations.h" #import "SUAppcastItem.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUBasicUpdateDriver () @property (strong) SUAppcastItem *updateItem; diff --git a/Sparkle/SUBinaryDeltaApply.m b/Sparkle/SUBinaryDeltaApply.m index 63abdb4f..c7837894 100644 --- a/Sparkle/SUBinaryDeltaApply.m +++ b/Sparkle/SUBinaryDeltaApply.m @@ -15,6 +15,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath) { NSString *patchFile = temporaryFilename(@"apply-binary-delta"); diff --git a/Sparkle/SUBinaryDeltaCommon.m b/Sparkle/SUBinaryDeltaCommon.m index be3966ce..bf44efef 100644 --- a/Sparkle/SUBinaryDeltaCommon.m +++ b/Sparkle/SUBinaryDeltaCommon.m @@ -18,6 +18,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + int compareFiles(const FTSENT **a, const FTSENT **b) { return strcoll((*a)->fts_name, (*b)->fts_name); diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 98a6f08b..477733ae 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -21,6 +21,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + extern int bsdiff(int argc, const char **argv); @interface CreateBinaryDeltaOperation : NSOperation diff --git a/Sparkle/SUBinaryDeltaTool.m b/Sparkle/SUBinaryDeltaTool.m index 01f07dcf..3024bda5 100644 --- a/Sparkle/SUBinaryDeltaTool.m +++ b/Sparkle/SUBinaryDeltaTool.m @@ -12,6 +12,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + #define VERBOSE_FLAG @"--verbose" #define VERSION_FLAG @"--version" diff --git a/Sparkle/SUBinaryDeltaUnarchiver.m b/Sparkle/SUBinaryDeltaUnarchiver.m index e9990e65..b1527f92 100644 --- a/Sparkle/SUBinaryDeltaUnarchiver.m +++ b/Sparkle/SUBinaryDeltaUnarchiver.m @@ -13,6 +13,10 @@ #import "SUHost.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUBinaryDeltaUnarchiver + (BOOL)canUnarchivePath:(NSString *)path diff --git a/Sparkle/SUCodeSigningVerifier.m b/Sparkle/SUCodeSigningVerifier.m index 0f37c0a5..eac8b76f 100644 --- a/Sparkle/SUCodeSigningVerifier.m +++ b/Sparkle/SUCodeSigningVerifier.m @@ -11,6 +11,10 @@ #import "SUCodeSigningVerifier.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUCodeSigningVerifier + (BOOL)codeSignatureAtPath:(NSString *)oldApplicationPath matchesSignatureAtPath:(NSString *)newApplicationPath error:(NSError *__autoreleasing *)error diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index 6e020ef8..347e8c61 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -18,6 +18,10 @@ #define DEBUG 0 #endif +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + // Define some minimum intervals to avoid DoS-like checking attacks const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60); const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24); diff --git a/Sparkle/SUDSAVerifier.m b/Sparkle/SUDSAVerifier.m index fa5f9934..5542e3cf 100644 --- a/Sparkle/SUDSAVerifier.m +++ b/Sparkle/SUDSAVerifier.m @@ -16,6 +16,10 @@ #import "SULog.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUDSAVerifier { SecKeyRef _secKey; } diff --git a/Sparkle/SUDiskImageUnarchiver.m b/Sparkle/SUDiskImageUnarchiver.m index a9546ca1..2944c939 100644 --- a/Sparkle/SUDiskImageUnarchiver.m +++ b/Sparkle/SUDiskImageUnarchiver.m @@ -11,6 +11,10 @@ #import "SULog.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUDiskImageUnarchiver + (BOOL)canUnarchivePath:(NSString *)path diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 404bd8cf..adc1afb7 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -14,6 +14,10 @@ #include #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static char SUAppleQuarantineIdentifier[] = "com.apple.quarantine"; // Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan! diff --git a/Sparkle/SUGuidedPackageInstaller.h b/Sparkle/SUGuidedPackageInstaller.h index 292f14af..3060a23d 100644 --- a/Sparkle/SUGuidedPackageInstaller.h +++ b/Sparkle/SUGuidedPackageInstaller.h @@ -23,7 +23,6 @@ A guided installation can be started by applications other than the application #define SUGUIDEDPACKAGEINSTALLER_H #import -#import "Sparkle.h" #import "SUInstaller.h" @interface SUGuidedPackageInstaller : SUInstaller diff --git a/Sparkle/SUGuidedPackageInstaller.m b/Sparkle/SUGuidedPackageInstaller.m index 0e268473..f7acf355 100644 --- a/Sparkle/SUGuidedPackageInstaller.m +++ b/Sparkle/SUGuidedPackageInstaller.m @@ -10,6 +10,11 @@ #import #import "SUParameterAssert.h" #import "SUGuidedPackageInstaller.h" +#import "SUErrors.h" + +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments) { diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 36380b7b..8b9b81ff 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -14,6 +14,10 @@ #import "SULog.h" #import "SUParameterAssert.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUHost () @property (strong, readwrite) NSBundle *bundle; diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 98ba20ff..f3bc760a 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -14,6 +14,11 @@ #import "SUConstants.h" #import "SULog.h" #import "SUParameterAssert.h" +#import "SUErrors.h" + +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif @implementation SUInstaller diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index 5941aac7..f886a07f 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -13,6 +13,10 @@ #include "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" implementation and should NOT import AppKit +#endif + // ----------------------------------------------------------------------------- // Constants: diff --git a/Sparkle/SUOperatingSystem.m b/Sparkle/SUOperatingSystem.m index c17c099c..28d8bdbc 100644 --- a/Sparkle/SUOperatingSystem.m +++ b/Sparkle/SUOperatingSystem.m @@ -7,6 +7,10 @@ #import "SUOperatingSystem.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 @interface NSProcessInfo () - (NSOperatingSystemVersion)operatingSystemVersion; diff --git a/Sparkle/SUPackageInstaller.m b/Sparkle/SUPackageInstaller.m index 89467fd1..1667ab28 100644 --- a/Sparkle/SUPackageInstaller.m +++ b/Sparkle/SUPackageInstaller.m @@ -10,6 +10,10 @@ #import "SUConstants.h" #import "SUErrors.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUPackageInstaller + (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host versionComparator:(id)__unused comparator completionHandler:(void (^)(NSError *))completionHandler diff --git a/Sparkle/SUPipedUnarchiver.m b/Sparkle/SUPipedUnarchiver.m index 7317143d..c806ee6a 100644 --- a/Sparkle/SUPipedUnarchiver.m +++ b/Sparkle/SUPipedUnarchiver.m @@ -10,6 +10,9 @@ #import "SUUnarchiver_Private.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif @implementation SUPipedUnarchiver diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 59947ff4..d878d66e 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -15,6 +15,10 @@ #import "SUErrors.h" #import "SUParameterAssert.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUPlainInstaller // Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one diff --git a/Sparkle/SUProbingUpdateDriver.m b/Sparkle/SUProbingUpdateDriver.m index 1fde6c6d..b538b51d 100644 --- a/Sparkle/SUProbingUpdateDriver.m +++ b/Sparkle/SUProbingUpdateDriver.m @@ -9,6 +9,10 @@ #import "SUProbingUpdateDriver.h" #import "SUUpdater.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUProbingUpdateDriver // Stop as soon as we have an answer! Since the superclass implementations are not called, we are responsible for notifying the delegate. diff --git a/Sparkle/SUScheduledUpdateDriver.m b/Sparkle/SUScheduledUpdateDriver.m index 9d6bf141..19aba59b 100644 --- a/Sparkle/SUScheduledUpdateDriver.m +++ b/Sparkle/SUScheduledUpdateDriver.m @@ -13,6 +13,10 @@ #import "SUAppcastItem.h" #import "SUVersionComparisonProtocol.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUScheduledUpdateDriver () @property (assign) BOOL showErrors; diff --git a/Sparkle/SUSparkleUserUpdaterDriver.m b/Sparkle/SUSparkleUserUpdaterDriver.m index 6c1659a8..5f2ed608 100644 --- a/Sparkle/SUSparkleUserUpdaterDriver.m +++ b/Sparkle/SUSparkleUserUpdaterDriver.m @@ -54,6 +54,8 @@ @property (nonatomic, copy) void (^applicationTerminationHandler)(SUApplicationTerminationStatus); +@property (nonatomic, copy) void (^systemPowerOffHandler)(SUSystemPowerOffStatus); + @property (nonatomic) BOOL installingUpdateOnTermination; @end @@ -73,6 +75,7 @@ @synthesize downloadStatusCompletion = _downloadStatusCompletion; @synthesize installUpdateHandler = _installUpdateHandler; @synthesize applicationTerminationHandler = _applicationTerminationHandler; +@synthesize systemPowerOffHandler = _systemPowerOffHandler; @synthesize installingUpdateOnTermination = _installingUpdateOnTermination; #pragma mark Birth @@ -537,6 +540,42 @@ }); } +#pragma mark System Death + +- (void)registerSystemPowerOff:(void (^)(SUSystemPowerOffStatus))systemPowerOffHandler +{ + dispatch_async(dispatch_get_main_queue(), ^{ + self.systemPowerOffHandler = systemPowerOffHandler; + + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; + }); +} + +- (void)cancelObservingSystemPowerOff +{ + if (self.systemPowerOffHandler != nil) { + self.systemPowerOffHandler(SUStoppedObservingSystemPowerOff); + self.systemPowerOffHandler = nil; + + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil]; + } +} + +- (void)unregisterSystemPowerOff +{ + dispatch_async(dispatch_get_main_queue(), ^{ + [self cancelObservingSystemPowerOff]; + }); +} + +- (void)systemWillPowerOff:(NSNotification *)__unused notification +{ + if (self.systemPowerOffHandler != nil) { + self.systemPowerOffHandler(SUSystemWillPowerOff); + self.systemPowerOffHandler = nil; + } +} + #pragma mark Aborting Update - (void)dismissUpdateInstallation @@ -563,6 +602,7 @@ } [self cancelObservingApplicationTermination]; + [self cancelObservingSystemPowerOff]; [self cancelInstallAndRestart]; }); } diff --git a/Sparkle/SUStandardVersionComparator.m b/Sparkle/SUStandardVersionComparator.m index b7c876a5..1d7d6ad9 100644 --- a/Sparkle/SUStandardVersionComparator.m +++ b/Sparkle/SUStandardVersionComparator.m @@ -13,6 +13,10 @@ #import "SUVersionComparisonProtocol.h" #import "SUStandardVersionComparator.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUStandardVersionComparator + (SUStandardVersionComparator *)defaultComparator diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index febb6f08..39400fde 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -13,6 +13,10 @@ #import "SUOperatingSystem.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + static NSString *const SUSystemProfilerApplicationNameKey = @"appName"; static NSString *const SUSystemProfilerApplicationVersionKey = @"appVersion"; static NSString *const SUSystemProfilerCPU64bitKey = @"cpu64bit"; diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index fc376d25..a3f8da69 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -11,7 +11,6 @@ #import #import "SUBasicUpdateDriver.h" -#import "SUUpdateAlert.h" @class SUStatusController; diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 96081453..bd83d897 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -14,6 +14,10 @@ #import "SUConstants.h" #import "SUAppcastItem.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUUIBasedUpdateDriver - (instancetype)initWithUpdater:(SUUpdater *)anUpdater host:(SUHost *)aHost diff --git a/Sparkle/SUUnarchiver.m b/Sparkle/SUUnarchiver.m index e887f4ca..42adf996 100644 --- a/Sparkle/SUUnarchiver.m +++ b/Sparkle/SUUnarchiver.m @@ -15,6 +15,10 @@ #import "SUUnarchiver.h" #import "SUUnarchiver_Private.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @implementation SUUnarchiver @synthesize archivePath; diff --git a/Sparkle/SUUnarchiver_Private.h b/Sparkle/SUUnarchiver_Private.h index 2a6b0ed6..0aa4419b 100644 --- a/Sparkle/SUUnarchiver_Private.h +++ b/Sparkle/SUUnarchiver_Private.h @@ -12,6 +12,10 @@ #import #import "SUUnarchiver.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUUnarchiver (Private) + (void)registerImplementation:(Class)implementation; + (NSArray *)unarchiverImplementations; diff --git a/Sparkle/SUUpdateDriver.m b/Sparkle/SUUpdateDriver.m index 18050afd..e5254268 100644 --- a/Sparkle/SUUpdateDriver.m +++ b/Sparkle/SUUpdateDriver.m @@ -10,6 +10,10 @@ #import "SUHost.h" #import "SULog.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; @interface SUUpdateDriver () diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index b2ce74ce..0e1a2f40 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -8,10 +8,7 @@ #import "SUUpdater.h" -#import "SUSparkleUserUpdaterDriver.h" - #import "SUHost.h" -#import "SUUpdatePermissionPrompt.h" #import "SUUpdatePermissionPromptResult.h" #import "SUAutomaticUpdateDriver.h" @@ -24,6 +21,10 @@ #import "SUSystemProfiler.h" #include +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification"; NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification"; NSString *const SUUpdaterDidNotFindUpdateNotification = @"SUUpdaterDidNotFindUpdateNotification"; diff --git a/Sparkle/SUUserInitiatedUpdateDriver.m b/Sparkle/SUUserInitiatedUpdateDriver.m index 3c3f5f1e..917e6833 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.m +++ b/Sparkle/SUUserInitiatedUpdateDriver.m @@ -10,6 +10,10 @@ #import "SUUpdater.h" #import "SUHost.h" +#ifdef _APPKITDEFINES_H +#error This is a "core" class and should NOT import AppKit +#endif + @interface SUUserInitiatedUpdateDriver () @property (assign, getter=isCanceled) BOOL canceled; diff --git a/Sparkle/SUUserUpdaterDriver.h b/Sparkle/SUUserUpdaterDriver.h index 405b3029..0dbaa33b 100644 --- a/Sparkle/SUUserUpdaterDriver.h +++ b/Sparkle/SUUserUpdaterDriver.h @@ -35,6 +35,11 @@ typedef NS_ENUM(NSUInteger, SUApplicationTerminationStatus) { SUApplicationStoppedObservingTermination }; +typedef NS_ENUM(NSUInteger, SUSystemPowerOffStatus) { + SUSystemWillPowerOff, + SUStoppedObservingSystemPowerOff +}; + typedef NS_ENUM(NSUInteger, SUInstallUpdateStatus) { SUInstallAndRelaunchUpdateNow, SUCancelUpdateInstallation @@ -87,6 +92,9 @@ typedef NS_ENUM(NSUInteger, SUInstallUpdateStatus) { - (void)unregisterApplicationTermination; - (void)terminateApplication; +- (void)registerSystemPowerOff:(void (^)(SUSystemPowerOffStatus))systemPowerOffHandler; +- (void)unregisterSystemPowerOff; + - (void)dismissUpdateInstallation; @end