Added Autotype stubbs

Some changes to handle remebering key files in the password input
This commit is contained in:
michael starke
2013-11-16 00:07:14 +01:00
parent 3e56f2269d
commit c7b5bdac74
10 changed files with 100 additions and 6 deletions

View File

@@ -9,6 +9,7 @@
#import "MPPasswordInputController.h"
#import "MPDocumentWindowController.h"
#import "MPDocument.h"
#import "MPSettingsHelper.h"
#import "MPKeyfilePathControlDelegate.h"
#import "HNHRoundedSecureTextField.h"
@@ -23,6 +24,7 @@
@property (weak) IBOutlet NSTextField *errorInfoTextField;
@property (weak) IBOutlet NSButton *togglePasswordButton;
@property (nonatomic, assign) BOOL shouldSelectKeyFile;
@property (assign) BOOL showPassword;
- (IBAction)_decrypt:(id)sender;
@@ -33,15 +35,28 @@
@implementation MPPasswordInputController
- (id)init {
return [[MPPasswordInputController alloc] initWithNibName:@"PasswordInputView" bundle:nil];
self = [self initWithNibName:@"PasswordInputView" bundle:nil];
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self) {
_showLastUsedKeyFile = NO;
_shouldSelectKeyFile = NO;
}
return self;
}
- (void)didLoadView {
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
[self bind:@"shouldSelectKeyFile" toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyRememberKeyFilesForDatabases ] options:nil];
[self.keyPathControl setDelegate:self.pathControlDelegate];
[self.errorImageView setImage:[NSImage imageNamed:NSImageNameCaution]];
[self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil];
[self.togglePasswordButton bind:NSValueBinding toObject:self withKeyPath:@"showPassword" options:nil];
[self _reset];
}
@@ -52,8 +67,17 @@
- (void)requestPassword {
// show Warnign if read-only mode!
[self _reset];
if(self.showLastUsedKeyFile) {
[self _selectRecentKeyFile];
}
}
#pragma mark Properties
- (void)setShouldSelectKeyFile:(BOOL)shouldSelectKeyFile {
if(_shouldSelectKeyFile != shouldSelectKeyFile) {
_shouldSelectKeyFile = shouldSelectKeyFile;
}
}
#pragma mark NSTextViewDelegate
#pragma mark -
#pragma mark Private
@@ -80,7 +104,14 @@
[self.keyPathControl setURL:nil];
[self.errorInfoTextField setHidden:YES];
[self.errorImageView setHidden:YES];
}
- (void)_selectRecentKeyFile {
if(!self.shouldSelectKeyFile) {
[self.keyPathControl setURL:nil];
return; // If we aren't supposed to preselect paths, clear them!
}
}
- (void)_showError:(NSError *)error {