Use SPUUserDriverUIComponent for command line user driver

This commit is contained in:
Zorg committed 2016-08-13 10:49:45 -04:00
1 parent b8ccc5d079
commit 8eb61afe53
3 files changed
+12 -12

No files matched your search

+2
View File
@@ -17,6 +17,8 @@ SU_EXPORT @interface SPUUserDriverUIComponent : NSObject
- (void)terminateApplicationForBundle:(NSBundle *)bundle;
- (BOOL)applicationIsAliveForBundle:(NSBundle *)bundle;
@end
NS_ASSUME_NONNULL_END
+5
View File
@@ -27,4 +27,9 @@
}
}
- (BOOL)applicationIsAliveForBundle:(NSBundle *)bundle
{
return ([SPUApplicationInfo runningApplicationWithBundle:bundle] != nil);
}
@end
+5 -12
View File
@@ -8,8 +8,6 @@
#import "SPUCommandLineUserDriver.h"
#import <AppKit/AppKit.h>
#import "SPUApplicationInfo.h"
#import "SPUDownloadData.h"
#define SCHEDULED_UPDATE_TIMER_THRESHOLD 2.0 // seconds
@@ -20,6 +18,7 @@
@property (nonatomic, readonly) BOOL deferInstallation;
@property (nonatomic, readonly) BOOL verbose;
@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent;
@property (nonatomic, readonly) SPUUserDriverUIComponent *uiComponent;
@property (nonatomic) NSUInteger bytesDownloaded;
@property (nonatomic) NSUInteger bytesToDownload;
@@ -32,6 +31,7 @@
@synthesize deferInstallation = _deferInstallation;
@synthesize verbose = _verbose;
@synthesize coreComponent = _coreComponent;
@synthesize uiComponent = _uiComponent;
@synthesize bytesDownloaded = _bytesDownloaded;
@synthesize bytesToDownload = _bytesToDownload;
@@ -44,6 +44,7 @@
_deferInstallation = deferInstallation;
_verbose = verbose;
_coreComponent = [[SPUUserDriverCoreComponent alloc] init];
_uiComponent = [[SPUUserDriverUIComponent alloc] init];
}
return self;
}
@@ -268,7 +269,7 @@
fprintf(stderr, "Deferring Installation.\n");
}
[self.coreComponent installUpdateWithChoice:SPUDismissUpdateInstallation];
} else if ([SPUApplicationInfo runningApplicationWithBundle:self.applicationBundle] != nil) {
} else if ([self.uiComponent applicationIsAliveForBundle:self.applicationBundle]) {
[self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow];
} else {
[self.coreComponent installUpdateWithChoice:SPUInstallUpdateNow];
@@ -311,15 +312,7 @@
- (void)terminateApplication
{
dispatch_async(dispatch_get_main_queue(), ^{
NSRunningApplication *runningApplication = [SPUApplicationInfo runningApplicationWithBundle:self.applicationBundle];
if (runningApplication != nil) {
if (![runningApplication terminate]) {
if (![runningApplication forceTerminate]) {
fprintf(stderr, "Error: Failed to terminate running application. Please terminate it to update it.");
exit(EXIT_FAILURE);
}
}
}
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
});
}