From ae4af1810768f18c4003df2ad70e29ca05beffaf Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 3 Aug 2015 15:56:28 +0200 Subject: [PATCH] More progress on Editing Signed-off-by: michael starke --- HNHUi | 2 +- KeePassKit | 2 +- MacPass.xcodeproj/project.pbxproj | 10 --- MacPass/MPActionHelper.m | 2 +- MacPass/MPAttachmentTableDataSource.m | 2 +- MacPass/MPAutotypeDaemon.m | 1 - MacPass/MPContextBarViewController.h | 2 +- MacPass/MPContextBarViewController.m | 3 +- MacPass/MPDocument+Attachment.h | 15 ---- MacPass/MPDocument+Attachments.m | 2 +- MacPass/MPDocument+Autotype.h | 56 ------------- MacPass/MPDocument+Autotype.m | 2 +- MacPass/MPDocument+EditingSession.h | 19 ----- MacPass/MPDocument+EditingSession.m | 54 +++++++----- MacPass/MPDocument+HistoryBrowsing.h | 19 ----- MacPass/MPDocument+HistoryBrowsing.m | 2 +- MacPass/MPDocument+Search.h | 37 --------- MacPass/MPDocument+Search.m | 1 - MacPass/MPDocument.h | 106 ++++++++++++++++++++++++ MacPass/MPDocument.m | 1 - MacPass/MPEntryViewController.m | 3 - MacPass/MPFixAutotypeWindowController.m | 1 - MacPass/MPToolbarDelegate.m | 2 +- 23 files changed, 148 insertions(+), 196 deletions(-) delete mode 100644 MacPass/MPDocument+Attachment.h delete mode 100644 MacPass/MPDocument+Autotype.h delete mode 100644 MacPass/MPDocument+EditingSession.h delete mode 100644 MacPass/MPDocument+HistoryBrowsing.h delete mode 100644 MacPass/MPDocument+Search.h diff --git a/HNHUi b/HNHUi index 3fecc574..108f4519 160000 --- a/HNHUi +++ b/HNHUi @@ -1 +1 @@ -Subproject commit 3fecc574c1cdd666461981b568a413e6d1930edd +Subproject commit 108f4519a573c26610f7b7f69e72e4405ee420bd diff --git a/KeePassKit b/KeePassKit index 25b5fd84..870d252a 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 25b5fd840b526846f442ffa1b1ca0caa5d933e02 +Subproject commit 870d252a2915a2f00326e85bfecebde26f003dca diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index d7d24142..de3f6c72 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -459,8 +459,6 @@ 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+Humanized.m"; sourceTree = ""; }; 4C13904C17ADD1A300A62934 /* KPKTreeCrypting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeCrypting.h; sourceTree = ""; }; 4C13904D17ADD3BE00A62934 /* KPKTreeWriting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeWriting.h; sourceTree = ""; }; - 4C15B73C18BCA379003F8008 /* MPDocument+Attachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Attachment.h"; sourceTree = ""; }; - 4C15B74418BCA3B1003F8008 /* MPDocument+Search.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Search.h"; sourceTree = ""; }; 4C15B74518BCA3B1003F8008 /* MPDocument+Search.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Search.m"; sourceTree = ""; }; 4C17D8E317A1C780006C8C1E /* MPDocumentWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentWindowDelegate.h; sourceTree = ""; }; 4C17D8E417A1C780006C8C1E /* MPDocumentWindowDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentWindowDelegate.m; sourceTree = ""; }; @@ -497,7 +495,6 @@ 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = ""; }; 4C1E9883185F71A800943563 /* MPContextBarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPContextBarViewController.h; sourceTree = ""; }; 4C1E9884185F71A800943563 /* MPContextBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextBarViewController.m; sourceTree = ""; }; - 4C1FA07918231900003A3F8C /* MPDocument+Autotype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Autotype.h"; sourceTree = ""; }; 4C1FA07A18231900003A3F8C /* MPDocument+Autotype.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Autotype.m"; sourceTree = ""; }; 4C21F29D195B39B9002D610D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = ""; }; 4C21F29F195B3A48002D610D /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/MainMenu.strings; sourceTree = ""; }; @@ -785,7 +782,6 @@ 4C6AEEF71A043E2B00CA2420 /* MPDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentController.h; sourceTree = ""; }; 4C6AEEF81A043E2B00CA2420 /* MPDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentController.m; sourceTree = ""; }; 4C6AEF021A04400E00CA2420 /* OpenPanelAccessoryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OpenPanelAccessoryView.xib; sourceTree = ""; }; - 4C6B7C7B18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+HistoryBrowsing.h"; sourceTree = ""; }; 4C6B7C7C18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+HistoryBrowsing.m"; sourceTree = ""; }; 4C6BC65F1A36717E00BDDF3D /* MPDatabaseSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseSearch.m; sourceTree = ""; }; 4C6C72C217C01E4200768849 /* NSMutableData+KeePassKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableData+KeePassKit.h"; sourceTree = ""; }; @@ -1004,7 +1000,6 @@ 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPopupImageView.m; sourceTree = ""; }; 4CE3E62417AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAttachmentTableDataSource.h; sourceTree = ""; }; 4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAttachmentTableDataSource.m; sourceTree = ""; }; - 4CE5299F194847150078C2FF /* MPDocument+EditingSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+EditingSession.h"; sourceTree = ""; }; 4CE5B548173AFBA700207B39 /* MPDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocument.h; sourceTree = ""; }; 4CE5B549173AFBA700207B39 /* MPDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MPDocument.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4CE76DAC17B3AD010043B82B /* KPKHashedDataTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKHashedDataTest.m; sourceTree = ""; }; @@ -1515,15 +1510,10 @@ 6E719715172058BA00E4C5FC /* MPDatabaseVersion.h */, 4CE5B548173AFBA700207B39 /* MPDocument.h */, 4CE5B549173AFBA700207B39 /* MPDocument.m */, - 4C15B73C18BCA379003F8008 /* MPDocument+Attachment.h */, 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */, - 4C1FA07918231900003A3F8C /* MPDocument+Autotype.h */, 4C1FA07A18231900003A3F8C /* MPDocument+Autotype.m */, - 4C15B74418BCA3B1003F8008 /* MPDocument+Search.h */, 4C15B74518BCA3B1003F8008 /* MPDocument+Search.m */, - 4C6B7C7B18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.h */, 4C6B7C7C18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.m */, - 4CE5299F194847150078C2FF /* MPDocument+EditingSession.h */, 4C94A0711938DDC20040ABAB /* MPDocument+EditingSession.m */, 4C94A06D1938DC8C0040ABAB /* MPEditingSession.h */, 4C94A06E1938DC8C0040ABAB /* MPEditingSession.m */, diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m index e629b779..4692ddfb 100644 --- a/MacPass/MPActionHelper.m +++ b/MacPass/MPActionHelper.m @@ -7,7 +7,7 @@ // #import "MPActionHelper.h" -#import "MPDocument+HistoryBrowsing.h" +#import "MPDocument.h" #import "MPEntryInspectorViewController.h" #import "MPEntryViewController.h" #import "MPDocumentWindowController.h" diff --git a/MacPass/MPAttachmentTableDataSource.m b/MacPass/MPAttachmentTableDataSource.m index 18ad9902..5673b390 100644 --- a/MacPass/MPAttachmentTableDataSource.m +++ b/MacPass/MPAttachmentTableDataSource.m @@ -21,7 +21,7 @@ // #import "MPAttachmentTableDataSource.h" -#import "MPDocument+Attachment.h" +#import "MPDocument.h" @implementation MPAttachmentTableDataSource diff --git a/MacPass/MPAutotypeDaemon.m b/MacPass/MPAutotypeDaemon.m index 3485f065..1da809b0 100644 --- a/MacPass/MPAutotypeDaemon.m +++ b/MacPass/MPAutotypeDaemon.m @@ -9,7 +9,6 @@ #import "MPAutotypeDaemon.h" #import "MPDocument.h" -#import "MPDocument+Autotype.h" #import "MPAutotypeCommand.h" #import "MPAutotypeContext.h" #import "MPAutotypePaste.h" diff --git a/MacPass/MPContextBarViewController.h b/MacPass/MPContextBarViewController.h index 0ed45c0d..6fa02391 100644 --- a/MacPass/MPContextBarViewController.h +++ b/MacPass/MPContextBarViewController.h @@ -7,7 +7,7 @@ // #import "MPViewController.h" -#import "MPDocument+Search.h" +#import "MPDocument.h" @class HNHGradientView; @class MPDocument; diff --git a/MacPass/MPContextBarViewController.m b/MacPass/MPContextBarViewController.m index bdb0a0ad..8280dbc9 100644 --- a/MacPass/MPContextBarViewController.m +++ b/MacPass/MPContextBarViewController.m @@ -11,8 +11,7 @@ #import "KPKTree.h" #import "KPKMetaData.h" -#import "MPDocument+HistoryBrowsing.h" -#import "MPDocument+Search.h" +#import "MPDocument.h" #import "MPFlagsHelper.h" #import "MPEntrySearchContext.h" diff --git a/MacPass/MPDocument+Attachment.h b/MacPass/MPDocument+Attachment.h deleted file mode 100644 index 5d9f7836..00000000 --- a/MacPass/MPDocument+Attachment.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// MPDocument+Attachment.h -// MacPass -// -// Created by Michael Starke on 25.02.14. -// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. -// - -#import "MPDocument.h" - -@interface MPDocument (Attachments) - -- (void)addAttachment:(NSURL *)location toEntry:(KPKEntry *)anEntry; - -@end \ No newline at end of file diff --git a/MacPass/MPDocument+Attachments.m b/MacPass/MPDocument+Attachments.m index 3c6f8b23..8b77b966 100644 --- a/MacPass/MPDocument+Attachments.m +++ b/MacPass/MPDocument+Attachments.m @@ -20,7 +20,7 @@ // along with this program. If not, see . // -#import "MPDocument+Attachment.h" +#import "MPDocument.h" #import "KPKEntry.h" #import "KPKBinary.h" diff --git a/MacPass/MPDocument+Autotype.h b/MacPass/MPDocument+Autotype.h deleted file mode 100644 index 1d82e084..00000000 --- a/MacPass/MPDocument+Autotype.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// MPDocument+Autotype.h -// MacPass -// -// Created by Michael Starke on 01/11/13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#import "MPDocument.h" - -@interface MPDocument (Autotype) - -/** -* Tests the given item for a possible wrong autotype format -* MacPass 0.4 and 0.4.1 did store wrong Autotype sequences and thus mangled database files -* -* @param item Item to test for malformation. Allowed Items are KPKNode, KPKEntry, KPKGroup and KPKAutotype -* -* @return YES if the given item is considered a possible candidate. NO in all other cases -*/ -+ (BOOL)isCandidateForMalformedAutotype:(id)item; - -/** - * Returns an NSArray containing all Autotype Contexts that match the given window title. - * If no entry is set, all entries in the document will be searched - * - * @param windowTitle Window title to search matches for - * @param entry Entry to use for lookup. If nil lookup will be performed in complete document - * - * @return NSArray of MPAutotypeContext objects matching the window title. - */ -- (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle preferredEntry:(KPKEntry *)entryOrNil; -/** - * Checks if the document has malformed autotype items - * - * @return YES if any malformed items are found - */ -- (BOOL)hasMalformedAutotypeItems; - -- (NSArray *)malformedAutotypeItems; - -@end diff --git a/MacPass/MPDocument+Autotype.m b/MacPass/MPDocument+Autotype.m index 46bb8840..babb032d 100644 --- a/MacPass/MPDocument+Autotype.m +++ b/MacPass/MPDocument+Autotype.m @@ -20,7 +20,7 @@ // along with this program. If not, see . // -#import "MPDocument+Autotype.h" +#import "MPDocument.h" #import "MPAutotypeContext.h" #import "KPKGroup.h" diff --git a/MacPass/MPDocument+EditingSession.h b/MacPass/MPDocument+EditingSession.h deleted file mode 100644 index ac9819dc..00000000 --- a/MacPass/MPDocument+EditingSession.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// MPDocument+EditingSession.h -// MacPass -// -// Created by Michael Starke on 30/05/14. -// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. -// - -#import "MPDocument.h" - -@class MPEditingSession; - -@interface MPDocument (EditingSession) - -- (BOOL)hasActiveSession; -- (void)cancelEditingSession; -- (void)commitEditingSession; - -@end diff --git a/MacPass/MPDocument+EditingSession.m b/MacPass/MPDocument+EditingSession.m index b63f952c..886eba19 100644 --- a/MacPass/MPDocument+EditingSession.m +++ b/MacPass/MPDocument+EditingSession.m @@ -6,43 +6,53 @@ // Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. // -#import "MPDocument+EditingSession.h" +#import "MPDocument.h" +#import "MPEditingSession.h" #import "KPKNode.h" -#import "MPEditingSession.h" + +NSString *const MPDocumentDidBeginEditingSelectedItem = @"com.hicknhack.macpass.MPDocumentDidBeginEditingSelectedItem"; +NSString *const MPDocumentDidCancelChangesToSelectedItem = @"com.hicknhack.macpass.MPDocumentDidCancelChangesToSelectedItem"; +NSString *const MPDocumentDidCommitChangesToSelectedItem = @"com.hicknhack.macpass.MPDocumentDidCommitChangesToSelectedItem"; @implementation MPDocument (EditingSession) -- (BOOL)hasActiveSession { +- (BOOL)isEditing { return (self.editingSession != nil); } -- (void)commitEditingSession { - [self _commitEditingSession:self.editingSession]; -} - -- (void)cancelEditingSession { - [self _cancelEditingSession:self.editingSession]; -} - -#pragma mark Private -- (void)_commitEditingSession:(MPEditingSession *)session { - if(nil == session) { +- (void)commitChangesToSelectedItem:(id)sender { + if(nil == self.editingSession) { return; // No session to commit } - [[self.undoManager prepareWithInvocationTarget:self] _cancelEditingSession:session]; - if(session.hasChanges) { - } + /* Force any lingering updates to be written */ + /* FIXME explore potential usage of: + * NSObject(NSEditorRegistration) + * NSObject(NSEditor) + */ + [((NSWindowController *)self.windowControllers.firstObject).window makeFirstResponder:nil]; + + /* update the data */ + [self.editingSession.source updateToNode:self.editingSession.node]; + [self.undoManager setActionName:NSLocalizedString(@"UPDATE_ENTRY", "")]; + self.editingSession = nil; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCommitChangesToSelectedItem object:self]; } -- (void)_cancelEditingSession:(MPEditingSession *)session { - if(nil == session) { +- (void)cancelChangesToSelectedItem:(id)sender { + if(nil == self.editingSession) { return; // No session to cancel } - [[self.undoManager prepareWithInvocationTarget:self] _commitEditingSession:session]; - if(session.hasChanges) { - [session.node updateToNode:session.rollbackNode]; + self.editingSession = nil; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCancelChangesToSelectedItem object:self]; +} + +- (void)beginEditingSelectedItem:(id)sender { + if(nil == self.selectedItem) { + return; } + self.editingSession = [[MPEditingSession alloc] initWithSource:self.selectedItem]; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidBeginEditingSelectedItem object:self]; } @end diff --git a/MacPass/MPDocument+HistoryBrowsing.h b/MacPass/MPDocument+HistoryBrowsing.h deleted file mode 100644 index 7acd9a86..00000000 --- a/MacPass/MPDocument+HistoryBrowsing.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// MPDocument+HistoryBrowsing.h -// MacPass -// -// Created by Michael Starke on 26.02.14. -// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. -// - -#import "MPDocument.h" - -FOUNDATION_EXPORT NSString *const MPDocumentDidEnterHistoryNotification; -FOUNDATION_EXPORT NSString *const MPDocumentDidExitHistoryNotification; - -@interface MPDocument (HistoryBrowsing) - -- (IBAction)showHistory:(id)sender; -- (IBAction)exitHistory:(id)sender; - -@end diff --git a/MacPass/MPDocument+HistoryBrowsing.m b/MacPass/MPDocument+HistoryBrowsing.m index c4af067f..61c33c97 100644 --- a/MacPass/MPDocument+HistoryBrowsing.m +++ b/MacPass/MPDocument+HistoryBrowsing.m @@ -6,7 +6,7 @@ // Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. // -#import "MPDocument+HistoryBrowsing.h" +#import "MPDocument.h" NSString *const MPDocumentDidEnterHistoryNotification = @"MPDocumentDidEnterHistoryNotification"; NSString *const MPDocumentDidExitHistoryNotification = @"MPDocumentDidExitHistoryNotification"; diff --git a/MacPass/MPDocument+Search.h b/MacPass/MPDocument+Search.h deleted file mode 100644 index c3f01c5e..00000000 --- a/MacPass/MPDocument+Search.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// MPDocument+Search.h -// MacPass -// -// Created by Michael Starke on 25.02.14. -// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. -// - -#import "MPDocument.h" - -@class MPEntrySearchContext; - -FOUNDATION_EXTERN NSString *const MPDocumentDidEnterSearchNotification; -FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchFlags; -FOUNDATION_EXTERN NSString *const MPDocumentDidExitSearchNotification; -/** - * Posted by the document, when the search results have been updated. This is only called when searching. - * If the search is exited, it will be notified by MPDocumentDidExitSearchNotification - * The userInfo dictionary has one key kMPDocumentSearchResultsKey with an NSArray of KPKEntries matching the search. - */ -FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchResults; - -/* keys used in userInfo dictionaries on notifications */ -FOUNDATION_EXTERN NSString *const kMPDocumentSearchResultsKey; - -@interface MPDocument (Search) - -- (void)enterSearchWithContext:(MPEntrySearchContext *)context; - -/* Should be called by the NSSearchTextField to update the search string */ -- (IBAction)updateSearch:(id)sender; -/* exits searching mode */ -- (IBAction)exitSearch:(id)sender; -/* called by the filter toggle buttons */ -- (IBAction)toggleSearchFlags:(id)sender; - -@end diff --git a/MacPass/MPDocument+Search.m b/MacPass/MPDocument+Search.m index 15326746..aff97b36 100644 --- a/MacPass/MPDocument+Search.m +++ b/MacPass/MPDocument+Search.m @@ -6,7 +6,6 @@ // Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. // -#import "MPDocument+Search.h" #import "MPDocument.h" #import "MPDocumentWindowController.h" diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 1e4a341b..37fc832b 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -175,3 +175,109 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; - (IBAction)duplicateEntryWithOptions:(id)sender; @end + +@interface MPDocument (Attachments) + +- (void)addAttachment:(NSURL *)location toEntry:(KPKEntry *)anEntry; + +@end + +#pragma mark - +#pragma mark Autotype + +@interface MPDocument (Autotype) + +/** + * Tests the given item for a possible wrong autotype format + * MacPass 0.4 and 0.4.1 did store wrong Autotype sequences and thus mangled database files + * + * @param item Item to test for malformation. Allowed Items are KPKNode, KPKEntry, KPKGroup and KPKAutotype + * + * @return YES if the given item is considered a possible candiate. NO in all other cases + */ ++ (BOOL)isCandidateForMalformedAutotype:(id)item; + +/** + * Returns an NSArray containing all Autotype Contexts that match the given window title. + * If no entry is set, all entries in the document will be searched + * + * @param windowTitle Window title to search matches for + * @param entry Entry to use for lookup. If nil lookup will be performed in complete document + * + * @return NSArray of MPAutotypeContext objects matching the window title. + */ +- (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle preferredEntry:(KPKEntry *)entryOrNil; +/** + * Checks if the document has malformed autotype items + * + * @return YES if any malformed items are found + */ +- (BOOL)hasMalformedAutotypeItems; + +- (NSArray *)malformedAutotypeItems; + +@end + +#pragma mark - +#pragma mark Edit Sessiong + +APPKIT_EXTERN NSString *const MPDocumentDidBeginEditingSelectedItem; +APPKIT_EXTERN NSString *const MPDocumentDidCancelChangesToSelectedItem; +APPKIT_EXTERN NSString *const MPDocumentDidCommitChangesToSelectedItem; + +@interface MPDocument (EditingSession) + +- (BOOL)isEditing; + +#pragma mark Edit Actions +- (IBAction)beginEditingSelectedItem:(id)sender; +- (IBAction)cancelChangesToSelectedItem:(id)sender; +- (IBAction)commitChangesToSelectedItem:(id)sender; + +@end + + +#pragma mark - +#pragma mark History Browsing + +FOUNDATION_EXPORT NSString *const MPDocumentDidEnterHistoryNotification; +FOUNDATION_EXPORT NSString *const MPDocumentDidExitHistoryNotification; + +@interface MPDocument (HistoryBrowsing) + +- (IBAction)showHistory:(id)sender; +- (IBAction)exitHistory:(id)sender; + +@end + +#pragma mark - +#pragma mark Search + +FOUNDATION_EXTERN NSString *const MPDocumentDidEnterSearchNotification; +FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchFlags; +FOUNDATION_EXTERN NSString *const MPDocumentDidExitSearchNotification; +/** + * Posted by the document, when the search results have been updated. This is only called when searching. + * If the search is exited, it will be notified by MPDocumentDidExitSearchNotification + * The userInfo dictionary has one key kMPDocumentSearchResultsKey with an NSArray of KPKEntries mathching the search. + */ +FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchResults; + +/* keys used in userInfo dictionaries on notifications */ +FOUNDATION_EXTERN NSString *const kMPDocumentSearchResultsKey; + +@interface MPDocument (Search) + +- (void)enterSearchWithContext:(MPEntrySearchContext *)context; + +/* Should be called by the NSSearchTextField to update the search string */ +- (IBAction)updateSearch:(id)sender; +/* exits searching mode */ +- (IBAction)exitSearch:(id)sender; +/* called by the filter toggle buttons */ +- (IBAction)toggleSearchFlags:(id)sender; + +@end + + + diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index b5906005..f8e49275 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -21,7 +21,6 @@ // #import "MPDocument.h" -#import "MPDocument+Search.h" #import "MPAppDelegate.h" #import "MPDocumentWindowController.h" #import "MPDatabaseVersion.h" diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 895d1f30..70a3fc1d 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -11,9 +11,6 @@ #import "MPOutlineViewController.h" #import "MPDocument.h" -#import "MPDocument+Search.h" -#import "MPDocument+Autotype.h" -#import "MPDocument+HistoryBrowsing.h" #import "MPDocumentWindowController.h" #import "MPPasteBoardController.h" diff --git a/MacPass/MPFixAutotypeWindowController.m b/MacPass/MPFixAutotypeWindowController.m index c2346ea6..7f11de75 100644 --- a/MacPass/MPFixAutotypeWindowController.m +++ b/MacPass/MPFixAutotypeWindowController.m @@ -9,7 +9,6 @@ #import "MPFixAutotypeWindowController.h" #import "MPDocument.h" -#import "MPDocument+Autotype.h" #import "MPIconHelper.h" #import "KPKNode.h" diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index 6cc1c0d9..2a4243b1 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -32,7 +32,7 @@ #import "MPIconHelper.h" #import "MPDocumentWindowController.h" -#import "MPDocument+Search.h" +#import "MPDocument.h" NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK"; NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP";