mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
First running Version that used document based architecture. Search is broken.
This commit is contained in:
@@ -71,7 +71,6 @@
|
||||
4C669BA216760ED100DD0774 /* UUID.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B7B16760ED100DD0774 /* UUID.m */; };
|
||||
4C69A73A16D589DF00EC1B1A /* MPGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C69A73916D589DF00EC1B1A /* MPGradientView.m */; };
|
||||
4C6B0E8C16C9B99B00A9ED23 /* PasswordInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */; };
|
||||
4C75CE3C16CB128700F61A4D /* MPDatabaseController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C75CE3B16CB128700F61A4D /* MPDatabaseController.m */; };
|
||||
4C77547516E55FE800970E02 /* MPInspectorTabViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77547416E55FE800970E02 /* MPInspectorTabViewController.m */; };
|
||||
4C77547716E55FFC00970E02 /* InspectorTabView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77547616E55FFC00970E02 /* InspectorTabView.xib */; };
|
||||
4C77E36715B84A240093A587 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77E36615B84A240093A587 /* Cocoa.framework */; };
|
||||
@@ -103,7 +102,6 @@
|
||||
4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; };
|
||||
4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; };
|
||||
4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */; };
|
||||
4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */; };
|
||||
4CBFA240172B385D006090DF /* PasswordEditView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CBFA23F172B385D006090DF /* PasswordEditView.xib */; };
|
||||
4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; };
|
||||
4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */; };
|
||||
@@ -241,8 +239,6 @@
|
||||
4C69A73816D589DF00EC1B1A /* MPGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGradientView.h; sourceTree = "<group>"; };
|
||||
4C69A73916D589DF00EC1B1A /* MPGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGradientView.m; sourceTree = "<group>"; };
|
||||
4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordInputView.xib; sourceTree = "<group>"; };
|
||||
4C75CE3A16CB128700F61A4D /* MPDatabaseController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseController.h; sourceTree = "<group>"; };
|
||||
4C75CE3B16CB128700F61A4D /* MPDatabaseController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseController.m; sourceTree = "<group>"; };
|
||||
4C77547316E55FE800970E02 /* MPInspectorTabViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPInspectorTabViewController.h; sourceTree = "<group>"; };
|
||||
4C77547416E55FE800970E02 /* MPInspectorTabViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPInspectorTabViewController.m; sourceTree = "<group>"; };
|
||||
4C77547616E55FFC00970E02 /* InspectorTabView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InspectorTabView.xib; sourceTree = "<group>"; };
|
||||
@@ -302,8 +298,6 @@
|
||||
4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
4CBA2AB617074B59006D8139 /* MPSettingsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsHelper.h; sourceTree = "<group>"; };
|
||||
4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsHelper.m; sourceTree = "<group>"; };
|
||||
4CBA981615BA0DB600721965 /* MPDatabaseDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseDocument.h; sourceTree = "<group>"; };
|
||||
4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseDocument.m; sourceTree = "<group>"; };
|
||||
4CBFA23F172B385D006090DF /* PasswordEditView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordEditView.xib; sourceTree = "<group>"; };
|
||||
4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = "<group>"; };
|
||||
4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbTree+MPAdditions.m"; sourceTree = "<group>"; };
|
||||
@@ -425,8 +419,6 @@
|
||||
children = (
|
||||
4C37A83E15B8B474005EF8EE /* MPOutlineDataSource.h */,
|
||||
4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */,
|
||||
4CBA981615BA0DB600721965 /* MPDatabaseDocument.h */,
|
||||
4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */,
|
||||
6E719715172058BA00E4C5FC /* MPDatabaseVersion.h */,
|
||||
4CE5B548173AFBA700207B39 /* MPDocument.h */,
|
||||
4CE5B549173AFBA700207B39 /* MPDocument.m */,
|
||||
@@ -759,8 +751,6 @@
|
||||
4CE8247116E2E98200573141 /* Data Controller */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4C75CE3A16CB128700F61A4D /* MPDatabaseController.h */,
|
||||
4C75CE3B16CB128700F61A4D /* MPDatabaseController.m */,
|
||||
4C431BCB16E2A82700700A81 /* MPPasteBoardController.h */,
|
||||
4C431BCC16E2A82700700A81 /* MPPasteBoardController.m */,
|
||||
);
|
||||
@@ -896,7 +886,6 @@
|
||||
4CAD747E15B887FD00104512 /* DDXMLElement.m in Sources */,
|
||||
4CAD747F15B887FD00104512 /* DDXMLNode.m in Sources */,
|
||||
4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */,
|
||||
4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */,
|
||||
4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */,
|
||||
4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */,
|
||||
4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */,
|
||||
@@ -936,7 +925,6 @@
|
||||
4C669BA016760ED100DD0774 /* Salsa20RandomStream.m in Sources */,
|
||||
4C669BA116760ED100DD0774 /* Utils.m in Sources */,
|
||||
4C669BA216760ED100DD0774 /* UUID.m in Sources */,
|
||||
4C75CE3C16CB128700F61A4D /* MPDatabaseController.m in Sources */,
|
||||
4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */,
|
||||
4C2E382616D1470200037A9D /* MPViewController.m in Sources */,
|
||||
4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */,
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPSettingsWindowController.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPPasswordCreatorViewController.h"
|
||||
#import "MPActionHelper.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// MPDatabaseController.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by michael starke on 13.02.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MPDatabaseVersion.h"
|
||||
|
||||
/*
|
||||
Notification is posted, when a database is loaded
|
||||
The userInfo dictionary contains the following keys
|
||||
MPDatabaseControllerDatabaseKey
|
||||
*/
|
||||
APPKIT_EXTERN NSString *const MPDatabaseControllerDidLoadDatabaseNotification;
|
||||
APPKIT_EXTERN NSString *const MPDatabaseControllerDidCloseDatabaseNotification;
|
||||
/*
|
||||
Database loaded or closed
|
||||
*/
|
||||
APPKIT_EXTERN NSString *const MPDatabaseControllerDatabaseKey;
|
||||
|
||||
|
||||
@class MPDatabaseDocument;
|
||||
|
||||
@interface MPDatabaseController : NSObject
|
||||
|
||||
@property (retain, readonly, nonatomic) MPDatabaseDocument *database;
|
||||
|
||||
+ (MPDatabaseController *)defaultController;
|
||||
+ (BOOL)hasOpenDatabase;
|
||||
|
||||
- (MPDatabaseDocument *)createDatabase:(MPDatabaseVersion)version password:(NSString *)password keyfile:(NSURL *)key;
|
||||
- (MPDatabaseDocument *)openDatabase:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key;
|
||||
- (MPDatabaseDocument *)newDatabaseAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)version password:(NSString *)password keyfile:(NSURL *)key;
|
||||
|
||||
@end
|
||||
@@ -1,85 +0,0 @@
|
||||
//
|
||||
// MPDatabaseController.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by michael starke on 13.02.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
|
||||
NSString *const MPDatabaseControllerDidLoadDatabaseNotification = @"com.macpass.MPDatabaseControllerDidLoadDatabaseNotification";
|
||||
NSString *const MPDatabaseControllerDidCloseDatabaseNotification = @"com.macpass.MPDatabaseControllerDidCloseDatabaseNotification";
|
||||
NSString *const MPDatabaseControllerDatabaseKey = @"com.macpass.MPDatabaseControllerDatabaseKey";
|
||||
|
||||
@interface MPDatabaseController ()
|
||||
|
||||
@property (retain) MPDatabaseDocument *database;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPDatabaseController
|
||||
|
||||
+ (MPDatabaseController *)defaultController {
|
||||
static MPDatabaseController *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[MPDatabaseController alloc] init];
|
||||
});
|
||||
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
+ (BOOL)hasOpenDatabase {
|
||||
return (nil != [MPDatabaseController defaultController].database);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
// nothing to do;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
self.database = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (MPDatabaseDocument *)createDatabase:(MPDatabaseVersion)version password:(NSString *)password keyfile:(NSURL *)key {
|
||||
return self.database;
|
||||
}
|
||||
|
||||
- (MPDatabaseDocument *)newDatabaseAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)version password:(NSString *)password keyfile:(NSURL *)key {
|
||||
self.database = [MPDatabaseDocument newDocumentAtURL:url databaseVersion:version password:password keyfile:key];
|
||||
return self.database;
|
||||
}
|
||||
|
||||
- (MPDatabaseDocument *)openDatabase:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key {
|
||||
self.database = [MPDatabaseDocument documentWithFile:file password:password keyfile:key];
|
||||
return self.database;
|
||||
}
|
||||
|
||||
- (void)setDatabase:(MPDatabaseDocument *)database {
|
||||
if(_database != database) {
|
||||
if(_database) {
|
||||
NSDictionary *userInfo = @{ MPDatabaseControllerDatabaseKey: _database };
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDatabaseControllerDidCloseDatabaseNotification
|
||||
object:self
|
||||
userInfo:userInfo];
|
||||
}
|
||||
[_database release];
|
||||
_database = [database retain];
|
||||
if(database) {
|
||||
NSDictionary *userInfo = @{ MPDatabaseControllerDatabaseKey: _database };
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDatabaseControllerDidLoadDatabaseNotification
|
||||
object:self
|
||||
userInfo:userInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// MPDocument.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 21.07.12.
|
||||
// Copyright (c) 2012 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MPDatabaseVersion.h"
|
||||
|
||||
APPKIT_EXTERN NSString *const MPDidLoadDatabaseNotification;
|
||||
APPKIT_EXTERN NSString *const MPDatabaseDocumentDocumentKey;
|
||||
|
||||
@class KdbPassword;
|
||||
@class KdbGroup;
|
||||
@class KdbEntry;
|
||||
|
||||
@interface MPDatabaseDocument : NSObject
|
||||
|
||||
@property (assign, readonly) KdbGroup *root;
|
||||
@property (retain, readonly) NSURL *file;
|
||||
@property (nonatomic,retain) NSString *password;
|
||||
@property (nonatomic, retain) NSURL *key;
|
||||
@property (assign, readonly) MPDatabaseVersion version;
|
||||
|
||||
+ (id)documentWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key;
|
||||
+ (id)newDocument:(MPDatabaseVersion)version;
|
||||
+ (id)newDocumentAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)dbversion password:(NSString *)password keyfile:(NSURL *)key;
|
||||
- (id)initWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key;
|
||||
- (id)initWithNewDatabase:(MPDatabaseVersion)version;
|
||||
- (id)initNewDocumentAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)dbversion password:(NSString *)password keyfile:(NSURL *)key;
|
||||
/*
|
||||
Saves the current database to the filesystem
|
||||
Tries to use the stored password and file path
|
||||
|
||||
If self.file and self.password aren't valid, the save does not get executed
|
||||
*/
|
||||
- (BOOL)save;
|
||||
- (BOOL)saveAsFile:(NSURL *)file withPassword:(NSString *)password keyfile:(NSURL *)key;
|
||||
|
||||
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
||||
|
||||
|
||||
@end
|
||||
@@ -1,170 +0,0 @@
|
||||
//
|
||||
// MPDocument.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 21.07.12.
|
||||
// Copyright (c) 2012 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "KdbLib.h"
|
||||
#import "Kdb4Node.h"
|
||||
#import "Kdb3Node.h"
|
||||
|
||||
NSString *const MPDidLoadDatabaseNotification = @"DidLoadDataBaseNotification";
|
||||
|
||||
@interface MPDatabaseDocument ()
|
||||
|
||||
@property (retain) KdbTree *tree;
|
||||
@property (retain) NSURL *file;
|
||||
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
||||
@property (assign) MPDatabaseVersion version;
|
||||
@property (readonly)BOOL isNewFile;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPDatabaseDocument
|
||||
|
||||
+ (id)documentWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key {
|
||||
return [[[MPDatabaseDocument alloc] initWithFile:file password:password keyfile:key] autorelease];
|
||||
}
|
||||
|
||||
+ (id)newDocument:(MPDatabaseVersion)version {
|
||||
return [[[MPDatabaseDocument alloc] initWithNewDatabase:version] autorelease];
|
||||
}
|
||||
|
||||
+ (id)newDocumentAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)dbversion password:(NSString *)password keyfile:(NSURL *)key {
|
||||
return [[[MPDatabaseDocument alloc] initNewDocumentAtURL:url databaseVersion:dbversion password:password keyfile:key] autorelease];
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
// create empty document
|
||||
return [self initWithFile:nil password:nil keyfile:nil];
|
||||
}
|
||||
|
||||
|
||||
- (id)initNewDocumentAtURL:(NSURL *)url databaseVersion:(MPDatabaseVersion)dbversion password:(NSString *)password keyfile:(NSURL *)key
|
||||
{
|
||||
self = [self initWithNewDatabase:dbversion];
|
||||
if(self) {
|
||||
self.file = url;
|
||||
self.password = password;
|
||||
self.key = key;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
Initalizer for creating
|
||||
*/
|
||||
- (id)initWithNewDatabase:(MPDatabaseVersion)version {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
switch(version) {
|
||||
case MPDatabaseVersion3:
|
||||
self.tree = [[[Kdb3Tree alloc] init] autorelease];
|
||||
break;
|
||||
case MPDatabaseVersion4:
|
||||
self.tree = [[[Kdb4Tree alloc] init] autorelease];
|
||||
break;
|
||||
default:
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
KdbGroup *newGroup = [self.tree createGroup:self.tree.root];
|
||||
newGroup.name = @"Default";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
Designated initalizer for loading
|
||||
*/
|
||||
- (id)initWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
/*
|
||||
Create an empty file
|
||||
*/
|
||||
self.file = file;
|
||||
self.key = key;
|
||||
self.password = password;
|
||||
@try {
|
||||
self.tree = [KdbReaderFactory load:[self.file path] withPassword:self.passwordHash];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"%@", [exception description]);
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if([self.tree isKindOfClass:[Kdb4Tree class]]) {
|
||||
self.version = MPDatabaseVersion4;
|
||||
}
|
||||
else if( [self.tree isKindOfClass:[Kdb3Tree class]]) {
|
||||
self.version = MPDatabaseVersion3;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.tree = nil;
|
||||
self.file = nil;
|
||||
self.password = nil;
|
||||
self.key = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (KdbGroup *)root {
|
||||
return [self.tree root];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)save {
|
||||
NSError *fileError;
|
||||
if(self.isNewFile || [self.file checkResourceIsReachableAndReturnError:&fileError] ) {
|
||||
@try {
|
||||
[KdbWriterFactory persist:self.tree file:[self.file path] withPassword:self.passwordHash];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"%@", [exception description]);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
else {
|
||||
NSLog(@"File Error: %@", fileError);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)saveAsFile:(NSURL *)file withPassword:(NSString *)password keyfile:(NSURL *)key {
|
||||
self.file = file;
|
||||
self.password = password;
|
||||
self.key = key;
|
||||
return [self save];
|
||||
}
|
||||
|
||||
- (KdbPassword *)passwordHash {
|
||||
// TODO: Use defaults to determine Encoding?
|
||||
return [[[KdbPassword alloc] initWithPassword:self.password passwordEncoding:NSUTF8StringEncoding keyFile:[self.key path]] autorelease];
|
||||
}
|
||||
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
||||
KdbEntry *newEntry = [self.tree createEntry:parent];
|
||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||
[parent addEntry:newEntry];
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
- (KdbGroup *)createGroup:(KdbGroup *)parent {
|
||||
KdbGroup *newGroup = [self.tree createGroup:parent];
|
||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||
[parent addGroup:newGroup];
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "MPDatabaseVersion.h"
|
||||
|
||||
@class KdbGroup;
|
||||
@class KdbEntry;
|
||||
|
||||
@interface MPDocument : NSDocument
|
||||
|
||||
@@ -18,8 +19,12 @@
|
||||
@property (nonatomic,retain) NSString *password;
|
||||
@property (nonatomic, retain) NSURL *key;
|
||||
@property (assign, readonly) MPDatabaseVersion version;
|
||||
@property (assign, readonly) BOOL isDecrypted;
|
||||
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version;
|
||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
||||
|
||||
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
||||
|
||||
@end
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
#import "KdbPassword.h"
|
||||
#import "MPDatabaseVersion.h"
|
||||
|
||||
@interface MPDocument () {
|
||||
@private
|
||||
BOOL _isDecrypted;
|
||||
}
|
||||
@interface MPDocument ()
|
||||
|
||||
@property (retain) KdbTree *tree;
|
||||
@property (retain) NSURL *file;
|
||||
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
||||
@property (assign) MPDatabaseVersion version;
|
||||
@property (assign) BOOL isDecrypted;
|
||||
|
||||
@end
|
||||
|
||||
@@ -37,7 +35,7 @@
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
_isDecrypted = NO;
|
||||
_isDecrypted = YES;
|
||||
switch(version) {
|
||||
case MPDatabaseVersion3:
|
||||
self.tree = [[[Kdb3Tree alloc] init] autorelease];
|
||||
@@ -56,15 +54,13 @@
|
||||
}
|
||||
|
||||
- (void) makeWindowControllers {
|
||||
|
||||
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
||||
[self addWindowController:windowController];
|
||||
[self addWindowController:windowController];
|
||||
}
|
||||
|
||||
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
||||
{
|
||||
[super windowControllerDidLoadNib:aController];
|
||||
// Add any code here that needs to be executed once the windowController has loaded the document's window.
|
||||
}
|
||||
|
||||
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
||||
@@ -84,6 +80,7 @@
|
||||
|
||||
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
||||
self.file = url;
|
||||
self.isDecrypted = NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -122,4 +119,22 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (KdbGroup *)root {
|
||||
return [self.tree root];
|
||||
}
|
||||
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
||||
KdbEntry *newEntry = [self.tree createEntry:parent];
|
||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||
[parent addEntry:newEntry];
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
- (KdbGroup *)createGroup:(KdbGroup *)parent {
|
||||
KdbGroup *newGroup = [self.tree createGroup:parent];
|
||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||
[parent addGroup:newGroup];
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPPasswordInputController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPPasswordEditViewController.h"
|
||||
@@ -18,7 +17,10 @@
|
||||
#import "MPInspectorTabViewController.h"
|
||||
#import "MPAppDelegate.h"
|
||||
|
||||
@interface MPDocumentWindowController ()
|
||||
@interface MPDocumentWindowController () {
|
||||
@private
|
||||
BOOL _needsDecryption;
|
||||
}
|
||||
|
||||
@property (assign) IBOutlet NSView *outlineView;
|
||||
@property (assign) IBOutlet NSSplitView *splitView;
|
||||
@@ -39,7 +41,6 @@
|
||||
@property (retain) MPMainWindowSplitViewDelegate *splitViewDelegate;
|
||||
|
||||
- (void)_setContentViewController:(MPViewController *)viewController;
|
||||
- (void)_updateWindowTitle;
|
||||
|
||||
/* window reszing and content checks */
|
||||
- (BOOL)_windowsIsLargeEnoughForInspectorView;
|
||||
@@ -52,6 +53,7 @@
|
||||
-(id)init {
|
||||
self = [super initWithWindowNibName:@"MainWindow" owner:self];
|
||||
if( self ) {
|
||||
_needsDecryption = NO;
|
||||
_toolbarDelegate = [[MPToolbarDelegate alloc] init];
|
||||
_outlineViewController = [[MPOutlineViewController alloc] init];
|
||||
_inspectorTabViewController = [[MPInspectorTabViewController alloc] init];
|
||||
@@ -60,11 +62,6 @@
|
||||
|
||||
[[NSBundle mainBundle] loadNibNamed:@"WelcomeView" owner:self topLevelObjects:NULL];
|
||||
[self.welcomeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didOpenDocument:)
|
||||
name:MPDatabaseControllerDidLoadDatabaseNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -91,7 +88,6 @@
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
[super windowDidLoad];
|
||||
[self _updateWindowTitle];
|
||||
|
||||
[[self.welcomeText cell] setBackgroundStyle:NSBackgroundStyleRaised];
|
||||
CGFloat minWidht = MPMainWindowSplitViewDelegateMinimumContentWidth + MPMainWindowSplitViewDelegateMinimumOutlineWidth + [self.splitView dividerThickness];
|
||||
@@ -122,6 +118,10 @@
|
||||
[self toggleInspector:nil];
|
||||
|
||||
[self _setContentViewController:nil];
|
||||
MPDocument *document = [self document];
|
||||
if(!document.isDecrypted) {
|
||||
[self showPasswordInput];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_setContentViewController:(MPViewController *)viewController {
|
||||
@@ -158,17 +158,6 @@
|
||||
[self.window makeFirstResponder:[viewController reconmendedFirstResponder]];
|
||||
}
|
||||
|
||||
- (void)_updateWindowTitle {
|
||||
if([MPDatabaseController defaultController].database) {
|
||||
NSString *appName = [(MPAppDelegate *)[NSApp delegate] applicationName];
|
||||
NSString *openFile = [[MPDatabaseController defaultController].database.file lastPathComponent];
|
||||
[self.window setTitle:[NSString stringWithFormat:@"%@ - %@", appName, openFile]];
|
||||
}
|
||||
else {
|
||||
[self.window setTitle:[(MPAppDelegate *)[NSApp delegate] applicationName]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Actions
|
||||
|
||||
- (void)toggleInspector:(id)sender {
|
||||
@@ -276,6 +265,7 @@
|
||||
_entryViewController = [[MPEntryViewController alloc] init];
|
||||
}
|
||||
[self _setContentViewController:self.entryViewController];
|
||||
[self.outlineViewController showOutline];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPAppDelegate.h"
|
||||
#import "MPOutlineViewDelegate.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPPasteBoardController.h"
|
||||
@@ -256,36 +255,31 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
}
|
||||
|
||||
- (void)updateFilter {
|
||||
MPDatabaseDocument *openDatabase = [MPDatabaseController defaultController].database;
|
||||
if(openDatabase) {
|
||||
[self _showFilterBarAnimated:YES];
|
||||
[self _showFilterBarAnimated:YES];
|
||||
|
||||
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(backgroundQueue, ^{
|
||||
|
||||
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(backgroundQueue, ^{
|
||||
|
||||
NSMutableArray *prediactes = [NSMutableArray arrayWithCapacity:3];
|
||||
if( [self _shouldFilterTitles] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
if( [self _shouldFilterUsernames] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.username CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
if( [self _shouldFilterURLs] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.url CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
NSPredicate *fullFilter = [NSCompoundPredicate orPredicateWithSubpredicates:prediactes];
|
||||
self.filteredEntries = [[openDatabase.root childEntries] filteredArrayUsingPredicate:fullFilter];
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[self.entryArrayController setContent:self.filteredEntries];
|
||||
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
|
||||
});
|
||||
NSMutableArray *prediactes = [NSMutableArray arrayWithCapacity:3];
|
||||
if( [self _shouldFilterTitles] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
if( [self _shouldFilterUsernames] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.username CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
if( [self _shouldFilterURLs] ) {
|
||||
[prediactes addObject:[NSPredicate predicateWithFormat:@"SELF.url CONTAINS[cd] %@", self.filter]];
|
||||
}
|
||||
NSPredicate *fullFilter = [NSCompoundPredicate orPredicateWithSubpredicates:prediactes];
|
||||
MPDocument *document = [[self windowController] document];
|
||||
self.filteredEntries = [[document.root childEntries] filteredArrayUsingPredicate:fullFilter];
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[self.entryArrayController setContent:self.filteredEntries];
|
||||
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
|
||||
});
|
||||
}
|
||||
else {
|
||||
[self.entryArrayController setContent:nil];
|
||||
self.filteredEntries = nil;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
- (void)setupFilterBar {
|
||||
@@ -301,7 +295,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
|
||||
[self.filterSearchField setAction:@selector(updateFilter:)];
|
||||
[[self.filterSearchField cell] setSendsSearchStringImmediately:NO];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#import "MPInspectorTabViewController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPOutlineViewDelegate.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPShadowBox.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPPopupImageView.h"
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPOutlineDataSource.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "MPDocument.h"
|
||||
#import "KdbLib.h"
|
||||
|
||||
@implementation MPOutlineDataSource
|
||||
@@ -25,8 +24,8 @@
|
||||
}
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
|
||||
if(!item) {
|
||||
MPDatabaseController *dbController = [MPDatabaseController defaultController];
|
||||
return dbController.database.root;
|
||||
MPDocument *document = [[[outlineView window] windowController] document];
|
||||
return document.root;
|
||||
}
|
||||
if( [item isKindOfClass:[KdbGroup class]]) {
|
||||
KdbGroup *group = item;
|
||||
@@ -38,8 +37,8 @@
|
||||
}
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
|
||||
if(!item) {
|
||||
MPDatabaseController *dbController = [MPDatabaseController defaultController];
|
||||
return ([[dbController.database.root groups] count] > 0);
|
||||
MPDocument *document = [[[outlineView window] windowController] document];
|
||||
return ([[document.root groups] count] > 0);
|
||||
}
|
||||
if([item isKindOfClass:[KdbGroup class]])
|
||||
{
|
||||
|
||||
@@ -11,8 +11,11 @@
|
||||
@interface MPOutlineViewController : MPViewController
|
||||
|
||||
- (void)clearSelection;
|
||||
- (void)showOutline;
|
||||
|
||||
|
||||
- (void)createGroup:(id)sender;
|
||||
- (void)createEntry:(id)sender;
|
||||
- (void)deleteEntry:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#import "MPOutlineViewController.h"
|
||||
#import "MPOutlineViewDelegate.h"
|
||||
#import "MPOutlineDataSource.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPAppDelegate.h"
|
||||
#import "KdbLib.h"
|
||||
|
||||
@@ -23,7 +22,6 @@
|
||||
@property (retain) NSMenu *menu;
|
||||
|
||||
|
||||
- (void)_didOpenDocument:(NSNotification *)notification;
|
||||
- (NSMenu *)_contextMenu;
|
||||
- (KdbGroup *)_clickedOrSelectedGroup;
|
||||
|
||||
@@ -40,11 +38,6 @@
|
||||
if (self) {
|
||||
self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease];
|
||||
self.datasource = [[[MPOutlineDataSource alloc] init] autorelease];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didOpenDocument:)
|
||||
name:MPDatabaseControllerDidLoadDatabaseNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -66,13 +59,10 @@
|
||||
[self.outlineView setAllowsEmptySelection:YES];
|
||||
}
|
||||
|
||||
- (void)_didOpenDocument:(NSNotification *)notification {
|
||||
[self.outlineView deselectAll:nil];
|
||||
- (void)showOutline {
|
||||
[self.outlineView reloadData];
|
||||
MPDatabaseController *dbContoller = [MPDatabaseController defaultController];
|
||||
if(dbContoller.database) {
|
||||
[self.outlineView expandItem:dbContoller.database.root expandChildren:NO];
|
||||
}
|
||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||
[self.outlineView expandItem:document.root expandChildren:NO];
|
||||
}
|
||||
|
||||
- (void)clearSelection {
|
||||
@@ -91,7 +81,8 @@
|
||||
- (void)createGroup:(id)sender {
|
||||
KdbGroup *group = [self _clickedOrSelectedGroup];
|
||||
if(group) {
|
||||
[[MPDatabaseController defaultController].database createGroup:group];
|
||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||
[document createGroup:group];
|
||||
[self.outlineView reloadData];
|
||||
}
|
||||
}
|
||||
@@ -99,7 +90,8 @@
|
||||
- (void)createEntry:(id)sender {
|
||||
KdbGroup *group = [self _clickedOrSelectedGroup];
|
||||
if(group) {
|
||||
[[MPDatabaseController defaultController].database createEntry:group];
|
||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||
[document createEntry:group];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPPasswordInputController.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPKeyfilePathControlDelegate.h"
|
||||
|
||||
@@ -46,15 +47,16 @@
|
||||
}
|
||||
|
||||
- (IBAction)_decrypt:(id)sender {
|
||||
MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument];
|
||||
MPDocumentWindowController *windowController = (MPDocumentWindowController *)[[[self view] window] windowController];
|
||||
MPDocument *document = [windowController document];
|
||||
if(document) {
|
||||
BOOL isOk = [document decryptWithPassword:[self.passwordTextField stringValue] keyFileURL:[self.keyPathControl URL]];
|
||||
if( isOk) {
|
||||
if(!isOk) {
|
||||
[self _showError];
|
||||
}
|
||||
}
|
||||
[self _reset];
|
||||
// show entries
|
||||
[windowController showEntries];
|
||||
}
|
||||
|
||||
- (void)_reset {
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
- (void)didLoadView;
|
||||
- (NSResponder *)reconmendedFirstResponder;
|
||||
/* Returns the associated window controller */
|
||||
- (id)windowController;
|
||||
|
||||
- (void)updateResponderChain;
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
// override
|
||||
}
|
||||
|
||||
- (id)windowController {
|
||||
return [[[self view] window] windowController];
|
||||
}
|
||||
|
||||
- (NSResponder *)reconmendedFirstResponder {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>64C</string>
|
||||
<string>666</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
Reference in New Issue
Block a user