diff --git a/KeePassKit b/KeePassKit index 105bd0ad..709c8874 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 105bd0adbd9aafa4dcc1c8048775be44a10f0f12 +Subproject commit 709c8874e411288f4563ac681c0de54390fc9ee1 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 38560c33..c739714d 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -266,6 +266,7 @@ 4CF7805D176E71170032EE71 /* MPServerDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF7805C176E71170032EE71 /* MPServerDaemon.m */; }; 4CF7805F176E75110032EE71 /* ServerSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CF7805E176E75110032EE71 /* ServerSettings.xib */; }; 4CF78064176E75AD0032EE71 /* MPServerSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78063176E75AD0032EE71 /* MPServerSettingsController.m */; }; + 4CFB5E9F17AAD20200D9B10C /* Kdb4Group+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFB5E9E17AAD20200D9B10C /* Kdb4Group+Undo.m */; }; 4CFC53BF16E94729007396BE /* MPShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFC53BE16E94729007396BE /* MPShadowBox.m */; }; 4CFC873B179DEDF3000DFC03 /* KPKMetaData.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFC873A179DEDF3000DFC03 /* KPKMetaData.m */; }; 4CFC873E179DF200000DFC03 /* KPKTimeInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFC873D179DF200000DFC03 /* KPKTimeInfo.m */; }; @@ -766,6 +767,8 @@ 4CF7805E176E75110032EE71 /* ServerSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ServerSettings.xib; sourceTree = ""; }; 4CF78062176E75AD0032EE71 /* MPServerSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPServerSettingsController.h; sourceTree = ""; }; 4CF78063176E75AD0032EE71 /* MPServerSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPServerSettingsController.m; sourceTree = ""; }; + 4CFB5E9D17AAD20200D9B10C /* Kdb4Group+Undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kdb4Group+Undo.h"; sourceTree = ""; }; + 4CFB5E9E17AAD20200D9B10C /* Kdb4Group+Undo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Kdb4Group+Undo.m"; sourceTree = ""; }; 4CFC53BD16E94729007396BE /* MPShadowBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPShadowBox.h; sourceTree = ""; }; 4CFC53BE16E94729007396BE /* MPShadowBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPShadowBox.m; sourceTree = ""; }; 4CFC8739179DEDF3000DFC03 /* KPKMetaData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKMetaData.h; sourceTree = ""; }; @@ -1080,6 +1083,8 @@ 4C4510081798C53700219998 /* StringField+Validation.m */, 4C45100A1798C65C00219998 /* Kdb4Entry+MPAdditions.h */, 4C45100B1798C65C00219998 /* Kdb4Entry+MPAdditions.m */, + 4CFB5E9D17AAD20200D9B10C /* Kdb4Group+Undo.h */, + 4CFB5E9E17AAD20200D9B10C /* Kdb4Group+Undo.m */, ); name = "KeePassLib Categories"; sourceTree = ""; @@ -2078,6 +2083,7 @@ 4CA08DA017A831B200A6544B /* MPAddEntryContextMenuDelegate.m in Sources */, 4C6BEA3117A88E6C00CF69A8 /* MPStripLineBreaksTransformer.m in Sources */, 4C79E80317A9187400AC6CD2 /* KPKXmlHeaderWriter.m in Sources */, + 4CFB5E9F17AAD20200D9B10C /* Kdb4Group+Undo.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryInspectorView.xib b/MacPass/EntryInspectorView.xib index 33f60a7d..9e8c0bc4 100644 --- a/MacPass/EntryInspectorView.xib +++ b/MacPass/EntryInspectorView.xib @@ -102,7 +102,6 @@ {293, 503} - _NS:9 @@ -114,7 +113,6 @@ {293, 503} - _NS:11 General @@ -589,7 +587,6 @@ {{20, 20}, {212, 77}} - _NS:9 YES @@ -724,7 +721,7 @@ {210, 258} - + _NS:13 @@ -844,7 +841,7 @@ {{20, 151}, {212, 260}} - + _NS:9 133138 diff --git a/MacPass/GroupInspectorView.xib b/MacPass/GroupInspectorView.xib index a6573f45..f259696a 100644 --- a/MacPass/GroupInspectorView.xib +++ b/MacPass/GroupInspectorView.xib @@ -48,10 +48,72 @@ 268 + + + 268 + {{17, 93}, {53, 14}} + + + + _NS:1535 + YES + + 68157504 + 272630784 + Autotype + + LucidaGrande + 11 + 3100 + + _NS:1535 + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + disabledControlTextColor + + 3 + MC4zMzMzMzMzMzMzAA + + + + NO + + + + 268 + {{17, 144}, {40, 14}} + + + + _NS:1535 + YES + + 68157504 + 272630784 + Search + + _NS:1535 + + + + + NO + 268 - {{18, 99}, {222, 26}} + {{18, 61}, {222, 26}} _NS:9 @@ -132,10 +194,10 @@ 268 - {{18, 130}, {222, 26}} + {{18, 112}, {222, 26}} - + _NS:9 {249, 750} YES @@ -206,7 +268,7 @@ {{174, 163}, {63, 19}} - + _NS:9 YES @@ -274,31 +336,11 @@ 68157504 272630784 Notes - - LucidaGrande - 11 - 3100 - + _NS:1535 - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - disabledControlTextColor - - 3 - MC4zMzMzMzMzMzMzAA - - + + NO @@ -335,7 +377,7 @@ {215, 257} - + _NS:13 @@ -461,7 +503,7 @@ {{20, 190}, {217, 259}} - + _NS:9 {750, 750} 133138 @@ -548,7 +590,7 @@ {255, 421} - + _NS:13 @@ -592,7 +634,7 @@ {255, 421} - + _NS:9 133152 @@ -694,7 +736,23 @@ 3 - + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + 4 0 @@ -702,7 +760,7 @@ 4 1 - 102 + 64 1000 @@ -742,15 +800,15 @@ 29 3 - - + + 3 0 4 1 - 10 + 8 1000 @@ -758,20 +816,68 @@ 24 3 - - - 4 + + + 5 0 - - 4 + + 5 1 - - 164 + + 20 1000 - 3 - 9 + 8 + 29 + 3 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 3 @@ -822,8 +928,8 @@ 29 3 - - + + 5 0 @@ -838,20 +944,20 @@ 29 3 - - - 6 + + + 3 0 - - 6 + + 4 1 - 20 + 8 1000 - 8 - 29 + 6 + 24 3 @@ -1036,7 +1142,9 @@ + + @@ -1222,11 +1330,6 @@ - - 226 - - - 229 @@ -1314,11 +1417,6 @@ - - 248 - - - 250 @@ -1335,8 +1433,64 @@ - 263 - + 264 + + + + + + + + 265 + + + + + 272 + + + + + 273 + + + + + 274 + + + + + 276 + + + + + + + + 277 + + + + + 278 + + + + + 279 + + + + + 281 + + + + + 282 + @@ -1357,7 +1511,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin HNHRoundedTextField @@ -1378,17 +1531,28 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + @@ -1400,16 +1564,20 @@ - - + + - - + + + + + - + + @@ -1443,7 +1611,7 @@ - 263 + 282 diff --git a/MacPass/Kdb4Group+Undo.h b/MacPass/Kdb4Group+Undo.h new file mode 100644 index 00000000..575dceb9 --- /dev/null +++ b/MacPass/Kdb4Group+Undo.h @@ -0,0 +1,16 @@ +// +// Kdb4Group+Undo.h +// MacPass +// +// Created by Michael Starke on 01.08.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "Kdb4Node.h" + +@interface Kdb4Group (Undo) + +- (NSString *)notesUndoable; +- (void)setNotesUndoable:(NSString *)newNotes; + +@end diff --git a/MacPass/Kdb4Group+Undo.m b/MacPass/Kdb4Group+Undo.m new file mode 100644 index 00000000..d596376f --- /dev/null +++ b/MacPass/Kdb4Group+Undo.m @@ -0,0 +1,24 @@ +// +// Kdb4Group+Undo.m +// MacPass +// +// Created by Michael Starke on 01.08.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "Kdb4Group+Undo.h" +#import "KdbGroup+Undo.h" + +@implementation Kdb4Group (Undo) + +- (NSString *)notesUndoable { + return self.notes; +} + +- (void)setNotesUndoable:(NSString *)newNotes { + [[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; + [[self undoManager] setActionName:NSLocalizedString(@"SET_NOTES", "")]; + self.notes = newNotes; +} + +@end diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index 213168c4..b46cdf68 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -46,10 +46,7 @@ if(![[self undoManager] isUndoing]) {\ - (void)setTitleUndoable:(NSString *)title { [[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; - - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; - } + MPSetActionName(@"SET_TITLE", ""); [self setLastModificationTime:[NSDate date]]; [self setTitle:title]; @@ -57,11 +54,8 @@ if(![[self undoManager] isUndoing]) {\ - (void)setUsernameUndoable:(NSString *)username { [[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; - - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"SET_USERNAME", "Undo set username")]; - } - + MPSetActionName(@"SET_USERNAME", ""); + [self setLastModificationTime:[NSDate date]]; [self setUsername:username]; } @@ -70,10 +64,6 @@ if(![[self undoManager] isUndoing]) {\ [[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password]; MPSetActionName(@"SET_PASSWORT", "Undo set password"); - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"SET_PASSWORD", "Set Password")]; - } - [self setLastModificationTime:[NSDate date]]; [self setPassword:password]; } @@ -82,10 +72,6 @@ if(![[self undoManager] isUndoing]) {\ [[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url]; MPSetActionName(@"SET_URL", "Undo set URL"); - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; - } - [self setLastModificationTime:[NSDate date]]; [self setUrl:url]; } @@ -94,10 +80,6 @@ if(![[self undoManager] isUndoing]) {\ [[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; MPSetActionName(@"SET_NOTES", "Set Notes"); - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"SET_TITLE", "Set Title")]; - } - [self setLastModificationTime:[NSDate date]]; [self setNotes:notes]; } @@ -112,9 +94,7 @@ if(![[self undoManager] isUndoing]) {\ } [[[self undoManager] prepareWithInvocationTarget:self.parent] addEntryUndoable:self atIndex:oldIndex]; - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:NSLocalizedString(@"DELETE_ENTRY", "Set Title")]; - } + MPSetActionName(@"DELETE_ENTRY", ""); //[[NSNotificationCenter defaultCenter] postNotificationName:@"" object:self userInfo:nil]; [self.parent removeObjectFromEntriesAtIndex:oldIndex]; @@ -138,9 +118,7 @@ if(![[self undoManager] isUndoing]) {\ } [[[self undoManager] prepareWithInvocationTarget:self] _moveToGroup:self.parent atIndex:oldIndex actionName:name]; - if(![[self undoManager] isUndoing]) { - [[self undoManager] setActionName:name]; - } + MPSetActionName(name, ""); [self.parent removeObjectFromEntriesAtIndex:oldIndex]; // Old indices might be wrong, correct them if necessary diff --git a/MacPass/MPGroupInspectorViewController.m b/MacPass/MPGroupInspectorViewController.m index 309e5a88..f7bb8210 100644 --- a/MacPass/MPGroupInspectorViewController.m +++ b/MacPass/MPGroupInspectorViewController.m @@ -12,6 +12,7 @@ #import "Kdb.h" #import "Kdb4Node.h" +#import "Kdb4Group+Undo.h" #import "HNHScrollView.h" #import "HNHRoundedTextField.h" @@ -75,7 +76,7 @@ - (void)_updateBindings { if(self.group) { [self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:@"nameUndoable" options:nil]; - if([self.group respondsToSelector:@selector(notes:)]) { + if([self.group isKindOfClass:[Kdb4Group class]]) { [self.notesTextView bind:NSValueBinding toObject:self.group withKeyPath:@"notesUndoable" options:nil]; } else { diff --git a/MacPassTests/KPKTestNSCoding.m b/MacPassTests/KPKTestNSCoding.m index c3c25757..3c9e4f3e 100644 --- a/MacPassTests/KPKTestNSCoding.m +++ b/MacPassTests/KPKTestNSCoding.m @@ -28,10 +28,6 @@ } - (void)testEntryCoding { - /* - 1. Deep Copy - 2. Copy without History - */ KPKEntry *entry = [[KPKEntry alloc] init]; entry.title = @"Title"; diff --git a/MacPassTests/KPKTestNSCopying.m b/MacPassTests/KPKTestNSCopying.m index b589f62c..2998ff01 100644 --- a/MacPassTests/KPKTestNSCopying.m +++ b/MacPassTests/KPKTestNSCopying.m @@ -7,7 +7,59 @@ // #import "KPKTestNSCopying.h" +#import "KPKEntry.h" +#import "KPKAttribute.h" +#import "KPKBinary.h" + @implementation KPKTestNSCopying +- (void)testAttributeCopying { + KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"Key" value:@"Value" isProtected:NO]; + KPKAttribute *copy = [attribute copy]; + + attribute.key = @"NewKey"; + attribute.value = @"NewValue"; + attribute.isProtected = YES; + + STAssertNotNil(copy, @"Copy shoule exist"); + STAssertTrue([copy.key isEqualToString:@"Key"], @"Copy key should be key"); + STAssertTrue([copy.value isEqualToString:@"Value"], @"Copy value should be value"); + STAssertFalse(copy.isProtected, @"Copy should not be protected"); +} + +- (void)testEntryCopying { + KPKEntry *entry = [[KPKEntry alloc] init]; + + entry.title = @"Title"; + entry.url = @"URL"; + entry.username = @"Username"; + entry.password = @"Password"; + + uint8 bytes[] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF }; + NSData *data = [[NSData alloc] initWithBytes:bytes length:5]; + + KPKBinary *binary = [[KPKBinary alloc] init]; + binary.data = data; + binary.name = @"Binary"; + + [entry addBinary:binary]; + [entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@"Custom" value:@"Value" isProtected:NO]]; + + KPKEntry *copyEntry = [entry copy]; + + entry.title = @"NewTitle"; + [entry removeBinary:binary]; + [[entry.customAttributes lastObject] setKey:@"NewCustomKey"]; + + STAssertNotNil(copyEntry, @"Copied Entry cannot be nil"); + STAssertTrue([copyEntry.title isEqualToString:@"Title"], @"Titles should match"); + STAssertTrue([copyEntry.url isEqualToString:@"URL"], @"URLS should match"); + STAssertTrue([copyEntry.binaries count] == 1, @"Binareis should be copied"); + + KPKBinary *copiedBinary = [copyEntry.binaries lastObject]; + STAssertTrue([copiedBinary.data isEqualToData:binary.data], @"Binary data should match"); + STAssertTrue([copiedBinary.name isEqualToString:binary.name], @"Binary names should macht"); +} + @end diff --git a/MiniKeePassLib b/MiniKeePassLib index 80c95a1e..692f6fbf 160000 --- a/MiniKeePassLib +++ b/MiniKeePassLib @@ -1 +1 @@ -Subproject commit 80c95a1eadc96259dbfe3f9f4bdb8401b33ae551 +Subproject commit 692f6fbf1188ad50899c9fc9084a5e1d1e9c09f5