mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 10:19:26 +00:00
Added Autotype stubbs
Some changes to handle remebering key files in the password input
This commit is contained in:
@@ -10,4 +10,8 @@
|
||||
|
||||
@interface MPAutotypeCommand : NSObject
|
||||
|
||||
@property (copy) NSString *commandString;
|
||||
|
||||
- (void)execute;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,4 +10,8 @@
|
||||
|
||||
@implementation MPAutotypeCommand
|
||||
|
||||
- (void)execute {
|
||||
// todo;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "DDHotKeyCenter.h"
|
||||
#import "MPPasteBoardController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocument+Autotype.h"
|
||||
|
||||
#import "KPKEntry.h"
|
||||
|
||||
@@ -103,6 +104,18 @@
|
||||
NSString *windowTitle = [self _frontMostWindowTitle];
|
||||
NSLog(@"Looking for entries matching window title:%@", windowTitle);
|
||||
|
||||
/*
|
||||
Query the document to generate a autotype command list for the window title
|
||||
We do not care where this came form, just get the autotype commands
|
||||
*/
|
||||
NSArray *autotypeCandidates = [[currentDocument findEntriesForWindowTitle:windowTitle] lastObject];
|
||||
if([autotypeCandidates count] == 0) {
|
||||
return; // No Entries found.
|
||||
}
|
||||
|
||||
/*
|
||||
Implement!
|
||||
*/
|
||||
return;
|
||||
|
||||
KPKEntry *selectedEntry = currentDocument.selectedEntry;
|
||||
|
||||
@@ -9,7 +9,14 @@
|
||||
#import "MPDocument.h"
|
||||
|
||||
@interface MPDocument (Autotype)
|
||||
/*
|
||||
Problem:
|
||||
|
||||
If matching isn't safe, we need to determine what to do:
|
||||
Possible selections for the user are Window associations or entries
|
||||
Hence we need to deliver both - or do something completely different?
|
||||
|
||||
*/
|
||||
- (NSArray *)findEntriesForWindowTitle:(NSString *)windowTitle;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,9 +8,18 @@
|
||||
|
||||
#import "MPDocument+Autotype.h"
|
||||
|
||||
#import "KPKGroup.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKAutotype.h"
|
||||
|
||||
@implementation MPDocument (Autotype)
|
||||
|
||||
- (NSArray *)findEntriesForWindowTitle:(NSString *)windowTitle {
|
||||
|
||||
NSArray *autotypeEntries = [self.root autotypeableChildEntries];
|
||||
for(KPKEntry *entry in autotypeEntries) {
|
||||
//KPKAutotype *autotype = entry.autotype;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,10 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
|
||||
- (void)showPasswordInput {
|
||||
if(!self.passwordInputController) {
|
||||
self.passwordInputController = [[MPPasswordInputController alloc] init];
|
||||
self.passwordInputController.showLastUsedKeyFile = YES;
|
||||
}
|
||||
else {
|
||||
self.passwordInputController.showLastUsedKeyFile = NO;
|
||||
}
|
||||
[self _setContentViewController:self.passwordInputController];
|
||||
[self.passwordInputController requestPassword];
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
@interface MPPasswordInputController : MPViewController
|
||||
|
||||
@property (nonatomic, assign) BOOL showLastUsedKeyFile;
|
||||
|
||||
- (void)requestPassword;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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