Initial work on UI separation

Separated just the permission prompt so far
This commit is contained in:
Zorg committed 2016-02-11 23:45:36 -05:00
1 parent b1d7c3ade9
commit 0a29626615
7 files changed
+109 -40

No files matched your search

+8
View File
@@ -186,6 +186,8 @@
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; };
7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SUUpdatePermissionPromptResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
72A450541C69A68900D67EEA /* SUUpdatePermissionPromptResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SUUpdatePermissionPromptResult.m */; };
72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; };
72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; };
72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; };
@@ -635,6 +637,8 @@
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = "<group>"; };
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestRelease.xcconfig; sourceTree = "<group>"; };
72A450511C69A68900D67EEA /* SUUpdatePermissionPromptResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdatePermissionPromptResult.h; sourceTree = "<group>"; };
72A450521C69A68900D67EEA /* SUUpdatePermissionPromptResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdatePermissionPromptResult.m; sourceTree = "<group>"; };
72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUFileManagerTest.swift; sourceTree = "<group>"; };
72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = SparkleTestCodeSignApp.tar.gz; sourceTree = "<group>"; };
72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = SparkleTestCodeSignApp.tar; sourceTree = "<group>"; };
@@ -995,6 +999,8 @@
6196CFE409C71ADE000DC222 /* SUStatusController.m */,
61B5FCA009C5228F00B25A18 /* SUUpdateAlert.h */,
61B5FCA109C5228F00B25A18 /* SUUpdateAlert.m */,
72A450511C69A68900D67EEA /* SUUpdatePermissionPromptResult.h */,
72A450521C69A68900D67EEA /* SUUpdatePermissionPromptResult.m */,
612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */,
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
61180BC80D64138900B4E0D1 /* SUWindowController.h */,
@@ -1158,6 +1164,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */,
611142E910FB1BE5009810AA /* bspatch.h in Headers */,
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */,
61299B3609CB04E000B7442F /* Sparkle.h in Headers */,
@@ -1679,6 +1686,7 @@
61299A6009CA6EB100B7442F /* SUConstants.m in Sources */,
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */,
61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */,
72A450541C69A68900D67EEA /* SUUpdatePermissionPromptResult.m in Sources */,
7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */,
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */,
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
+3 -12
View File
@@ -11,23 +11,14 @@
#import "SUWindowController.h"
typedef NS_ENUM(NSInteger, SUPermissionPromptResult) {
SUAutomaticallyCheck,
SUDoNotAutomaticallyCheck
};
@class SUHost, SUUpdatePermissionPromptResult;
@protocol SUUpdatePermissionPromptDelegate;
@class SUHost;
@interface SUUpdatePermissionPrompt : SUWindowController
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d;
+ (void)promptWithHost:(SUHost *)host systemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply;
- (IBAction)toggleMoreInfo:(id)sender;
- (IBAction)finishPrompt:(id)sender;
@end
@protocol SUUpdatePermissionPromptDelegate <NSObject>
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result;
@end
#endif
+21 -22
View File
@@ -7,6 +7,7 @@
//
#import "SUUpdatePermissionPrompt.h"
#import "SUUpdatePermissionPromptResult.h"
#import "SUHost.h"
#import "SUConstants.h"
@@ -18,57 +19,53 @@
@property (strong) SUHost *host;
@property (strong) NSArray *systemProfileInformationArray;
@property (weak) id<SUUpdatePermissionPromptDelegate> delegate;
@property (weak) IBOutlet NSTextField *descriptionTextField;
@property (weak) IBOutlet NSView *moreInfoView;
@property (weak) IBOutlet NSButton *moreInfoButton;
@property (weak) IBOutlet NSTableView *profileTableView;
@property (nonatomic, readonly) void (^reply)(SUUpdatePermissionPromptResult *);
@end
@implementation SUUpdatePermissionPrompt
@synthesize reply = _reply;
@synthesize isShowingMoreInfo = _isShowingMoreInfo;
@synthesize shouldSendProfile = _shouldSendProfile;
@synthesize host;
@synthesize systemProfileInformationArray;
@synthesize delegate;
@synthesize descriptionTextField;
@synthesize moreInfoView;
@synthesize moreInfoButton;
@synthesize profileTableView;
- (BOOL)shouldAskAboutProfile
{
return [[self.host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
}
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d
- (instancetype)initPromptWithHost:(SUHost *)theHost systemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply
{
self = [super initWithWindowNibName:@"SUUpdatePermissionPrompt"];
if (self)
{
host = aHost;
delegate = d;
if (self)
{
_reply = reply;
self.host = theHost;
self.isShowingMoreInfo = NO;
self.shouldSendProfile = [self shouldAskAboutProfile];
systemProfileInformationArray = profile;
self.systemProfileInformationArray = systemProfile;
[self setShouldCascadeWindows:NO];
}
return self;
}
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d
+ (void)promptWithHost:(SUHost *)host systemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply
{
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
if ([aHost isBackgroundApplication]) {
if ([host isBackgroundApplication]) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
if (![NSApp modalWindow]) { // do not prompt if there is is another modal window on screen
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initPromptWithHost:host systemProfile:systemProfile reply:reply];
NSWindow *window = [prompt window];
if (window) {
[NSApp runModalForWindow:window];
@@ -76,6 +73,11 @@
}
}
- (BOOL)shouldAskAboutProfile
{
return [[self.host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
- (void)windowDidLoad
@@ -149,11 +151,8 @@
- (IBAction)finishPrompt:(id)sender
{
if (![self.delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) {
[NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", self.delegate];
}
[self.host setBool:self.shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey];
[self.delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)];
self.reply([SUUpdatePermissionPromptResult updatePermissionPromptResultWithChoice:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck) shouldSendProfile:self.shouldSendProfile]);
[[self window] close];
[NSApp stopModal];
}
+23
View File
@@ -0,0 +1,23 @@
//
// SUUpdatePermissionPromptResult.h
// Sparkle
//
// Created by Mayur Pawashe on 2/8/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, SUCheckUpdatesChoice) {
SUAutomaticallyCheck,
SUDoNotAutomaticallyCheck
};
@interface SUUpdatePermissionPromptResult : NSObject
+ (instancetype)updatePermissionPromptResultWithChoice:(SUCheckUpdatesChoice)choice shouldSendProfile:(BOOL)shouldSendProfile;
@property (nonatomic, readonly) SUCheckUpdatesChoice choice;
@property (nonatomic, readonly) BOOL shouldSendProfile;
@end
+31
View File
@@ -0,0 +1,31 @@
//
// SUUpdatePermissionPromptResult.m
// Sparkle
//
// Created by Mayur Pawashe on 2/8/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUUpdatePermissionPromptResult.h"
@implementation SUUpdatePermissionPromptResult
@synthesize choice = _choice;
@synthesize shouldSendProfile = _shouldSendProfile;
- (instancetype)initWithCheckUpdatesChoice:(SUCheckUpdatesChoice)choice shouldSendProfile:(BOOL)shouldSendProfile
{
self = [super init];
if (self != nil) {
_choice = choice;
_shouldSendProfile = shouldSendProfile;
}
return self;
}
+ (instancetype)updatePermissionPromptResultWithChoice:(SUCheckUpdatesChoice)choice shouldSendProfile:(BOOL)shouldSendProfile
{
return [[self alloc] initWithCheckUpdatesChoice:choice shouldSendProfile:shouldSendProfile];
}
@end
+3 -1
View File
@@ -14,7 +14,7 @@
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@class SUAppcastItem, SUAppcast;
@class SUAppcastItem, SUAppcast, SUHost, SUUpdatePermissionPromptResult;
@protocol SUUpdaterDelegate;
@@ -361,6 +361,8 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
- (BOOL)handlePermissionForUpdater:(SUUpdater *)updater host:(SUHost *)host systemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply;
@end
#endif
+20 -5
View File
@@ -10,6 +10,7 @@
#import "SUHost.h"
#import "SUUpdatePermissionPrompt.h"
#import "SUUpdatePermissionPromptResult.h"
#import "SUAutomaticUpdateDriver.h"
#import "SUProbingUpdateDriver.h"
@@ -27,7 +28,7 @@ NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotific
NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNotificationKey";
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
@interface SUUpdater () <SUUpdatePermissionPromptDelegate>
@interface SUUpdater ()
@property (strong) NSTimer *checkTimer;
@property (strong) NSBundle *sparkleBundle;
@@ -186,7 +187,20 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:YES]];
}
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:profileInfo delegate:self];
BOOL handledPermissionPrompt = NO;
if ([self.delegate respondsToSelector:@selector(handlePermissionForUpdater:host:systemProfile:reply:)]) {
handledPermissionPrompt = [self.delegate handlePermissionForUpdater:self host:self.host systemProfile:profileInfo reply:^(SUUpdatePermissionPromptResult *result) {
[self updatePermissionPromptFinishedWithResult:result];
}];
}
if (!handledPermissionPrompt) {
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:profileInfo reply:^(SUUpdatePermissionPromptResult *result) {
[self updatePermissionPromptFinishedWithResult:result];
}];
}
// We start the update checks and register as observer for changes after the prompt finishes
} else {
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
@@ -194,9 +208,10 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
}
}
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result
- (void)updatePermissionPromptFinishedWithResult:(SUUpdatePermissionPromptResult *)result
{
[self setAutomaticallyChecksForUpdates:(result == SUAutomaticallyCheck)];
[self.host setBool:result.shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey];
[self setAutomaticallyChecksForUpdates:(result.choice == SUAutomaticallyCheck)];
// Schedule checks, but make sure we ignore the delayed call from KVO
[self resetUpdateCycle];
}
@@ -335,7 +350,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
[self.driver abortUpdate];
}
SUUIBasedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self];
SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self];
theUpdateDriver.automaticallyInstallUpdates = YES;
[self checkForUpdatesWithDriver:theUpdateDriver];
}