diff --git a/HNHUi b/HNHUi index a4186af4..32be9c7c 160000 --- a/HNHUi +++ b/HNHUi @@ -1 +1 @@ -Subproject commit a4186af409bc28b1ebd9ba0559c68365b69cead9 +Subproject commit 32be9c7cea56bbec94e6a974e5561ee330372895 diff --git a/KeePassKit b/KeePassKit index 4a383312..8b8d3406 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 4a3833128e2290b0cbb5f3a6695039bdbae9f39a +Subproject commit 8b8d3406a5dfa826b74823f02ff8e140ec0ff8c7 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index e5779f38..a2228ec5 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 4C01C23F1764D2980016D5D0 /* KdbEntry+Undo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */; }; 4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */; }; 4C01C245176500C40016D5D0 /* HNHLevelIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C244176500C40016D5D0 /* HNHLevelIndicatorCell.m */; }; + 4C055E74179620BF00BD2BAB /* NSString+CommandString.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C055E73179620BF00BD2BAB /* NSString+CommandString.m */; }; 4C10412C178CDD44001B5239 /* NSDate+Humanized.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */; }; 4C16BA6217879A3C002B42BD /* MPPasswordStringFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C16BA6117879A3C002B42BD /* MPPasswordStringFormatter.m */; }; 4C18F9AB178E122500890BCE /* Test_Password_1234.kdb in Resources */ = {isa = PBXBuildFile; fileRef = 4C18F9AA178E122500890BCE /* Test_Password_1234.kdb */; }; @@ -186,6 +187,8 @@ 4CAF62FC1763604000CD7084 /* HNHBadgedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAF62FB1763604000CD7084 /* HNHBadgedTextFieldCell.m */; }; 4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; }; 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */; }; + 4CC0D2CE17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC0D2CD17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m */; }; + 4CC0D2D117974A5A000B4BDA /* MPAttachmentTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC0D2D017974A5A000B4BDA /* MPAttachmentTableViewDelegate.m */; }; 4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; }; 4CC299FF176F99E50050C939 /* MPRequestHandlerService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC299FE176F99E50050C939 /* MPRequestHandlerService.m */; }; 4CC29A02176F9D140050C939 /* MPTestAssociateRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC29A01176F9D140050C939 /* MPTestAssociateRequestHandler.m */; }; @@ -234,6 +237,8 @@ 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextMenuHelper.m; sourceTree = ""; }; 4C01C243176500C40016D5D0 /* HNHLevelIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHLevelIndicatorCell.h; sourceTree = ""; }; 4C01C244176500C40016D5D0 /* HNHLevelIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHLevelIndicatorCell.m; sourceTree = ""; }; + 4C055E72179620BF00BD2BAB /* NSString+CommandString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CommandString.h"; sourceTree = ""; }; + 4C055E73179620BF00BD2BAB /* NSString+CommandString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+CommandString.m"; sourceTree = ""; }; 4C10412A178CDD44001B5239 /* NSDate+Humanized.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+Humanized.h"; sourceTree = ""; }; 4C10412B178CDD44001B5239 /* NSDate+Humanized.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+Humanized.m"; sourceTree = ""; }; 4C16BA6017879A3C002B42BD /* MPPasswordStringFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordStringFormatter.h; sourceTree = ""; }; @@ -568,6 +573,10 @@ 4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 4CBA2AB617074B59006D8139 /* MPSettingsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsHelper.h; sourceTree = ""; }; 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsHelper.m; sourceTree = ""; }; + 4CC0D2CC17974A47000B4BDA /* MPCustomFieldTableViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPCustomFieldTableViewDelegate.h; sourceTree = ""; }; + 4CC0D2CD17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPCustomFieldTableViewDelegate.m; sourceTree = ""; }; + 4CC0D2CF17974A5A000B4BDA /* MPAttachmentTableViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAttachmentTableViewDelegate.h; sourceTree = ""; }; + 4CC0D2D017974A5A000B4BDA /* MPAttachmentTableViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAttachmentTableViewDelegate.m; sourceTree = ""; }; 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = ""; }; 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbTree+MPAdditions.m"; sourceTree = ""; }; 4CC299FD176F99E50050C939 /* MPRequestHandlerService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRequestHandlerService.h; sourceTree = ""; }; @@ -955,6 +964,10 @@ 4C811C8216ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m */, 4CE298E91795FC2A00DF7BDB /* MPEntryMenuDelegate.h */, 4CE298EA1795FC2A00DF7BDB /* MPEntryMenuDelegate.m */, + 4CC0D2CC17974A47000B4BDA /* MPCustomFieldTableViewDelegate.h */, + 4CC0D2CD17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m */, + 4CC0D2CF17974A5A000B4BDA /* MPAttachmentTableViewDelegate.h */, + 4CC0D2D017974A5A000B4BDA /* MPAttachmentTableViewDelegate.m */, ); name = Delegates; sourceTree = ""; @@ -1358,6 +1371,8 @@ 4C8A173C1790AA41008B5C17 /* NSData+Keyfile.m */, 4CDB5C401794AA4F0017667E /* KPKTree+Serializing.h */, 4CDB5C411794AA4F0017667E /* KPKTree+Serializing.m */, + 4C055E72179620BF00BD2BAB /* NSString+CommandString.h */, + 4C055E73179620BF00BD2BAB /* NSString+CommandString.m */, ); path = Categories; sourceTree = ""; @@ -1790,6 +1805,9 @@ 4CDB5C421794AA4F0017667E /* KPKTree+Serializing.m in Sources */, 4C5AA591179549A1008ECAD7 /* KPKXmlTreeWriter.m in Sources */, 4CE298EB1795FC2A00DF7BDB /* MPEntryMenuDelegate.m in Sources */, + 4C055E74179620BF00BD2BAB /* NSString+CommandString.m in Sources */, + 4CC0D2CE17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m in Sources */, + 4CC0D2D117974A5A000B4BDA /* MPAttachmentTableViewDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 1233112a..7711222c 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -133,65 +133,11 @@ 268 - - - - -2147483380 - {{184, 5}, {45, 19}} - - - - _NS:9 - YES - - -2080374784 - 134217728 - Done - - LucidaGrande - 12 - 16 - - _NS:9 - - -2038153216 - 164 - - - 400 - 75 - - NO - - - - -2147483380 - {{237, 5}, {36, 19}} - - - _NS:9 - YES - - -2080374784 - 134217728 - Edit - - _NS:9 - - -2038153216 - 164 - - - 400 - 75 - - NO - - + {293, 30} - + _NS:9 HNHGradientView @@ -256,13 +202,13 @@ {{0, 31}, {293, 399}} - + _NS:9 1 - + 256 @@ -270,7 +216,6 @@ 268 {{17, 365}, {35, 14}} - _NS:1535 YES @@ -303,7 +248,6 @@ 268 {{20, 335}, {253, 22}} - _NS:9 YES @@ -338,7 +282,6 @@ 268 {{17, 313}, {58, 14}} - _NS:1535 YES @@ -359,7 +302,6 @@ 268 {{20, 283}, {253, 22}} - _NS:9 YES @@ -381,7 +323,6 @@ 268 {{20, 231}, {253, 22}} - _NS:9 YES @@ -403,7 +344,6 @@ 268 {{17, 261}, {25, 14}} - _NS:1535 YES @@ -424,7 +364,6 @@ 268 {{17, 209}, {58, 14}} - _NS:1535 YES @@ -445,7 +384,6 @@ 268 {{20, 152}, {253, 19}} - _NS:9 {250, 750} @@ -454,7 +392,11 @@ -2080374784 134217728 Generate - + + LucidaGrande + 12 + 16 + _NS:9 -2038153216 @@ -471,7 +413,6 @@ 268 {{17, 35}, {259, 11}} - _NS:1535 YES @@ -496,8 +437,7 @@ 268 {{17, 16}, {259, 11}} - - + _NS:1535 YES @@ -517,7 +457,6 @@ 268 {{20, 179}, {214, 22}} - _NS:9 YES @@ -542,7 +481,6 @@ 268 {{242, 177}, {31, 25}} - _NS:22 YES @@ -568,8 +506,6 @@ {293, 399} - - _NS:11 @@ -596,7 +532,7 @@ 2322 {251, 332} - + _NS:13 @@ -688,7 +624,7 @@ 256 {{236, 1}, {16, 332}} - + _NS:83 NO @@ -713,7 +649,7 @@ {{20, 20}, {253, 334}} - + _NS:9 133138 @@ -926,7 +862,6 @@ -2147483392 {{1, 147}, {52, 16}} - _NS:60 NO 1 @@ -958,7 +893,7 @@ - + 256 @@ -966,6 +901,7 @@ 268 {{241, 362}, {32, 19}} + _NS:9 YES @@ -991,6 +927,7 @@ 268 {{17, 365}, {80, 14}} + _NS:1535 YES @@ -1020,6 +957,7 @@ {259, 333} + _NS:13 YES @@ -1082,6 +1020,7 @@ {{1, 1}, {259, 333}} + _NS:11 @@ -1093,6 +1032,7 @@ -2147483392 {{224, 17}, {15, 102}} + _NS:58 NO @@ -1105,6 +1045,7 @@ -2147483392 {{1, 119}, {223, 15}} + _NS:60 NO @@ -1116,6 +1057,7 @@ {{16, 20}, {261, 335}} + _NS:9 133681 @@ -1129,6 +1071,8 @@ {293, 399} + + Fields @@ -1136,13 +1080,13 @@ - + 6 YES YES - + @@ -1463,7 +1407,7 @@ 268 {{223, 11}, {32, 19}} - + _NS:9 YES @@ -1653,6 +1597,72 @@ 2260 + + + valueTextField + + + 274 + + + + 268 + {{3, 10}, {250, 22}} + + + _NS:9 + YES + + -1805647871 + 272629760 + + + Value + _NS:9 + + YES + + + + NO + + + + 268 + {{0, 40}, {258, 14}} + + + _NS:9 + YES + + -1808793535 + 272761856 + + + Title + _NS:9 + + + + + NO + + + {{1, 57}, {256, 54}} + + + + + 2365 + + + + labelTextField + + + + 2366 + @@ -2003,70 +2013,6 @@ 662 - - - 5 - 0 - - 6 - 1 - - 8 - - 1000 - - 6 - 24 - 3 - - - - 6 - 0 - - 6 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - 11 - 0 - - 11 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 5 - 22 - 2 - 8 @@ -2083,8 +2029,6 @@ 40 1 - - @@ -3841,6 +3785,7 @@ + @@ -4679,57 +4624,256 @@ - - 2313 - - - - - - - - 2314 - - - - - 2315 - - - - - 2317 - - - - - - - - 2318 - - - - - 2319 - - - - - 2320 - - - - - 2321 - - - 2322 + + 2345 + + + + + + + 6 + 0 + + 6 + 1 + + 3 + + 1000 + + 8 + 29 + 3 + + + + 4 + 0 + + 4 + 1 + + 10 + + 1000 + + 9 + 40 + 3 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 5 + 0 + + 5 + 1 + + 3 + + 1000 + + 9 + 40 + 3 + + + + 3 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 9 + 40 + 3 + + + + 5 + 0 + + 5 + 1 + + 3 + + 1000 + + 8 + 29 + 3 + + + + + + 2347 + + + + + 7 + 1 + + 0 + 1 + + 80 + + 1000 + + 9 + 40 + 1 + + + + 8 + 1 + + 0 + 1 + + 22 + + 1000 + + 9 + 40 + 1 + + + + + + + 2348 + + + + + 7 + 0 + + 0 + 1 + + 252 + + 1000 + + 3 + 9 + 1 + + + + 8 + 0 + + 0 + 1 + + 14 + + 1000 + + 9 + 40 + 1 + + + + + + + 2349 + + + + + 2351 + + + + + 2352 + + + + + 2353 + + + + + 2354 + + + + + 2358 + + + + + 2359 + + + + + 2360 + + + + + 2361 + + + + + 2362 + + + + + 2369 + + + + + 2370 + + + @@ -4786,7 +4930,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - + @@ -4975,6 +5119,7 @@ + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4994,6 +5139,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + SelectedCell @@ -5107,17 +5253,43 @@ 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 + MPCustomFieldTableCellView + + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + NormalCell + + + + + + 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 + HNHRoundedTextFieldCell + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -5152,10 +5324,6 @@ com.apple.InterfaceBuilder.CocoaPlugin - - - - com.apple.InterfaceBuilder.CocoaPlugin @@ -5168,7 +5336,7 @@ - 2322 + 2370 diff --git a/MacPass/DocumentWindow.xib b/MacPass/DocumentWindow.xib index adde5c56..1c4b3bf1 100644 --- a/MacPass/DocumentWindow.xib +++ b/MacPass/DocumentWindow.xib @@ -52,6 +52,7 @@ {{0, 0}, {1920, 1058}} {10000000000000, 10000000000000} + DatabaseWindow YES @@ -159,6 +160,7 @@ NSWindowController id + id id @@ -166,6 +168,10 @@ editPassword: id + + exportDatabase: + id + showDatabaseSettings: id diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 1b8731fa..ab22ef52 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -45,9 +45,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { serverDaemon = [[MPServerDaemon alloc] init]; lockDaemon = [[MPLockDaemon alloc] init]; + NSUInteger openDocs = [[[NSDocumentController sharedDocumentController] documents] count]; + if(openDocs == 0) { + NSLog(@"Do something!"); + } } - - (NSString *)applicationName { return [[NSBundle mainBundle] infoDictionary][@"CFBundleName"]; } diff --git a/MacPass/MPAttachmentTableViewDelegate.h b/MacPass/MPAttachmentTableViewDelegate.h new file mode 100644 index 00000000..7797aae4 --- /dev/null +++ b/MacPass/MPAttachmentTableViewDelegate.h @@ -0,0 +1,17 @@ +// +// MPAttachmentTableViewDelegate.h +// MacPass +// +// Created by Michael Starke on 17.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@class MPInspectorViewController; + +@interface MPAttachmentTableViewDelegate : NSObject + +@property (nonatomic, weak) MPInspectorViewController *viewController; + +@end diff --git a/MacPass/MPAttachmentTableViewDelegate.m b/MacPass/MPAttachmentTableViewDelegate.m new file mode 100644 index 00000000..f8be1bef --- /dev/null +++ b/MacPass/MPAttachmentTableViewDelegate.m @@ -0,0 +1,65 @@ +// +// MPAttachmentTableViewDelegate.m +// MacPass +// +// Created by Michael Starke on 17.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPAttachmentTableViewDelegate.h" + +#import "MPInspectorViewController.h" +#import "MPSelectedAttachmentTableCellView.h" + +#import "Kdb4Node.h" + +#import "HNHTableRowView.h" + +@implementation MPAttachmentTableViewDelegate + +- (void)tableViewSelectionDidChange:(NSNotification *)notification { + NSTableView *tableView = [notification object]; + NSIndexSet *allColumns = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[tableView tableColumns] count])]; + Kdb4Entry *entryv4 = (Kdb4Entry *)self.viewController.selectedEntry; + NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [entryv4.binaries count] )]; + [tableView reloadDataForRowIndexes:indexSet columnIndexes:allColumns]; +} + +- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { + /* Decide what view to use */ + NSIndexSet *selectedIndexes = [tableView selectedRowIndexes]; + NSTableCellView *view; + if([selectedIndexes containsIndex:row]) { + MPSelectedAttachmentTableCellView *cellView = [tableView makeViewWithIdentifier:@"SelectedCell" owner:tableView]; + [cellView.saveButton setTag:row]; + [cellView.saveButton setAction:@selector(saveAttachment:)]; + [cellView.saveButton setTarget:self.viewController]; + [cellView.removeButton setTag:row]; + [cellView.removeButton setAction:@selector(removeAttachment:)]; + [cellView.removeButton setTarget:self.viewController]; + view = cellView; + } + else { + view = [tableView makeViewWithIdentifier:@"NormalCell" owner:tableView]; + } + /* Bind view */ + if([self.viewController.selectedEntry isKindOfClass:[Kdb4Entry class]]) { + Kdb4Entry *entry = (Kdb4Entry *)self.viewController.selectedEntry; + BinaryRef *binaryRef = entry.binaries[row]; + [[view textField] bind:NSValueBinding toObject:binaryRef withKeyPath:@"key" options:nil]; + [[view imageView] setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[binaryRef.key pathExtension]]]; + } + else { + // Create view to support only one binary! + } + return view; +} + +- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row { + HNHTableRowView *view = nil; + view = [[HNHTableRowView alloc] init]; + view.selectionCornerRadius = 7; + return view; +} + +@end diff --git a/MacPass/MPCustomFieldTableViewDelegate.h b/MacPass/MPCustomFieldTableViewDelegate.h new file mode 100644 index 00000000..a64d791a --- /dev/null +++ b/MacPass/MPCustomFieldTableViewDelegate.h @@ -0,0 +1,17 @@ +// +// MPCustomFieldTableDelegate.h +// MacPass +// +// Created by Michael Starke on 17.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@class MPInspectorViewController; + +@interface MPCustomFieldTableViewDelegate : NSObject + +@property (nonatomic, weak) MPInspectorViewController *viewController; + +@end diff --git a/MacPass/MPCustomFieldTableViewDelegate.m b/MacPass/MPCustomFieldTableViewDelegate.m new file mode 100644 index 00000000..6a5c284e --- /dev/null +++ b/MacPass/MPCustomFieldTableViewDelegate.m @@ -0,0 +1,41 @@ +// +// MPCustomFieldTableDelegate.m +// MacPass +// +// Created by Michael Starke on 17.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPCustomFieldTableViewDelegate.h" +#import "MPInspectorViewController.h" +#import "MPCustomFieldTableCellView.h" + +#import "Kdb4Node.h" +#import "StringField+Undo.h" + +@implementation MPCustomFieldTableViewDelegate + +- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { + if(![self.viewController.selectedEntry isKindOfClass:[Kdb4Entry class]]) { + return nil; + } + Kdb4Entry *entry = (Kdb4Entry *)self.viewController.selectedEntry; + MPCustomFieldTableCellView *view = [tableView makeViewWithIdentifier:@"NormalCell" owner:tableView]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_customFieldFrameChanged:) name:NSViewFrameDidChangeNotification object:view]; + if([self.viewController.selectedEntry isKindOfClass:[Kdb4Entry class]]) { + StringField *stringField = entry.stringFields[row]; + [view.labelTextField bind:NSValueBinding toObject:stringField withKeyPath:MPStringFieldKeyUndoableKey options:nil]; + [view.valueTextField bind:NSValueBinding toObject:stringField withKeyPath:MPStringFieldValueUndoableKey options:nil]; + [view.removeButton setTarget:self.viewController]; + [view.removeButton setAction:@selector(removeCustomField:)]; + [view.removeButton setTag:row]; + } + return view; +} + +- (void)_customFieldFrameChanged:(NSNotification *)notification { + // NSView *sender = [notification object]; + // NSLog(@"didChangeFrameFor: %@ to: %@", sender, NSStringFromRect([sender frame])); +} + +@end diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 278b72f3..e1cb15b9 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -354,7 +354,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return newStringField; } - - (void)moveGroup:(KdbGroup *)group toGroup:(KdbGroup *)target index:(NSInteger)index { NSInteger oldIndex = [group.parent.groups indexOfObject:group]; if(group.parent == target && oldIndex == index) { diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index b381b69f..377187d1 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -19,7 +19,7 @@ APPKIT_EXTERN NSString *const MPCurrentItemChangedNotification; -@interface MPDocumentWindowController : NSWindowController +@interface MPDocumentWindowController : NSWindowController @property (readonly, strong) MPPasswordInputController *passwordInputController; @property (readonly, strong) MPEntryViewController *entryViewController; diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 67594129..dc1532a0 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -148,6 +148,9 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [passwordColumn setIdentifier:MPEntryTablePasswordColumnIdentifier]; [urlColumn setIdentifier:MPEntryTableURLColumnIdentifier]; + [self.entryTable setAutosaveName:@"EntryTable"]; + [self.entryTable setAutosaveTableColumns:YES]; + NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)]; NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)]; NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)]; diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h index 3ca51dbe..1707fa6c 100644 --- a/MacPass/MPInspectorViewController.h +++ b/MacPass/MPInspectorViewController.h @@ -15,7 +15,7 @@ @class HNHRoundedSecureTextField; @class MPDocumentWindowController; -@interface MPInspectorViewController : MPViewController +@interface MPInspectorViewController : MPViewController @property (weak) IBOutlet MPPopupImageView *itemImageView; @property (weak) IBOutlet NSTextField *itemNameTextfield; @@ -36,6 +36,9 @@ @property (weak) IBOutlet NSButton *togglePassword; +@property (weak, nonatomic, readonly) KdbEntry *selectedEntry; +@property (weak, nonatomic, readonly) KdbGroup *selectedGroup; + /* Seperate call to ensure alle registered objects are in place */ - (void)setupNotifications:(MPDocumentWindowController *)windowController; diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index ef4cd8a3..4d515b45 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -20,6 +20,8 @@ #import "MPDatabaseVersion.h" #import "MPCustomFieldTableCellView.h" #import "MPSelectedAttachmentTableCellView.h" +#import "MPAttachmentTableViewDelegate.h" +#import "MPCustomFieldTableViewDelegate.h" #import "NSDate+Humanized.h" @@ -45,6 +47,10 @@ enum { @interface MPInspectorViewController () { BOOL _visible; + NSArrayController *_attachmentsController; + NSArrayController *_customFieldsController; + MPAttachmentTableViewDelegate *_attachmentTableDelegate; + MPCustomFieldTableViewDelegate *_customFieldTableDelegate; } @property (weak, nonatomic) KdbEntry *selectedEntry; @@ -60,8 +66,6 @@ enum { @property (nonatomic, assign) NSUInteger activeTab; @property (weak) IBOutlet NSTabView *tabView; -@property (strong) NSArrayController *attachmentsController; -@property (strong) NSArrayController *customFieldsController; - (IBAction)addCustomField:(id)sender; - (IBAction)removeCustomField:(id)sender; @@ -87,6 +91,10 @@ enum { _selectedGroup = nil; _attachmentsController = [[NSArrayController alloc] init]; _customFieldsController = [[NSArrayController alloc] init]; + _attachmentTableDelegate = [[MPAttachmentTableViewDelegate alloc] init]; + _attachmentTableDelegate.viewController = self; + _customFieldTableDelegate = [[MPCustomFieldTableViewDelegate alloc] init]; + _customFieldTableDelegate.viewController = self; _activeTab = MPGeneralTab; } return self; @@ -107,12 +115,12 @@ enum { /* Set background to clearcolor so we can draw in the scrollview */ [_attachmentTableView setBackgroundColor:[NSColor clearColor]]; - [_attachmentTableView bind:NSContentBinding toObject:self.attachmentsController withKeyPath:@"arrangedObjects" options:nil]; - [_attachmentTableView setDelegate:self]; + [_attachmentTableView bind:NSContentBinding toObject:_attachmentsController withKeyPath:@"arrangedObjects" options:nil]; + [_attachmentTableView setDelegate:_attachmentTableDelegate]; /* Set background to clearcolor so we can draw in the scrollview */ [_customFieldsTableView setBackgroundColor:[NSColor clearColor]]; - [_customFieldsTableView bind:NSContentBinding toObject:self.customFieldsController withKeyPath:@"arrangedObjects" options:nil]; - [_customFieldsTableView setDelegate:self]; + [_customFieldsTableView bind:NSContentBinding toObject:_customFieldsController withKeyPath:@"arrangedObjects" options:nil]; + [_customFieldsTableView setDelegate:_customFieldTableDelegate]; [self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil]; [self.togglePassword bind:NSValueBinding toObject:self withKeyPath:@"showPassword" options:nil]; @@ -167,26 +175,26 @@ enum { - (void)_updateAttachments { if(self.selectedEntry) { if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { - [self.attachmentsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"binaries" options:nil]; + [_attachmentsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"binaries" options:nil]; } else { /* Use binary from Kdb3Entry */ } } - else if([self.attachmentsController content] != nil){ - [self.attachmentsController unbind:NSContentArrayBinding]; - [self.attachmentsController setContent:nil]; + else if([_attachmentsController content] != nil){ + [_attachmentsController unbind:NSContentArrayBinding]; + [_attachmentsController setContent:nil]; } } - (void)_updateCustomFields { if(self.selectedEntry && [self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { - [self.customFieldsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"stringFields" options:nil]; + [_customFieldsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"stringFields" options:nil]; } - else if([self.customFieldsController content] != nil){ - [self.customFieldsController unbind:NSContentArrayBinding]; - [self.customFieldsController setContent:nil]; + else if([_customFieldsController content] != nil){ + [_customFieldsController unbind:NSContentArrayBinding]; + [_customFieldsController setContent:nil]; } } @@ -412,78 +420,4 @@ enum { [self _updateContent]; } - -#pragma mark NSTableViewDelegate -/* TODO: Divide this into single delegates */ -- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - if(tableView == self.attachmentTableView) { - return [self _viewForAttachmentTableColumn:tableColumn row:row]; - } - return [self _viewForCustomFieldTableColumn:tableColumn row:row]; -} - -- (void)tableViewSelectionDidChange:(NSNotification *)notification { - if([notification object] == self.attachmentTableView) { - NSIndexSet *allColumns = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[self.attachmentTableView tableColumns] count])]; - Kdb4Entry *entryv4 = (Kdb4Entry *)self.selectedEntry; - NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [entryv4.binaries count] )]; - [self.attachmentTableView reloadDataForRowIndexes:indexSet columnIndexes:allColumns]; - } -} - -- (NSView *)_viewForAttachmentTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - /* Decide what view to use */ - NSIndexSet *selectedIndexes = [self.attachmentTableView selectedRowIndexes]; - NSTableCellView *view; - if([selectedIndexes containsIndex:row]) { - MPSelectedAttachmentTableCellView *cellView = [_attachmentTableView makeViewWithIdentifier:@"SelectedCell" owner:_attachmentTableView]; - [cellView.saveButton setTag:row]; - [cellView.saveButton setAction:@selector(saveAttachment:)]; - [cellView.saveButton setTarget:self]; - [cellView.removeButton setTag:row]; - [cellView.removeButton setAction:@selector(removeAttachment:)]; - [cellView.removeButton setTarget:self]; - view = cellView; - } - else { - view = [_attachmentTableView makeViewWithIdentifier:@"NormalCell" owner:_attachmentTableView]; - } - /* Bind view */ - if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { - Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; - BinaryRef *binaryRef = entry.binaries[row]; - [[view textField] bind:NSValueBinding toObject:binaryRef withKeyPath:@"key" options:nil]; - [[view imageView] setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[binaryRef.key pathExtension]]]; - } - return view; -} -- (NSView *)_viewForCustomFieldTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - MPCustomFieldTableCellView *view = [_customFieldsTableView makeViewWithIdentifier:[tableColumn identifier] owner:_customFieldsTableView]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_customFieldFrameChanged:) name:NSViewFrameDidChangeNotification object:view]; - if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { - Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; - StringField *stringField = entry.stringFields[row]; - [view.labelTextField bind:NSValueBinding toObject:stringField withKeyPath:MPStringFieldKeyUndoableKey options:nil]; - [view.valueTextField bind:NSValueBinding toObject:stringField withKeyPath:MPStringFieldValueUndoableKey options:nil]; - [view.removeButton setTarget:self]; - [view.removeButton setAction:@selector(removeCustomField:)]; - [view.removeButton setTag:row]; - } - return view; -} - -- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row { - HNHTableRowView *view = nil; - if(tableView == self.attachmentTableView) { - view = [[HNHTableRowView alloc] init]; - view.selectionCornerRadius = 7; - } - return view; -} - -- (void)_customFieldFrameChanged:(NSNotification *)notification { - // NSView *sender = [notification object]; - // NSLog(@"didChangeFrameFor: %@ to: %@", sender, NSStringFromRect([sender frame])); -} - @end diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 3fc06582..203ec20c 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -27,7 +27,7 @@ NSString *const kMPSettingsKeyIdleLockTimeOut = @"IdleLockTimeOut"; return @{ kMPSettingsKeyPasteboardClearTimeout: @30, // 30 seconds kMPSettingsKeyClearPasteboardOnQuit: @YES, - kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @YES, + kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @NO, kMPSettingsKeyHttpPort: @19455, kMPSettingsKeyEnableHttpServer: @NO, kMPSettingsKeyShowMenuItem: @YES, diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index dc9e1059..e1987841 100644 Binary files a/MacPass/en.lproj/Localizable.strings and b/MacPass/en.lproj/Localizable.strings differ