From 7feb2517dd4632abccd22351dec0515860df178e Mon Sep 17 00:00:00 2001 From: michael starke Date: Fri, 5 Jul 2013 16:37:35 +0200 Subject: [PATCH] Added a default Database name Minor changes Updtaed KeePassLib --- MacPass.xcodeproj/project.pbxproj | 6 +++ MacPass/Kdb4Tree+NewTree.m | 2 +- MacPass/KdbEntry+MPAdditions.m | 2 + MacPass/KdbEntry+MPTreeTools.m | 1 + MacPass/KdbTree+MPAdditions.h | 8 ++++ MacPass/KdbTree+MPAdditions.m | 60 +++++++++++++++++++++++++++ MacPass/MPOutlineViewController.m | 2 +- MacPass/MacPass-Info.plist | 2 +- MacPass/en.lproj/Localizable.strings | Bin 6526 -> 6674 bytes MiniKeePassLib | 2 +- 10 files changed, 81 insertions(+), 4 deletions(-) diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 21c44bf1..71d9dc22 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -185,6 +185,7 @@ 4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE5B549173AFBA700207B39 /* MPDocument.m */; }; 4CE8246F16E2E93400573141 /* MPOverlayWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */; }; 4CE8247516E2F2B900573141 /* MPOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8247416E2F2B900573141 /* MPOverlayView.m */; }; + 4CF1F0CA1786B37900CD920E /* NSData+Gzip.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */; }; 4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */; }; 4CF6C718176F5234007A811D /* MPAssociateRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C717176F5234007A811D /* MPAssociateRequestHandler.m */; }; 4CF78057176E5CFD0032EE71 /* MPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78056176E5CFD0032EE71 /* MPConnection.m */; }; @@ -541,6 +542,8 @@ 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOverlayWindowController.m; sourceTree = ""; }; 4CE8247316E2F2B900573141 /* MPOverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOverlayView.h; sourceTree = ""; }; 4CE8247416E2F2B900573141 /* MPOverlayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOverlayView.m; sourceTree = ""; }; + 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Gzip.m"; sourceTree = ""; }; + 4CF1F0C91786B37900CD920E /* NSData+Gzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Gzip.h"; sourceTree = ""; }; 4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringLengthValueTransformer.h; sourceTree = ""; }; 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPStringLengthValueTransformer.m; sourceTree = ""; }; 4CF6C715176F5183007A811D /* MPServerRequestHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPServerRequestHandler.h; sourceTree = ""; }; @@ -757,6 +760,8 @@ 4C2724D01778EFE300FD8456 /* NSString+Empty.m */, 4C2724D21778FA0700FD8456 /* NSDate+Packed.h */, 4C2724D31778FA0700FD8456 /* NSDate+Packed.m */, + 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */, + 4CF1F0C91786B37900CD920E /* NSData+Gzip.h */, 4C2724D51778FF1A00FD8456 /* NSUUID+KeePassLib.h */, 4C2724D61778FF1A00FD8456 /* NSUUID+KeePassLib.m */, 4C2724D817790E7C00FD8456 /* NSMutableData+Base64.h */, @@ -1514,6 +1519,7 @@ 4CC672791781D0C0006DEDCF /* KdbGroup+MPAdditions.m in Sources */, 4CC6727C1781D0D2006DEDCF /* KdbEntry+MPAdditions.m in Sources */, 4C5FE9AE17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m in Sources */, + 4CF1F0CA1786B37900CD920E /* NSData+Gzip.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Kdb4Tree+NewTree.m b/MacPass/Kdb4Tree+NewTree.m index eac1c505..d1d82c24 100644 --- a/MacPass/Kdb4Tree+NewTree.m +++ b/MacPass/Kdb4Tree+NewTree.m @@ -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; diff --git a/MacPass/KdbEntry+MPAdditions.m b/MacPass/KdbEntry+MPAdditions.m index e4bc52a0..aa4db2b5 100644 --- a/MacPass/KdbEntry+MPAdditions.m +++ b/MacPass/KdbEntry+MPAdditions.m @@ -7,6 +7,8 @@ // #import "KdbEntry+MPAdditions.h" +#import "Kdb3Node.h" +#import "Kdb4Node.h" #import "MPIconHelper.h" diff --git a/MacPass/KdbEntry+MPTreeTools.m b/MacPass/KdbEntry+MPTreeTools.m index 0b7c6642..5e4f760c 100644 --- a/MacPass/KdbEntry+MPTreeTools.m +++ b/MacPass/KdbEntry+MPTreeTools.m @@ -17,4 +17,5 @@ return NSNotFound; } + @end diff --git a/MacPass/KdbTree+MPAdditions.h b/MacPass/KdbTree+MPAdditions.h index b5046c1d..8bdff8f4 100644 --- a/MacPass/KdbTree+MPAdditions.h +++ b/MacPass/KdbTree+MPAdditions.h @@ -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 diff --git a/MacPass/KdbTree+MPAdditions.m b/MacPass/KdbTree+MPAdditions.m index dd7b1fbf..ea4a27ae 100644 --- a/MacPass/KdbTree+MPAdditions.m +++ b/MacPass/KdbTree+MPAdditions.m @@ -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 diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 2c02ef5c..349cf55e 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -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]; } diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index e5cda421..51335c82 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 1913 + 1923 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 7d48bc807f7f84a08ad7dc48f42f6dcfd4d54203..7663fb92c8904e67db0fff45db72471716f51d08 100644 GIT binary patch delta 92 zcmexoG|6NG7vJPlf&!Cou`B4iFeEaR0C5r!7c-