mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 12:19:52 +00:00
Added binary lookup to MPDocument
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1090</string>
|
||||
<string>1103</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
Reference in New Issue
Block a user