More progress on Editing

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-08-03 15:56:28 +02:00
parent 83a9bc1f74
commit ae4af18107
23 changed files with 148 additions and 196 deletions

2
HNHUi

Submodule HNHUi updated: 3fecc574c1...108f4519a5

View File

@@ -459,8 +459,6 @@
4C10412B178CDD44001B5239 /* NSDate+Humanized.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+Humanized.m"; sourceTree = "<group>"; };
4C13904C17ADD1A300A62934 /* KPKTreeCrypting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeCrypting.h; sourceTree = "<group>"; };
4C13904D17ADD3BE00A62934 /* KPKTreeWriting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPKTreeWriting.h; sourceTree = "<group>"; };
4C15B73C18BCA379003F8008 /* MPDocument+Attachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Attachment.h"; sourceTree = "<group>"; };
4C15B74418BCA3B1003F8008 /* MPDocument+Search.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Search.h"; sourceTree = "<group>"; };
4C15B74518BCA3B1003F8008 /* MPDocument+Search.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Search.m"; sourceTree = "<group>"; };
4C17D8E317A1C780006C8C1E /* MPDocumentWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentWindowDelegate.h; sourceTree = "<group>"; };
4C17D8E417A1C780006C8C1E /* MPDocumentWindowDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentWindowDelegate.m; sourceTree = "<group>"; };
@@ -497,7 +495,6 @@
4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorWindow.xib; sourceTree = "<group>"; };
4C1E9883185F71A800943563 /* MPContextBarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPContextBarViewController.h; sourceTree = "<group>"; };
4C1E9884185F71A800943563 /* MPContextBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextBarViewController.m; sourceTree = "<group>"; };
4C1FA07918231900003A3F8C /* MPDocument+Autotype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+Autotype.h"; sourceTree = "<group>"; };
4C1FA07A18231900003A3F8C /* MPDocument+Autotype.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Autotype.m"; sourceTree = "<group>"; };
4C21F29D195B39B9002D610D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = "<group>"; };
4C21F29F195B3A48002D610D /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/MainMenu.strings; sourceTree = "<group>"; };
@@ -785,7 +782,6 @@
4C6AEEF71A043E2B00CA2420 /* MPDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentController.h; sourceTree = "<group>"; };
4C6AEEF81A043E2B00CA2420 /* MPDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentController.m; sourceTree = "<group>"; };
4C6AEF021A04400E00CA2420 /* OpenPanelAccessoryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OpenPanelAccessoryView.xib; sourceTree = "<group>"; };
4C6B7C7B18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+HistoryBrowsing.h"; sourceTree = "<group>"; };
4C6B7C7C18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+HistoryBrowsing.m"; sourceTree = "<group>"; };
4C6BC65F1A36717E00BDDF3D /* MPDatabaseSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseSearch.m; sourceTree = "<group>"; };
4C6C72C217C01E4200768849 /* NSMutableData+KeePassKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableData+KeePassKit.h"; sourceTree = "<group>"; };
@@ -1004,7 +1000,6 @@
4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPopupImageView.m; sourceTree = "<group>"; };
4CE3E62417AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAttachmentTableDataSource.h; sourceTree = "<group>"; };
4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAttachmentTableDataSource.m; sourceTree = "<group>"; };
4CE5299F194847150078C2FF /* MPDocument+EditingSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPDocument+EditingSession.h"; sourceTree = "<group>"; };
4CE5B548173AFBA700207B39 /* MPDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocument.h; sourceTree = "<group>"; };
4CE5B549173AFBA700207B39 /* MPDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MPDocument.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4CE76DAC17B3AD010043B82B /* KPKHashedDataTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKHashedDataTest.m; sourceTree = "<group>"; };
@@ -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 */,

View File

@@ -7,7 +7,7 @@
//
#import "MPActionHelper.h"
#import "MPDocument+HistoryBrowsing.h"
#import "MPDocument.h"
#import "MPEntryInspectorViewController.h"
#import "MPEntryViewController.h"
#import "MPDocumentWindowController.h"

View File

@@ -21,7 +21,7 @@
//
#import "MPAttachmentTableDataSource.h"
#import "MPDocument+Attachment.h"
#import "MPDocument.h"
@implementation MPAttachmentTableDataSource

View File

@@ -9,7 +9,6 @@
#import "MPAutotypeDaemon.h"
#import "MPDocument.h"
#import "MPDocument+Autotype.h"
#import "MPAutotypeCommand.h"
#import "MPAutotypeContext.h"
#import "MPAutotypePaste.h"

View File

@@ -7,7 +7,7 @@
//
#import "MPViewController.h"
#import "MPDocument+Search.h"
#import "MPDocument.h"
@class HNHGradientView;
@class MPDocument;

View File

@@ -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"

View File

@@ -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

View File

@@ -20,7 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "MPDocument+Attachment.h"
#import "MPDocument.h"
#import "KPKEntry.h"
#import "KPKBinary.h"

View File

@@ -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 <http://www.gnu.org/licenses/>.
//
#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

View File

@@ -20,7 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "MPDocument+Autotype.h"
#import "MPDocument.h"
#import "MPAutotypeContext.h"
#import "KPKGroup.h"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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";

View File

@@ -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

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPDocument+Search.h"
#import "MPDocument.h"
#import "MPDocumentWindowController.h"

View File

@@ -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

View File

@@ -21,7 +21,6 @@
//
#import "MPDocument.h"
#import "MPDocument+Search.h"
#import "MPAppDelegate.h"
#import "MPDocumentWindowController.h"
#import "MPDatabaseVersion.h"

View File

@@ -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"

View File

@@ -9,7 +9,6 @@
#import "MPFixAutotypeWindowController.h"
#import "MPDocument.h"
#import "MPDocument+Autotype.h"
#import "MPIconHelper.h"
#import "KPKNode.h"

View File

@@ -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";