Distinguish between application and host bundle in user drivers

This commit is contained in:
Zorg committed 2016-08-13 11:21:15 -04:00
1 parent cdc329d2c3
commit 5114cd9d83
7 files changed
+18 -13

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
self.initializedUpdater = YES;
NSBundle *hostBundle = [NSBundle mainBundle];
id <SPUUserDriver, SPUStandardUserDriverProtocol> userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:self.userDriverDelegate];
id <SPUUserDriver, SPUStandardUserDriverProtocol> userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle applicationBundle:hostBundle delegate:self.userDriverDelegate];
self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate];
self.userDriver = userDriver;
+2 -1
View File
@@ -24,9 +24,10 @@ SU_EXPORT @interface SPUStandardUserDriver : NSObject <SPUUserDriver, SPUStandar
Initializes a Sparkle's standard user driver for user update interactions
@param hostBundle The target bundle of the host that is being updated
@param applicationBundle The application bundle designated for relaunching
@param delegate The delegate to this user driver. Pass nil if you don't want to provide one.
*/
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(_Nullable id <SPUStandardUserDriverDelegate>)delegate;
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle delegate:(nullable id<SPUStandardUserDriverDelegate>)delegate;
@end
+5 -2
View File
@@ -23,6 +23,7 @@
@interface SPUStandardUserDriver ()
@property (nonatomic, readonly) SUHost *host;
@property (nonatomic, readonly) NSBundle *applicationBundle;
@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent;
@property (nonatomic, readonly) SPUUserDriverUIComponent *uiComponent;
@@ -37,6 +38,7 @@
@implementation SPUStandardUserDriver
@synthesize host = _host;
@synthesize applicationBundle = _applicationBundle;
@synthesize coreComponent = _coreComponent;
@synthesize uiComponent = _uiComponent;
@synthesize delegate = _delegate;
@@ -46,11 +48,12 @@
#pragma mark Birth
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(id<SPUStandardUserDriverDelegate>)delegate
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle delegate:(nullable id<SPUStandardUserDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_host = [[SUHost alloc] initWithBundle:hostBundle];
_applicationBundle = applicationBundle;
_delegate = delegate;
_coreComponent = [[SPUUserDriverCoreComponent alloc] init];
_uiComponent = [[SPUUserDriverUIComponent alloc] init];
@@ -397,7 +400,7 @@
[self.statusController close];
self.statusController = nil;
[self.uiComponent terminateApplicationForBundle:self.host.bundle];
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
});
}
+1 -1
View File
@@ -74,7 +74,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
}
[sharedUpdaters setObject:self forKey:[NSValue valueWithNonretainedObject:bundle]];
_userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:bundle delegate:self];
_userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:bundle applicationBundle:bundle delegate:self];
_updater = [[SPUUpdater alloc] initWithHostBundle:bundle userDriver:_userDriver delegate:self];
NSError *updaterError = nil;
+1 -1
View File
@@ -13,6 +13,6 @@
@interface SUPopUpTitlebarUserDriver : NSObject <SPUUserDriver, SPUStandardUserDriverProtocol>
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window;
- (instancetype)initWithApplicationBundle:(NSBundle *)applicationBundle window:(NSWindow *)window;
@end
+5 -5
View File
@@ -11,7 +11,7 @@
@interface SUPopUpTitlebarUserDriver()
@property (nonatomic, readonly) NSBundle *hostBundle;
@property (nonatomic, readonly) NSBundle *applicationBundle;
@property (nonatomic, readonly) NSWindow *window;
@property (nonatomic, nullable) SUInstallUpdateViewController *installUpdateViewController;
@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent;
@@ -27,7 +27,7 @@
@implementation SUPopUpTitlebarUserDriver
@synthesize hostBundle = _hostBundle;
@synthesize applicationBundle = _applicationBundle;
@synthesize window = _window;
@synthesize installUpdateViewController = _installUpdateViewController;
@synthesize coreComponent = _coreComponent;
@@ -39,11 +39,11 @@
@synthesize expectedContentLength = _expectedContentLength;
@synthesize contentLengthDownloaded = _contentLengthDownloaded;
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window
- (instancetype)initWithApplicationBundle:(NSBundle *)applicationBundle window:(NSWindow *)window
{
self = [super init];
if (self != nil) {
_hostBundle = hostBundle;
_applicationBundle = applicationBundle;
_window = window;
_coreComponent = [[SPUUserDriverCoreComponent alloc] init];
_uiComponent = [[SPUUserDriverUIComponent alloc] init];
@@ -332,7 +332,7 @@
// In case our termination request fails or is delayed
[self removeUpdateButton];
[self.uiComponent terminateApplicationForBundle:self.hostBundle];
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
});
}
@@ -30,13 +30,14 @@
- (void)windowDidLoad
{
NSBundle *hostBundle = [NSBundle mainBundle];
NSBundle *applicationBundle = hostBundle;
// If the user is holding down command, we use the popup title user driver instead
id<SPUUserDriver, SPUStandardUserDriverProtocol> userDriver;
if (([NSEvent modifierFlags] & NSCommandKeyMask) != 0) {
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithHostBundle:hostBundle window:self.window];
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithApplicationBundle:applicationBundle window:self.window];
} else {
userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:nil];
userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle applicationBundle:applicationBundle delegate:nil];
}
self.userDriver = userDriver;