From 4a3232b39d5d906ab62a406796ddbf8701eed04f Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 3 Jul 2013 14:53:24 +0200 Subject: [PATCH] Converted to modern Objective-C New UI for exporting attachments --- HNHUi | 2 +- MacPass.xcodeproj/project.pbxproj | 6 + MacPass/Base.lproj/InspectorView.xib | 487 ++++++++++++++++++-- MacPass/Kdb4Entry+KVOAdditions.m | 2 +- MacPass/Kdb4Tree+KVOAdditions.m | 4 +- MacPass/KdbGroup+KVOAdditions.m | 4 +- MacPass/MPInspectorViewController.m | 18 +- MacPass/MPSelectedAttachmentTableCellView.h | 16 + MacPass/MPSelectedAttachmentTableCellView.m | 13 + MacPass/MPServerSettingsController.m | 1 + MacPass/MacPass-Info.plist | 2 +- MacPass/NSString+MPPasswordCreation.m | 2 +- MiniKeePassLib | 2 +- 13 files changed, 507 insertions(+), 52 deletions(-) create mode 100644 MacPass/MPSelectedAttachmentTableCellView.h create mode 100644 MacPass/MPSelectedAttachmentTableCellView.m diff --git a/HNHUi b/HNHUi index 1dda7a87..19711e36 160000 --- a/HNHUi +++ b/HNHUi @@ -1 +1 @@ -Subproject commit 1dda7a87d817ae44cafbd15b4e593a40b6954bbb +Subproject commit 19711e36d54db50ceb2c76e19e3a85b90caca87f diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index fe14c35a..0b43e386 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ 4C5A11FF1708DE8800223D8A /* PasswordCreatorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */; }; 4C5BF67B175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */; }; 4C5EC302177B700D00DA955B /* MPRootAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5EC301177B700D00DA955B /* MPRootAdapter.m */; }; + 4C5FE9AE17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5FE9AD17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m */; }; 4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */; }; 4C61EA0516D2FFE200AC519E /* OutlineView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C61EA0416D2FFE200AC519E /* OutlineView.xib */; }; 4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65C79B16DD283900E32CFF /* MPToolbarButton.m */; }; @@ -330,6 +331,8 @@ 4C5BF67A175C01F300D53DF7 /* MPUppercaseStringValueTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPUppercaseStringValueTransformer.m; sourceTree = ""; }; 4C5EC300177B700D00DA955B /* MPRootAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRootAdapter.h; sourceTree = ""; }; 4C5EC301177B700D00DA955B /* MPRootAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRootAdapter.m; sourceTree = ""; }; + 4C5FE9AC17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSelectedAttachmentTableCellView.h; sourceTree = ""; }; + 4C5FE9AD17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSelectedAttachmentTableCellView.m; sourceTree = ""; }; 4C61EA0116D2FD0800AC519E /* MPOutlineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewController.h; sourceTree = ""; }; 4C61EA0216D2FD0800AC519E /* MPOutlineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineViewController.m; sourceTree = ""; }; 4C61EA0416D2FFE200AC519E /* OutlineView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OutlineView.xib; sourceTree = ""; }; @@ -587,6 +590,8 @@ 4C4A100E176286FD00BBF2CA /* MPTableView.m */, 4C4FCE13177CFE6B00BBF7AE /* MPCustomFieldTableCellView.h */, 4C4FCE14177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m */, + 4C5FE9AC17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.h */, + 4C5FE9AD17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m */, ); name = Views; sourceTree = ""; @@ -1492,6 +1497,7 @@ 4CC7EA1B17807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.m in Sources */, 4CC672791781D0C0006DEDCF /* KdbGroup+MPAdditions.m in Sources */, 4CC6727C1781D0D2006DEDCF /* KdbEntry+MPAdditions.m in Sources */, + 4C5FE9AE17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 1552c705..6d78b0a5 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -202,7 +202,7 @@ {{0, 31}, {293, 399}} - + _NS:9 @@ -526,7 +526,7 @@ 2 - + 256 @@ -540,29 +540,9 @@ 2322 - - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - public.url - {251, 332} - - + _NS:13 @@ -624,7 +604,6 @@ {{1, 1}, {251, 332}} - _NS:11 @@ -655,7 +634,6 @@ 256 {{236, 1}, {16, 332}} - _NS:83 NO @@ -669,7 +647,6 @@ -2147483392 {{-100, -100}, {87, 18}} - _NS:33 NO @@ -682,8 +659,7 @@ {{20, 20}, {253, 334}} - - + _NS:9 133138 @@ -698,7 +674,6 @@ 268 {{17, 362}, {35, 17}} - _NS:1535 YES @@ -716,8 +691,6 @@ {293, 399} - - _NS:28 @@ -727,7 +700,7 @@ - + 256 @@ -735,6 +708,7 @@ 268 {{241, 362}, {32, 19}} + _NS:9 YES @@ -763,6 +737,7 @@ 268 {{17, 365}, {79, 14}} + _NS:1535 YES @@ -792,6 +767,7 @@ {251, 332} + _NS:13 YES @@ -876,6 +852,7 @@ {{1, 1}, {251, 332}} + _NS:11 @@ -887,6 +864,7 @@ -2147483392 {{37, 1}, {16, 2}} + _NS:58 NO @@ -899,6 +877,7 @@ -2147483392 {{1, 147}, {52, 16}} + _NS:60 NO @@ -910,6 +889,7 @@ {{20, 20}, {253, 334}} + _NS:9 133682 @@ -923,6 +903,8 @@ {293, 399} + + Attachments @@ -1078,7 +1060,6 @@ -2147483392 {{1, 119}, {223, 15}} - _NS:60 NO 1 @@ -1109,13 +1090,13 @@ - + 6 YES YES - + @@ -1314,7 +1295,7 @@ 134217728 33554432 - + NSImage NSActionTemplate @@ -1332,7 +1313,7 @@ 266 {{40, 10}, {208, 17}} - + _NS:20 {250, 750} YES @@ -1467,6 +1448,112 @@ 2173 + + + imageView + + + 274 + + + + 268 + + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + {{3, 2}, {32, 32}} + + + _NS:11 + YES + + 134217728 + 33554432 + + _NS:11 + 0 + 0 + 0 + NO + + NO + YES + + + + 266 + {{40, 10}, {160, 17}} + + + _NS:20 + {250, 750} + YES + + 67108928 + 272631808 + Table View Cell + + _NS:20 + + + + + NO + + + + 268 + {{205, 9}, {40, 19}} + + + _NS:9 + YES + + -2080374784 + 134217728 + Save + + _NS:9 + + -2033434624 + 164 + + + 400 + 75 + + NO + + + {{1, 39}, {248, 36}} + + _NS:9 + + + + 2214 + + + + textField + + + + 2215 + + + + saveButton + + + + 2224 + @@ -3342,6 +3429,7 @@ + @@ -4172,6 +4260,265 @@ + + 2202 + + + + + + + 5 + 0 + + 6 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 6 + 0 + + 6 + 1 + + 3 + + 1000 + + 8 + 29 + 3 + + + + 4 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 5 + 0 + + 6 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 5 + 0 + + 5 + 1 + + 3 + + 1000 + + 8 + 29 + 3 + + + + + + + 2203 + + + + + + 7 + 0 + + 0 + 1 + + 32 + + 1000 + + 3 + 9 + 1 + + + + 8 + 0 + + 0 + 1 + + 32 + + 1000 + + 3 + 9 + 1 + + + + + + 2204 + + + + + + + + 2205 + + + + + 2207 + + + + + 2209 + + + + + 2210 + + + + + 2211 + + + + + 2212 + + + + + 2213 + + + + + 2216 + + + + + + 7 + 0 + + 0 + 1 + + 40 + + 1000 + + 3 + 9 + 1 + + + + + + 2217 + + + + + 2218 + + + + + 2219 + + + + + 2220 + + + + + 2222 + + + + + 2223 + + + @@ -4289,6 +4636,7 @@ + com.apple.InterfaceBuilder.CocoaPlugin @@ -4323,6 +4671,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + NormalCell @@ -4509,6 +4858,44 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + MPSelectedAttachmentTableCellView + + + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + SelectedCell + + + + + + 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 @@ -4555,7 +4942,7 @@ - 2201 + 2224 @@ -4638,10 +5025,15 @@ MPInspectorViewController MPViewController + id id id + + _popUpPasswordGenerator: + id + addCustomField: id @@ -4753,6 +5145,25 @@ ./Classes/MPPopupImageView.h + + MPSelectedAttachmentTableCellView + NSTableCellView + + saveButton + NSButton + + + saveButton + + saveButton + NSButton + + + + IBProjectSource + ./Classes/MPSelectedAttachmentTableCellView.h + + MPViewController NSViewController diff --git a/MacPass/Kdb4Entry+KVOAdditions.m b/MacPass/Kdb4Entry+KVOAdditions.m index 7d682347..0f2cc7d9 100644 --- a/MacPass/Kdb4Entry+KVOAdditions.m +++ b/MacPass/Kdb4Entry+KVOAdditions.m @@ -15,7 +15,7 @@ } - (StringField *)objectInStringFieldsAtIndex:(NSUInteger)index { - return [self.stringFields objectAtIndex:index]; + return (self.stringFields)[index]; } - (void)insertObject:(StringField *)stringfield inStringFieldsAtIndex:(NSUInteger)anIndex { diff --git a/MacPass/Kdb4Tree+KVOAdditions.m b/MacPass/Kdb4Tree+KVOAdditions.m index e313a923..405f5489 100644 --- a/MacPass/Kdb4Tree+KVOAdditions.m +++ b/MacPass/Kdb4Tree+KVOAdditions.m @@ -19,11 +19,11 @@ } - (Binary *)objectInBinariesAtIndex:(NSUInteger)index { - return [self.binaries objectAtIndex:index]; + return (self.binaries)[index]; } - (CustomIcon *)objectInCustomIconsAtIndex:(NSUInteger)index { - return [self.customIcons objectAtIndex:index]; + return (self.customIcons)[index]; } @end diff --git a/MacPass/KdbGroup+KVOAdditions.m b/MacPass/KdbGroup+KVOAdditions.m index 846c88d9..3af8ee74 100644 --- a/MacPass/KdbGroup+KVOAdditions.m +++ b/MacPass/KdbGroup+KVOAdditions.m @@ -16,7 +16,7 @@ } - (void)removeObjectFromEntriesAtIndex:(NSUInteger)index { - KdbEntry *entry = [_entries objectAtIndex:index]; + KdbEntry *entry = _entries[index]; [_entries removeObjectAtIndex:index]; entry.parent = nil; } @@ -43,7 +43,7 @@ } - (void)removeObjectFromGroupsAtIndex:(NSUInteger)index { - KdbGroup *group = [self.groups objectAtIndex:index]; + KdbGroup *group = (self.groups)[index]; [_groups removeObjectAtIndex:index]; group.parent = nil; } diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 9924a36c..003beb43 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -315,7 +315,7 @@ enum { MPDocument *document = [[self windowController] document]; NSUInteger index = [sender tag]; Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry; - [document entry:entry removeStringField:[entry.stringFields objectAtIndex:index]]; + [document entry:entry removeStringField:(entry.stringFields)[index]]; } #pragma mark Notificiations @@ -347,16 +347,24 @@ enum { 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])]; + [self.attachmentTableView reloadDataForRowIndexes:[self.attachmentTableView selectedRowIndexes] columnIndexes:allColumns]; + } +} + - (NSView *)_viewForAttachmentTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - NSTableCellView *view = [_attachmentTableView makeViewWithIdentifier:[tableColumn identifier] owner:_attachmentTableView]; + /* Decide what view to use */ + NSIndexSet *selectedIndexes = [self.attachmentTableView selectedRowIndexes]; + NSString *viewIdentifyer = [selectedIndexes containsIndex:row] ? @"SelectedCell" : @"NormalCell"; + NSTableCellView *view = [_attachmentTableView makeViewWithIdentifier:viewIdentifyer 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]]]; - //MPDocument *document = [[self windowController] document]; - //Binary *binary = [document binaryForRef:binaryRef]; - //NSLog(@"%@", binary.data); } return view; } diff --git a/MacPass/MPSelectedAttachmentTableCellView.h b/MacPass/MPSelectedAttachmentTableCellView.h new file mode 100644 index 00000000..45576d2a --- /dev/null +++ b/MacPass/MPSelectedAttachmentTableCellView.h @@ -0,0 +1,16 @@ +// +// MPSelectedAttachmentTableCellView.h +// MacPass +// +// Created by Michael Starke on 03.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +/* Simple View with an additional Button to add an Action to selected rows */ +@interface MPSelectedAttachmentTableCellView : NSTableCellView + +@property (nonatomic, assign) IBOutlet NSButton *saveButton; + +@end diff --git a/MacPass/MPSelectedAttachmentTableCellView.m b/MacPass/MPSelectedAttachmentTableCellView.m new file mode 100644 index 00000000..4493ba3a --- /dev/null +++ b/MacPass/MPSelectedAttachmentTableCellView.m @@ -0,0 +1,13 @@ +// +// MPSelectedAttachmentTableCellView.m +// MacPass +// +// Created by Michael Starke on 03.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPSelectedAttachmentTableCellView.h" + +@implementation MPSelectedAttachmentTableCellView + +@end diff --git a/MacPass/MPServerSettingsController.m b/MacPass/MPServerSettingsController.m index ae86c14b..a4352e84 100644 --- a/MacPass/MPServerSettingsController.m +++ b/MacPass/MPServerSettingsController.m @@ -37,6 +37,7 @@ NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController]; NSString *serverKeyPath = [NSString stringWithFormat:@"values.%@", kMPSettingsKeyEnableHttpServer]; [self.enableServerCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:serverKeyPath options:nil]; + [self.enableServerCheckbutton setEnabled:NO]; } @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 8e60f840..bb2f1961 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 1809 + 1831 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/NSString+MPPasswordCreation.m b/MacPass/NSString+MPPasswordCreation.m index 37204556..8b63e6e6 100644 --- a/MacPass/NSString+MPPasswordCreation.m +++ b/MacPass/NSString+MPPasswordCreation.m @@ -33,7 +33,7 @@ static NSString *allowedCharactersString(MPPasswordCharacterFlags flags) { @implementation NSString (MPPasswordCreationTools) + (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags { - return [NSDictionary dictionary]; + return @{}; } - (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags { diff --git a/MiniKeePassLib b/MiniKeePassLib index 4e64de08..626117bc 160000 --- a/MiniKeePassLib +++ b/MiniKeePassLib @@ -1 +1 @@ -Subproject commit 4e64de0805a471b794ec1e0d574949993ce2233e +Subproject commit 626117bcb11b3416e22b9d7fcb79891b510792ad