mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-18 20:49:26 +00:00
Added Autotype stubbs
Some changes to handle remebering key files in the password input
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user