mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 16:19:29 +00:00
Moving editing session to KeePassKit
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPEditingSession.h"
|
||||
#import "KPKEditingSession.h"
|
||||
|
||||
#import "KPKNode.h"
|
||||
|
||||
@@ -33,14 +33,13 @@ NSString *const MPDocumentDidCommitChangesToSelectedItem = @"com.hicknhack.mac
|
||||
[((NSWindowController *)self.windowControllers.firstObject).window makeFirstResponder:nil];
|
||||
|
||||
/* update the data */
|
||||
[self.editingSession.source updateToNode:self.editingSession.node];
|
||||
if(self.editingSession.node.asEntry) {
|
||||
[self.editingSession.source commitEditing];
|
||||
if(self.editingSession.source.asEntry) {
|
||||
[self.undoManager setActionName:NSLocalizedString(@"UPDATE_ENTRY", "")];
|
||||
}
|
||||
else if(self.editingSession.node.asGroup) {
|
||||
else if(self.editingSession.source.asGroup) {
|
||||
[self.undoManager setActionName:NSLocalizedString(@"UPDATE_GROUP", "")];
|
||||
}
|
||||
self.editingSession = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCommitChangesToSelectedItem object:self];
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ NSString *const MPDocumentDidCommitChangesToSelectedItem = @"com.hicknhack.mac
|
||||
if(nil == self.editingSession) {
|
||||
return; // No session to cancel
|
||||
}
|
||||
self.editingSession = nil;
|
||||
[self.selectedItem cancelEditing];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCancelChangesToSelectedItem object:self];
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ NSString *const MPDocumentDidCommitChangesToSelectedItem = @"com.hicknhack.mac
|
||||
if(nil == self.selectedItem) {
|
||||
return;
|
||||
}
|
||||
self.editingSession = [MPEditingSession editingSessionWithSource:self.selectedItem];
|
||||
[self.selectedItem beginEditing];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidBeginEditingSelectedItem object:self];
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@class KPKAttribute;
|
||||
@class KPKCompositeKey;
|
||||
@class KPKNode;
|
||||
@class MPEditingSession;
|
||||
@class KPKEditingSession;
|
||||
|
||||
@interface MPDocument : NSDocument <MPTargetNodeResolving>
|
||||
|
||||
@@ -88,11 +88,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@property (nonatomic, copy) MPEntrySearchContext *searchContext;
|
||||
@property (nonatomic, strong) NSArray *searchResult;
|
||||
|
||||
/*
|
||||
Editing Session
|
||||
*/
|
||||
@property (nonatomic, strong) MPEditingSession *editingSession;
|
||||
|
||||
+ (KPKVersion)versionForFileType:(NSString *)fileType;
|
||||
+ (NSString *)fileTypeForVersion:(KPKVersion)version;
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
@property (nonatomic, strong) NSData *encryptedData;
|
||||
@property (nonatomic, strong) MPTreeDelegate *treeDelgate;
|
||||
|
||||
|
||||
@property (assign) BOOL readOnly;
|
||||
@property (strong) NSURL *lockFileURL;
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// MPEditSession.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 30/05/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class KPKNode;
|
||||
|
||||
@interface MPEditingSession : NSObject
|
||||
|
||||
@property (copy, readonly) KPKNode *node;
|
||||
@property (nullable, weak, readonly) KPKNode *source;
|
||||
|
||||
+ (instancetype)editingSessionWithSource:(KPKNode *)node;
|
||||
- (instancetype)initWithSource:(KPKNode *)node;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
- (BOOL)hasChanges;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// MPEditSession.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 30/05/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPEditingSession.h"
|
||||
#import "KPKNode.h"
|
||||
|
||||
@interface MPEditingSession ()
|
||||
|
||||
@property (copy) KPKNode *node;
|
||||
@property (weak) KPKNode *source;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPEditingSession
|
||||
|
||||
+ (instancetype)editingSessionWithSource:(KPKNode *)node {
|
||||
return [[MPEditingSession alloc] initWithSource:node];
|
||||
}
|
||||
|
||||
- (instancetype)initWithSource:(KPKNode *)node {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.node = node;
|
||||
self.source = node;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hasChanges {
|
||||
return ![self.node isEqual:self.source];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "MPInspectorViewController.h"
|
||||
#import "MPDatePickingViewController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPEditingSession.h"
|
||||
#import "KPKEditingSession.h"
|
||||
#import "MPEntryInspectorViewController.h"
|
||||
#import "MPGroupInspectorViewController.h"
|
||||
#import "MPIconHelper.h"
|
||||
|
||||
Reference in New Issue
Block a user