diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index cdb01af6..e182d942 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -90,7 +90,6 @@ 4C669B8A16760ED100DD0774 /* InputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B4716760ED100DD0774 /* InputStream.m */; }; 4C669B8B16760ED100DD0774 /* OutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B4916760ED100DD0774 /* OutputStream.m */; }; 4C669B8C16760ED100DD0774 /* Sha256OutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B4B16760ED100DD0774 /* Sha256OutputStream.m */; }; - 4C669B8F16760ED100DD0774 /* DDXMLDocument+MKPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B5216760ED100DD0774 /* DDXMLDocument+MKPAdditions.m */; }; 4C669B9016760ED100DD0774 /* DDXMLElement+MKPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B5416760ED100DD0774 /* DDXMLElement+MKPAdditions.m */; }; 4C669B9116760ED100DD0774 /* Kdb.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B5616760ED100DD0774 /* Kdb.m */; }; 4C669B9316760ED100DD0774 /* Kdb3Node.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C669B5A16760ED100DD0774 /* Kdb3Node.m */; }; @@ -334,8 +333,6 @@ 4C669B4916760ED100DD0774 /* OutputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OutputStream.m; sourceTree = ""; }; 4C669B4A16760ED100DD0774 /* Sha256OutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sha256OutputStream.h; sourceTree = ""; }; 4C669B4B16760ED100DD0774 /* Sha256OutputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sha256OutputStream.m; sourceTree = ""; }; - 4C669B5116760ED100DD0774 /* DDXMLDocument+MKPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DDXMLDocument+MKPAdditions.h"; sourceTree = ""; }; - 4C669B5216760ED100DD0774 /* DDXMLDocument+MKPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DDXMLDocument+MKPAdditions.m"; sourceTree = ""; }; 4C669B5316760ED100DD0774 /* DDXMLElement+MKPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DDXMLElement+MKPAdditions.h"; sourceTree = ""; }; 4C669B5416760ED100DD0774 /* DDXMLElement+MKPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DDXMLElement+MKPAdditions.m"; sourceTree = ""; }; 4C669B5516760ED100DD0774 /* Kdb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Kdb.h; sourceTree = ""; }; @@ -694,6 +691,8 @@ 4C2724CB1778EF8E00FD8456 /* Categories */ = { isa = PBXGroup; children = ( + 4C669B5316760ED100DD0774 /* DDXMLElement+MKPAdditions.h */, + 4C669B5416760ED100DD0774 /* DDXMLElement+MKPAdditions.m */, 4C2724CC1778EFB100FD8456 /* NSData+Random.h */, 4C2724CD1778EFB100FD8456 /* NSData+Random.m */, 4C2724CF1778EFE300FD8456 /* NSString+Empty.h */, @@ -862,10 +861,6 @@ isa = PBXGroup; children = ( 4C2724CB1778EF8E00FD8456 /* Categories */, - 4C669B5116760ED100DD0774 /* DDXMLDocument+MKPAdditions.h */, - 4C669B5216760ED100DD0774 /* DDXMLDocument+MKPAdditions.m */, - 4C669B5316760ED100DD0774 /* DDXMLElement+MKPAdditions.h */, - 4C669B5416760ED100DD0774 /* DDXMLElement+MKPAdditions.m */, 4C669B5516760ED100DD0774 /* Kdb.h */, 4C669B5616760ED100DD0774 /* Kdb.m */, 4C669B5916760ED100DD0774 /* Kdb3Node.h */, @@ -1311,7 +1306,6 @@ 4C669B8A16760ED100DD0774 /* InputStream.m in Sources */, 4C669B8B16760ED100DD0774 /* OutputStream.m in Sources */, 4C669B8C16760ED100DD0774 /* Sha256OutputStream.m in Sources */, - 4C669B8F16760ED100DD0774 /* DDXMLDocument+MKPAdditions.m in Sources */, 4C669B9016760ED100DD0774 /* DDXMLElement+MKPAdditions.m in Sources */, 4C669B9116760ED100DD0774 /* Kdb.m in Sources */, 4C669B9316760ED100DD0774 /* Kdb3Node.m in Sources */, diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index b97d55dd..90711f1f 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -22,6 +22,8 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; @class KdbEntry; @class KdbTree; @class UUID; +@class Binary; +@class BinaryRef; @interface MPDocument : NSDocument @@ -37,13 +39,21 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; @property (nonatomic, retain) NSURL *key; @property (assign, readonly) MPDatabaseVersion version; - - (id)initWithVersion:(MPDatabaseVersion)version; - (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL; -/* Lookup */ +#pragma mark Data Lookup +/* + Returns the entry for the given UUID, nil if none was found + */ - (KdbEntry *)findEntry:(UUID *)uuid; +/* + Return the Binary for the given BinaryRef. nil if none was found + */ +- (Binary *)binaryForRef:(BinaryRef *)binaryRef; + +#pragma mark Data Manipulation /* Undoable Intiialization of elements */ - (KdbGroup *)createGroup:(KdbGroup *)parent; - (KdbEntry *)createEntry:(KdbGroup *)parent; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 2f0c3e49..e661085d 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -158,6 +158,19 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return [self.root entryForUUID:uuid]; } +- (Binary *)binaryForRef:(BinaryRef *)binaryRef { + if(self.version != MPDatabaseVersion4) { + return nil; + } + NSPredicate *filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { + Binary *binaryFile = evaluatedObject; + return (binaryFile.binaryId == binaryRef.ref); + }]; + Kdb4Tree *tree = (Kdb4Tree *)self.tree; + NSArray *filteredBinary = [tree.binaries filteredArrayUsingPredicate:filterPredicate]; + return [filteredBinary lastObject]; +} + #pragma mark Data manipulation - (KdbEntry *)createEntry:(KdbGroup *)parent { diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 4258f58f..4c3a268d 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -300,14 +300,8 @@ enum { Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; BinaryRef *binaryRef = entry.binaries[row]; [[view textField] bind:NSValueBinding toObject:binaryRef withKeyPath:@"key" options:nil]; - MPDocument *document = [[self windowController] document]; - Kdb4Tree *tree = (Kdb4Tree *)document.tree; - NSPredicate *filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { - Binary *binaryFile = evaluatedObject; - return (binaryFile.binaryId == binaryRef.ref); - }]; - NSArray *filteredBinary = [tree.binaries filteredArrayUsingPredicate:filterPredicate]; - Binary *attachedFile = [filteredBinary lastObject]; +// MPDocument *document = [[self windowController] document]; +// [document binaryForRef:binaryRef]; } return view; } diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 91259c78..cae8f308 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 1090 + 1103 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MiniKeePassLib b/MiniKeePassLib index 5bda74e6..c0d72ecc 160000 --- a/MiniKeePassLib +++ b/MiniKeePassLib @@ -1 +1 @@ -Subproject commit 5bda74e60865f0f556e9991b671a83eed6cc9ad2 +Subproject commit c0d72eccd714294b616f1c1f2b4996388d2262e1