Added a default Database name

Minor changes
Updtaed KeePassLib
This commit is contained in:
michael starke
2013-07-05 16:37:35 +02:00
parent 59db224a35
commit 7feb2517dd
10 changed files with 81 additions and 4 deletions

View File

@@ -15,7 +15,7 @@
Kdb4Tree *tree = [[Kdb4Tree alloc] init];
tree.generator = @"MacPass";
tree.databaseName = @"";
tree.databaseName = NSLocalizedString(@"NEW_DATABASE", "Name for a newly created Database");
tree.databaseNameChanged = currentTime;
tree.databaseDescription = @"";
tree.databaseDescriptionChanged = currentTime;

View File

@@ -7,6 +7,8 @@
//
#import "KdbEntry+MPAdditions.h"
#import "Kdb3Node.h"
#import "Kdb4Node.h"
#import "MPIconHelper.h"

View File

@@ -17,4 +17,5 @@
return NSNotFound;
}
@end

View File

@@ -8,10 +8,18 @@
#import "Kdb.h"
@class BinaryRef;
@interface KdbTree (MPAdditions)
- (NSArray *)allEntries;
- (NSArray *)allGroups;
- (void)addAttachment:(NSURL *)location toEntry:(KdbEntry *)anEntry;
- (void)saveAttachmentFromEntry:(KdbEntry *)anEntry toLocation:(NSURL *)location;
- (void)saveAttachment:(BinaryRef *)reference toLocation:(NSURL *)location;
- (NSUInteger)nextBinaryId;
@end

View File

@@ -9,6 +9,9 @@
#import "KdbTree+MPAdditions.h"
#import "KdbGroup+MPTreeTools.h"
#import "Kdb3Node.h"
#import "Kdb4Node.h"
@implementation KdbTree (MPAdditions)
- (NSArray *)allGroups {
@@ -19,4 +22,61 @@
return [self.root childEntries];
}
- (void)addAttachment:(NSURL *)location toEntry:(KdbEntry *)anEntry {
NSError *error = nil;
NSString *fileName = [NSString stringWithFormat:@"%@.%@", [location lastPathComponent], [location pathExtension]];
if([anEntry isKindOfClass:[Kdb3Entry class]]) {
Kdb3Entry *entry = (Kdb3Entry *)anEntry;
NSData *binaryData = [NSData dataWithContentsOfURL:location options:NSDataReadingUncached error:&error];
if(!binaryData) {
[NSApp presentError:error];
binaryData = nil;
error = nil;
return; // failed
}
entry.binary = binaryData;
entry.binaryDesc = fileName;
}
if( [anEntry isKindOfClass:[Kdb4Entry class]]) {
Kdb4Entry *entry = (Kdb4Entry *)anEntry;
Kdb4Tree *tree = (Kdb4Tree *)self;
NSString *fileData = [NSString stringWithContentsOfURL:location usedEncoding:0 error:&error];
if(!fileData) {
[NSApp presentError:error];
fileData = nil;
error = nil;
return; // failed
}
Binary *binary = [[Binary alloc] init];
binary.binaryId = [self nextBinaryId];
binary.compressed = (tree.compressionAlgorithm == KPLCompressionGzip);
if(binary.compressed ) {
}
binary.data = fileData;
[tree.binaries addObject:binary];
BinaryRef *ref = [[BinaryRef alloc] init];
ref.key = fileName;
[entry.binaries addObject:ref];
}
}
- (void)saveAttachment:(BinaryRef *)reference toLocation:(NSURL *)location {
}
- (void)saveAttachmentFromEntry:(KdbEntry *)entry toLocation:(NSURL *)location {
}
- (NSUInteger)nextBinaryId {
Kdb4Tree *tree = (Kdb4Tree *)self;
NSUInteger maxKey = 0;
for(Binary *binary in tree.binaries) {
maxKey = MAX(binary.binaryId, maxKey);
}
return (maxKey + 1);
}
@end

View File

@@ -154,7 +154,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
view = [outlineView makeViewWithIdentifier:_MPOutlineViewDataViewIdentifier owner:self];
NSImage *icon = [MPIconHelper icon:(MPIconType)[group image]];
[view.imageView setImage:icon];
[view.textField bind:NSValueBinding toObject:group withKeyPath:@"name" options:nil];
[view.textField bind:NSValueBinding toObject:group withKeyPath:MPGroupNameUndoableKey options:nil];
[view.textField bind:@"count" toObject:group withKeyPath:@"entries.@count" options:nil];
}

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1913</string>
<string>1923</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>

Binary file not shown.