From 2aef949a5b33d9bf2f074af13074718002344c7f Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 1 Sep 2014 19:28:29 +0200 Subject: [PATCH] Added default Autotype sequence to settings. Using sepearte MPTreeDeleagte for autotype and editing --- KeePassKit | 2 +- MacPass/MPDocument.m | 7 +++++++ MacPass/MPSettingsHelper.m | 2 ++ MacPass/MPTreeDelegate.h | 4 ++++ MacPass/MPTreeDelegate.m | 25 +++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/KeePassKit b/KeePassKit index 450ad0d4..5f2c98f4 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 450ad0d4dc88e324158d338e18a3770d24315b7f +Subproject commit 5f2c98f46fc4d3c1b6bdd985d46384ff1301fd7b diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index a0e0106b..335db0a9 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -31,6 +31,8 @@ #import "MPNotifications.h" #import "MPConstants.h" #import "MPSavePanelAccessoryViewController.h" +#import "MPTreeDelegate.h" + #import "DDXMLNode.h" @@ -65,6 +67,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey @private BOOL _didLockFile; NSData *_encryptedData; + MPTreeDelegate *_treeDelgate; } @property (nonatomic, assign) NSUInteger unlockCount; @@ -396,6 +399,10 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey if(_tree != tree) { _tree = tree; _tree.undoManager = [self undoManager]; + if(nil == _treeDelgate) { + _treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self]; + } + _tree.delegate = _treeDelgate; } } diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 1e35260e..335a2fe0 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -36,6 +36,7 @@ NSString *const kMPSettingsKeyRememeberdKeysForDatabases = @"Rememe NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyForControlKey"; NSString *const kMPSettingsKeyEnableGlobalAutotype = @"EnableGlobalAutotype"; NSString *const kMPSettingsKeyGlobalAutotypeKeyDataKey = @"GlobalAutotypeKeyDataKey"; +NSString *const kMPSettingsKeyDefaultGlobalAutotypeSequence = @"DefaultGlobalAutotypeSequence"; NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext"; @@ -99,6 +100,7 @@ NSString *const kMPDeprecatedSettingsKeyEntrySearchFilterMode = @"En kMPSettingsKeyRememberKeyFilesForDatabases: @NO, kMPSettingsKeySendCommandForControlKey: @YES, kMPSettingsKeyEnableGlobalAutotype: @NO, + kMPSettingsKeyDefaultGlobalAutotypeSequence: @"{USERNAME}{TAB}{PASSWORD}{ENTER}", kMPSettingsKeyEnableQuicklookPreview: @NO, kMPSettingsKeyCopyGeneratedPasswordToClipboard: @NO, kMPSettingsKeyDefaultPasswordRounds: @50000, diff --git a/MacPass/MPTreeDelegate.h b/MacPass/MPTreeDelegate.h index 7f8e945b..fadf8281 100644 --- a/MacPass/MPTreeDelegate.h +++ b/MacPass/MPTreeDelegate.h @@ -9,6 +9,10 @@ #import #import "KPKTree.h" +@class MPDocument; + @interface MPTreeDelegate : NSObject +- (instancetype)initWithDocument:(MPDocument *)document; + @end diff --git a/MacPass/MPTreeDelegate.m b/MacPass/MPTreeDelegate.m index 6b5a20b2..9fa0b171 100644 --- a/MacPass/MPTreeDelegate.m +++ b/MacPass/MPTreeDelegate.m @@ -8,11 +8,32 @@ #import "MPTreeDelegate.h" +#import "MPDocument.h" +#import "MPSettingsHelper.h" + +@interface MPTreeDelegate (); + +@property (weak) MPDocument *document; + +@end + + @implementation MPTreeDelegate +- (instancetype)initWithDocument:(MPDocument *)document { + self = [super init]; + if(self) { + self.document = document; + } + return self; +} + - (NSString *)defaultAutotypeSequenceForTree:(KPKTree *)tree { - /* TODO use Settings for the default autotype sequence */ - return nil; + return [[NSUserDefaults standardUserDefaults] stringForKey:kMPSettingsKeyDefaultGlobalAutotypeSequence]; +} + +- (BOOL)shouldEditTree:(KPKTree *)tree { + return (NO == self.document.isReadOnly); } @end