Attachments on Kdb1 Entries are now supported. Saving not implemented. Attach/detach works.

This commit is contained in:
michael starke
2013-07-19 23:30:45 +02:00
parent 86d983f776
commit dc51c60c19
6 changed files with 19 additions and 10 deletions

View File

@@ -14,16 +14,16 @@
return (self.binary != nil ? 1 : 0);
}
- (id)objectInBinariesAtIndex:(NSUInteger)index {
if(self.binary) {
return @"Dummy";
}
return nil;
return self.binary;
}
- (void)removeObjectFromBinariesAtIndex:(NSUInteger)index {
return; // Stubb
if(self.binary ) {
self.binary = nil;
self.binaryDesc = nil;
}
}
- (void)insertObject:(id)binary inBinariesAtIndex:(NSUInteger)index {
return; //Stubb
return;//
}

View File

@@ -202,7 +202,7 @@
if(hasKey) {
keyOk = [self.keyURL checkResourceIsReachableAndReturnError:nil];
}
BOOL hasPassword = ![password isEmpty];
BOOL hasPassword = ![NSString isEmptyString:password];
BOOL passwordOk = YES;
if(hasPassword ) {
passwordOk = [password isEqualToString:repeat] || self.showPassword;

View File

@@ -105,6 +105,14 @@
[self.treeV4.binaries removeObject:binary];
}
- (void)removeAttachmentFromEntry:(KdbEntry *)anEntry {
if(self.version != MPDatabaseVersion3) {
return;
}
Kdb3Entry *entry = (Kdb3Entry *)anEntry;
[entry removeObjectFromBinariesAtIndex:0];
}
- (Binary *)findBinary:(BinaryRef *)reference {
if(self.version != MPDatabaseVersion4) {
return nil;

View File

@@ -99,6 +99,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
- (void)saveAttachmentFromEntry:(KdbEntry *)anEntry toLocation:(NSURL *)location;
- (void)saveAttachment:(BinaryRef *)reference toLocation:(NSURL *)location;
- (void)removeAttachment:(BinaryRef *)reference fromEntry:(KdbEntry *)anEntry;
- (void)removeAttachmentFromEntry:(KdbEntry *)anEntry;
- (NSUInteger)nextBinaryId;
- (Binary *)findBinary:(BinaryRef *)reference;

View File

@@ -384,9 +384,9 @@ enum {
- (IBAction)removeAttachment:(id)sender {
MPDocument *document = [[self windowController] document];
if(document.version == MPDatabaseVersion3) {
// Handle entry
[document removeAttachmentFromEntry:self.selectedEntry];
}
if(document.version == MPDatabaseVersion4) {
else if(document.version == MPDatabaseVersion4) {
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
BinaryRef *reference = entry.binaries[[sender tag]];
[document removeAttachment:reference fromEntry:self.selectedEntry];