From f3001b35e1561a51badf4d1c60c81f6d3f6543d5 Mon Sep 17 00:00:00 2001 From: michael starke Date: Tue, 2 Jul 2013 00:48:48 +0200 Subject: [PATCH] More work on Recylcebin support #24 Document settings display tree to chose recycle bin location --- MacPass.xcodeproj/project.pbxproj | 12 + MacPass/DocumentSettingsWindow.xib | 376 +++++++++++-------- MacPass/KdbEntry+MPAdditions.h | 15 + MacPass/KdbEntry+MPAdditions.m | 19 + MacPass/KdbGroup+MPAdditions.h | 22 ++ MacPass/KdbGroup+MPAdditions.m | 36 ++ MacPass/MPActionHelper.h | 1 + MacPass/MPActionHelper.m | 3 +- MacPass/MPContextMenuHelper.h | 16 +- MacPass/MPContextMenuHelper.m | 41 +- MacPass/MPDocument.h | 4 +- MacPass/MPDocument.m | 75 ++-- MacPass/MPDocumentSettingsWindowController.h | 6 +- MacPass/MPDocumentSettingsWindowController.m | 61 ++- MacPass/MPDocumentWindowController.m | 1 + MacPass/MPRootAdapter.h | 2 + MacPass/MPRootAdapter.m | 3 + MacPass/MPToolbarDelegate.m | 2 +- MacPass/MacPass-Info.plist | 2 +- MacPass/de.lproj/Localizable.strings | Bin 6224 -> 6542 bytes MacPass/en.lproj/Localizable.strings | Bin 6028 -> 6202 bytes 21 files changed, 477 insertions(+), 220 deletions(-) create mode 100644 MacPass/KdbEntry+MPAdditions.h create mode 100644 MacPass/KdbEntry+MPAdditions.m create mode 100644 MacPass/KdbGroup+MPAdditions.h create mode 100644 MacPass/KdbGroup+MPAdditions.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 28c1b546..9b1d0e2b 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -162,6 +162,8 @@ 4CC299FF176F99E50050C939 /* MPRequestHandlerService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC299FE176F99E50050C939 /* MPRequestHandlerService.m */; }; 4CC29A02176F9D140050C939 /* MPTestAssociateRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC29A01176F9D140050C939 /* MPTestAssociateRequestHandler.m */; }; 4CC3AABD175F4983003EF01B /* HNHRoundedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */; }; + 4CC672791781D0C0006DEDCF /* KdbGroup+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC672781781D0C0006DEDCF /* KdbGroup+MPAdditions.m */; }; + 4CC6727C1781D0D2006DEDCF /* KdbEntry+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6727B1781D0D2006DEDCF /* KdbEntry+MPAdditions.m */; }; 4CC7EA1B17807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7EA1A17807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.m */; }; 4CD5D702177A5EE400100649 /* DocumentSettingsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD5D701177A5EE400100649 /* DocumentSettingsWindow.xib */; }; 4CD5D705177A5F3300100649 /* MPDocumentSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD5D704177A5F3300100649 /* MPDocumentSettingsWindowController.m */; }; @@ -500,6 +502,10 @@ 4CC29A01176F9D140050C939 /* MPTestAssociateRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestAssociateRequestHandler.m; sourceTree = ""; }; 4CC3AAB8175F4983003EF01B /* HNHRoundedTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextFieldCell.h; sourceTree = ""; }; 4CC3AAB9175F4983003EF01B /* HNHRoundedTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextFieldCell.m; sourceTree = ""; }; + 4CC672771781D0C0006DEDCF /* KdbGroup+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbGroup+MPAdditions.h"; sourceTree = ""; }; + 4CC672781781D0C0006DEDCF /* KdbGroup+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbGroup+MPAdditions.m"; sourceTree = ""; }; + 4CC6727A1781D0D2006DEDCF /* KdbEntry+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbEntry+MPAdditions.h"; sourceTree = ""; }; + 4CC6727B1781D0D2006DEDCF /* KdbEntry+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbEntry+MPAdditions.m"; sourceTree = ""; }; 4CC7EA1917807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundendTextFieldCellHelper.h; sourceTree = ""; }; 4CC7EA1A17807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundendTextFieldCellHelper.m; sourceTree = ""; }; 4CD5D701177A5EE400100649 /* DocumentSettingsWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DocumentSettingsWindow.xib; sourceTree = ""; }; @@ -755,6 +761,10 @@ 4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPTreeTools.m */, 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */, 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */, + 4CC672771781D0C0006DEDCF /* KdbGroup+MPAdditions.h */, + 4CC672781781D0C0006DEDCF /* KdbGroup+MPAdditions.m */, + 4CC6727A1781D0D2006DEDCF /* KdbEntry+MPAdditions.h */, + 4CC6727B1781D0D2006DEDCF /* KdbEntry+MPAdditions.m */, 4C01C23D1764D2980016D5D0 /* KdbEntry+Undo.h */, 4C01C23E1764D2980016D5D0 /* KdbEntry+Undo.m */, 4C22040B1746ED160054C916 /* KdbGroup+Undo.h */, @@ -1480,6 +1490,8 @@ 4C0D9B37177F84D700D0857C /* HNHSecureTextView.m in Sources */, 4C0D9B3A177F867100D0857C /* HNHSecureLayoutManager.m in Sources */, 4CC7EA1B17807E7E0089D4F3 /* HNHRoundendTextFieldCellHelper.m in Sources */, + 4CC672791781D0C0006DEDCF /* KdbGroup+MPAdditions.m in Sources */, + 4CC6727C1781D0D2006DEDCF /* KdbEntry+MPAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/DocumentSettingsWindow.xib b/MacPass/DocumentSettingsWindow.xib index f0d73cee..1cadf9ef 100644 --- a/MacPass/DocumentSettingsWindow.xib +++ b/MacPass/DocumentSettingsWindow.xib @@ -69,6 +69,7 @@ {{378, 13}, {75, 32}} + _NS:9 YES @@ -97,6 +98,7 @@ {{13, 41}, {441, 246}} + _NS:9 @@ -147,6 +149,7 @@ 268 {{50, 121}, {81, 17}} + _NS:1535 YES @@ -299,6 +302,7 @@ 256 {{193, 1}, {16, 121}} + _NS:83 NO @@ -343,7 +347,7 @@ - + 256 @@ -351,7 +355,6 @@ 268 {{69, 130}, {68, 17}} - _NS:1535 YES @@ -372,7 +375,6 @@ 268 {{142, 128}, {164, 22}} - _NS:9 YES @@ -398,7 +400,6 @@ {{139, 67}, {170, 22}} - _NS:9 YES @@ -427,7 +428,6 @@ 268 {{86, 71}, {51, 17}} - _NS:1535 YES @@ -448,7 +448,6 @@ 268 {{142, 44}, {164, 19}} - _NS:9 YES @@ -477,7 +476,6 @@ 268 {{142, 96}, {164, 22}} - _NS:9 YES @@ -499,7 +497,6 @@ 268 {{22, 98}, {115, 17}} - _NS:1535 YES @@ -517,8 +514,6 @@ {{10, 33}, {421, 200}} - - Protection @@ -644,7 +639,6 @@ 268 {{138, 38}, {107, 18}} - _NS:9 YES @@ -675,7 +669,7 @@ - + 256 @@ -683,6 +677,7 @@ 268 {{15, 154}, {149, 18}} + _NS:9 YES @@ -709,6 +704,7 @@ 268 {{15, 55}, {138, 18}} + _NS:9 YES @@ -735,6 +731,7 @@ 268 {{43, 35}, {187, 18}} + _NS:9 YES @@ -761,6 +758,7 @@ 268 {{42, 131}, {94, 17}} + _NS:1535 YES @@ -781,6 +779,7 @@ 268 {{42, 106}, {142, 17}} + _NS:1535 YES @@ -801,6 +800,7 @@ 268 {{187, 101}, {122, 26}} + _NS:9 YES @@ -876,6 +876,7 @@ 268 {{189, 129}, {96, 22}} + _NS:9 YES @@ -897,6 +898,7 @@ 268 {{290, 126}, {19, 27}} + _NS:1099 YES @@ -914,10 +916,12 @@ 268 - {{187, 54}, {122, 26}} + {{187, 54}, {220, 26}} + _NS:9 + {750, 750} YES -2076180416 @@ -931,28 +935,27 @@ 400 75 - - - Item 1 - - 1048576 - 2147483647 - 1 - - - _popUpItemAction: - - + YES OtherViews - + + + A Folder + + 1048576 + 2147483647 + 1 + + + _popUpItemAction: + + Item 2 - 1048576 2147483647 @@ -973,6 +976,7 @@ + -1 1 YES YES @@ -982,6 +986,8 @@ {{10, 33}, {421, 200}} + + Advanced @@ -989,13 +995,13 @@ - + 0 YES YES - + @@ -1004,7 +1010,7 @@ - {{0, 0}, {1920, 1058}} + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} YES @@ -1091,14 +1097,6 @@ 677 - - - useRecycleBinCheckButton - - - - 688 - emptyRecycleBinOnQuitCheckButton @@ -1131,6 +1129,14 @@ 707 + + + enableRecycleBinCheckButton + + + + 815 + @@ -1246,8 +1252,8 @@ 1000 - 8 - 29 + 9 + 40 3 @@ -1262,12 +1268,12 @@ 1000 - 8 - 29 + 9 + 40 3 - + @@ -1524,6 +1530,22 @@ 24 2 + + + 6 + 0 + + 6 + 1 + + 17 + + 1000 + + 9 + 40 + 3 + 5 @@ -1536,8 +1558,8 @@ 1000 - 6 - 24 + 9 + 40 2 @@ -1557,22 +1579,6 @@ 2 - - 6 - 0 - - 6 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - 6 0 @@ -1616,8 +1622,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -1684,6 +1690,22 @@ 24 3 + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + 5 @@ -1716,22 +1738,6 @@ 24 3 - - - 5 - 0 - - 5 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - 5 @@ -1744,8 +1750,8 @@ 1000 - 6 - 24 + 9 + 40 2 @@ -1776,8 +1782,8 @@ 1000 - 6 - 24 + 9 + 40 2 @@ -1792,8 +1798,8 @@ 1000 - 8 - 29 + 9 + 40 3 @@ -1813,13 +1819,13 @@ 3 - + @@ -2058,16 +2064,6 @@ - - 365 - - - - - 374 - - - 425 @@ -2242,16 +2238,6 @@ - - 390 - - - - - 552 - - - 557 @@ -2280,6 +2266,22 @@ + + + 7 + 0 + + 0 + 1 + + 136 + + 1000 + + 9 + 40 + 1 + @@ -2293,11 +2295,6 @@ - - 567 - - - 568 @@ -2421,11 +2418,6 @@ - - 603 - - - 527 @@ -2784,6 +2776,22 @@ + + + 7 + 0 + + 0 + 1 + + 215 + + 1000 + + 9 + 40 + 1 + @@ -2820,31 +2828,11 @@ - - 685 - - - 686 - - 687 - - - - - 708 - - - - - 556 - - - 710 @@ -3063,6 +3051,66 @@ + + 685 + + + + + 374 + + + + + 708 + + + + + 365 + + + + + 390 + + + + + 842 + + + + + 843 + + + + + 844 + + + + + 845 + + + + + 848 + + + + + 849 + + + + + 850 + + + @@ -3122,19 +3170,19 @@ - + - + @@ -3196,18 +3244,18 @@ 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 @@ -3232,7 +3280,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3262,7 +3309,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedSecureTextFieldCell + HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3271,7 +3318,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedSecureTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3284,6 +3330,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3293,7 +3342,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3303,7 +3351,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - HNHRoundedSecureTextFieldCell + HNHRoundedTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3323,41 +3371,38 @@ 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 - 814 + 850 - HNHRoundedSecureTextFieldCell - NSSecureTextFieldCell + HNHRoundedTextFieldCell + NSTextFieldCell IBProjectSource - ./Classes/HNHRoundedSecureTextFieldCell.h + ./Classes/HNHRoundedTextFieldCell.h MPDocumentSettingsWindowController NSWindowController - - close: - id - - - close: - - close: - id - - NSTextView NSTextField NSButton + NSButton NSPathControl NSTextField NSButton @@ -3367,7 +3412,6 @@ NSButton NSTabView NSPopUpButton - NSButton @@ -3382,6 +3426,10 @@ emptyRecycleBinOnQuitCheckButton NSButton + + enableRecycleBinCheckButton + NSButton + keyfilePathControl NSPathControl @@ -3418,10 +3466,6 @@ selectRecycleBinGroupPopUpButton NSPopUpButton - - useRecycleBinCheckButton - NSButton - IBProjectSource diff --git a/MacPass/KdbEntry+MPAdditions.h b/MacPass/KdbEntry+MPAdditions.h new file mode 100644 index 00000000..a30c5508 --- /dev/null +++ b/MacPass/KdbEntry+MPAdditions.h @@ -0,0 +1,15 @@ +// +// KdbEntry+MPAdditions.h +// MacPass +// +// Created by Michael Starke on 01.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "Kdb.h" + +@interface KdbEntry (MPAdditions) + +@property (nonatomic, readonly) NSImage *icon; + +@end diff --git a/MacPass/KdbEntry+MPAdditions.m b/MacPass/KdbEntry+MPAdditions.m new file mode 100644 index 00000000..e4bc52a0 --- /dev/null +++ b/MacPass/KdbEntry+MPAdditions.m @@ -0,0 +1,19 @@ +// +// KdbEntry+MPAdditions.m +// MacPass +// +// Created by Michael Starke on 01.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "KdbEntry+MPAdditions.h" + +#import "MPIconHelper.h" + +@implementation KdbEntry (MPAdditions) + +- (NSImage *)icon { + return [MPIconHelper icon:(MPIconType)self.image]; +} + +@end diff --git a/MacPass/KdbGroup+MPAdditions.h b/MacPass/KdbGroup+MPAdditions.h new file mode 100644 index 00000000..739d1e68 --- /dev/null +++ b/MacPass/KdbGroup+MPAdditions.h @@ -0,0 +1,22 @@ +// +// KdbGroup+MPAdditions.h +// MacPass +// +// Created by Michael Starke on 01.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "Kdb.h" + +@interface KdbGroup (MPAdditions) + +/* Adapter to load images based on icon index */ +@property (nonatomic, readonly) NSImage *icon; + +/* Walks the tree up to the root element */ +- (KdbGroup *)root; + +/* Removes all Groups and Entries from this group*/ +- (void)clear; + +@end diff --git a/MacPass/KdbGroup+MPAdditions.m b/MacPass/KdbGroup+MPAdditions.m new file mode 100644 index 00000000..655d8363 --- /dev/null +++ b/MacPass/KdbGroup+MPAdditions.m @@ -0,0 +1,36 @@ +// +// KdbGroup+MPAdditions.m +// MacPass +// +// Created by Michael Starke on 01.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "KdbGroup+MPAdditions.h" +#import "KdbGroup+KVOAdditions.h" +#import "MPIconHelper.h" + +@implementation KdbGroup (MPAdditions) + +- (NSImage *)icon { + return [MPIconHelper icon:(MPIconType)self.image]; +} + +- (KdbGroup *)root { + if(self.parent) { + return [self.parent root]; + } + return self; +} + +- (void)clear { + NSUInteger groupCount = [_groups count]; + for(NSInteger index = (groupCount - 1); index > -1; index--) { + [self removeObjectFromGroupsAtIndex:index]; + } + NSUInteger entryCount = [_entries count]; + for(NSInteger index = (entryCount - 1); index > -1; index--) { + [self removeObjectFromEntriesAtIndex:index]; + } +} +@end diff --git a/MacPass/MPActionHelper.h b/MacPass/MPActionHelper.h index 113c07c0..0aec7b4d 100644 --- a/MacPass/MPActionHelper.h +++ b/MacPass/MPActionHelper.h @@ -19,6 +19,7 @@ typedef NS_ENUM(NSUInteger, MPActionType) { MPActionOpenURL, // open url in default browser MPActionToggleInspector, MPActionLock, // show the lock screen + MPActionEmptyTrash // empties the trashcan, if there is one }; @interface MPActionHelper : NSObject diff --git a/MacPass/MPActionHelper.m b/MacPass/MPActionHelper.m index 24c55453..c3ec5f6f 100644 --- a/MacPass/MPActionHelper.m +++ b/MacPass/MPActionHelper.m @@ -24,7 +24,8 @@ @(MPActionEdit) : @"editEntry:", @(MPActionOpenURL) : @"openURL:", @(MPActionToggleInspector) : @"toggleInspector:", - @(MPActionLock) : @"lock:" + @(MPActionLock) : @"lock:", + @(MPActionEmptyTrash) : @"emptyTrash:" } retain]; }); return NSSelectorFromString(actionDict[@(type)]); diff --git a/MacPass/MPContextMenuHelper.h b/MacPass/MPContextMenuHelper.h index 7a5b1ea2..96e6ad80 100644 --- a/MacPass/MPContextMenuHelper.h +++ b/MacPass/MPContextMenuHelper.h @@ -8,13 +8,15 @@ #import -typedef enum { - MPContextMenuCreate = 1<<0, - MPContextMenuDelete = 1<<1, - MPContextMenuCopy = 1<<2, - MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, - MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy, -} MPContextMenuItemsFlags; +typedef NS_OPTIONS(NSUInteger, MPContextMenuItemsFlags) { + MPContextMenuCreate = 1 << 0, + MPContextMenuDelete = 1 << 1, + MPContextMenuCopy = 1 << 2, + MPContextMenuTrash = 1 << 3, + MPContextMenuMinimal = MPContextMenuCreate | MPContextMenuDelete, + MPContextMenuFull = MPContextMenuMinimal | MPContextMenuCopy, + MPContextMenuExtended = MPContextMenuFull | MPContextMenuTrash +}; @interface MPContextMenuHelper : NSTableCellView diff --git a/MacPass/MPContextMenuHelper.m b/MacPass/MPContextMenuHelper.m index 741a0754..0fdcc146 100644 --- a/MacPass/MPContextMenuHelper.m +++ b/MacPass/MPContextMenuHelper.m @@ -15,8 +15,9 @@ BOOL insertCreate = (0 != (flags & MPContextMenuCreate)); BOOL insertDelete = (0 != (flags & MPContextMenuDelete)); BOOL insertCopy = (0 != (flags & MPContextMenuCopy)); + BOOL insertTrash = (0 != (flags & MPContextMenuTrash)); - NSMutableArray *items = [NSMutableArray arrayWithCapacity:7]; + NSMutableArray *items = [NSMutableArray arrayWithCapacity:10]; if(insertCreate) { NSMenuItem *newGroup = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"ADD_GROUP", @"") @@ -30,20 +31,30 @@ [newEntry release]; [newGroup release]; } - if(insertDelete) { - if([items count] > 0) { - [items addObject:[NSMenuItem separatorItem]]; + if(insertDelete || insertTrash) { + [self _beginSection:items]; + if(insertDelete) { + NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") + action:[MPActionHelper actionOfType:MPActionDelete] + keyEquivalent:@""]; + [items addObject:delete]; + [delete release]; + + } + if(insertTrash) { + NSMenuItem *emptyTrash = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"EMPTY_TRASH", @"") + action:[MPActionHelper actionOfType:MPActionEmptyTrash] + keyEquivalent:@""]; + [emptyTrash setKeyEquivalentModifierMask:(NSShiftKeyMask | NSCommandKeyMask)]; + unichar backSpace = NSBackspaceCharacter; + [emptyTrash setKeyEquivalent:[NSString stringWithCharacters:&backSpace length:1]]; + [items addObject:emptyTrash]; + [emptyTrash release]; + } - NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") - action:[MPActionHelper actionOfType:MPActionDelete] - keyEquivalent:@""]; - [items addObject:delete]; - [delete release]; } if(insertCopy) { - if([items count] > 0) { - [items addObject:[NSMenuItem separatorItem]]; - } + [self _beginSection:items]; NSMenuItem *copyUsername = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"COPY_USERNAME", @"") action:[MPActionHelper actionOfType:MPActionCopyUsername] keyEquivalent:@"C"]; @@ -74,8 +85,14 @@ [copyPassword release]; [copyUsername release]; } + return items; } ++ (void)_beginSection:(NSMutableArray *)items { + if([items count] > 0) { + [items addObject:[NSMenuItem separatorItem]]; + } +} @end diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 9a549a1c..5d2f5654 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -44,6 +44,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; @property (readonly, retain) MPRootAdapter *rootAdapter; @property (nonatomic, retain) NSString *password; @property (nonatomic, retain) NSURL *key; + @property (assign, readonly) MPDatabaseVersion version; @property (assign, readonly, getter = isReadOnly) BOOL readOnly; @@ -69,7 +70,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; - (KdbGroup *)createGroup:(KdbGroup *)parent; - (KdbEntry *)createEntry:(KdbGroup *)parent; - (StringField *)createStringField:(KdbEntry *)entry; - /* All non-setter undoable actions */ @@ -86,4 +86,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; - (void)entry:(Kdb4Entry *)entry addStringField:(StringField *)field atIndex:(NSUInteger)index; - (void)entry:(Kdb4Entry *)entry removeStringField:(StringField *)field; +- (void)emptyTrash:(id)sender; + @end diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 5009ed60..dc93cd75 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -12,6 +12,7 @@ #import "MPDatabaseVersion.h" #import "MPRootAdapter.h" #import "MPIconHelper.h" +#import "MPActionHelper.h" #import "KdbLib.h" #import "Kdb3Node.h" @@ -21,6 +22,7 @@ #import "KdbGroup+KVOAdditions.h" #import "Kdb4Entry+KVOAdditions.h" #import "KdbGroup+MPTreeTools.h" +#import "KdbGroup+MPAdditions.h" #import "KdbEntry+Undo.h" #import "Kdb3Tree+NewTree.h" #import "Kdb4Tree+NewTree.h" @@ -51,8 +53,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; @property (assign) BOOL readOnly; @property (retain) NSURL *lockFileURL; -@property (readonly, assign, nonatomic) KdbGroup *recyleBin; -@property (readonly) BOOL useRecylceBin; + +@property (readonly) BOOL useTrash; +@property (readonly) KdbGroup *trash; @end @@ -258,20 +261,21 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } } -- (BOOL)useRecylceBin { +- (BOOL)useTrash { if(self.treeV4) { return self.treeV4.recycleBinEnabled; } return NO; } -- (KdbGroup *)recyleBin { - static KdbGroup *_recycleBin; - if(self.useRecylceBin) { - if(!_recycleBin) { - _recycleBin = [self findGroup:self.treeV4.recycleBinUuid]; +- (KdbGroup *)trash { + static KdbGroup *_trash = nil; + if(self.useTrash) { + BOOL trashValid = [((Kdb4Group *)_trash).uuid isEqual:self.treeV4.recycleBinUuid]; + if(!trashValid) { + _trash = [self findGroup:self.treeV4.recycleBinUuid]; } - return _recycleBin; + return _trash; } return nil; } @@ -322,7 +326,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return; // No changes } [[[self undoManager] prepareWithInvocationTarget:self] moveGroup:group toGroup:group.parent index:oldIndex]; - if(self.recyleBin == target) { + if(self.trash == target) { [[self undoManager] setActionName:@"UNDO_DELETE_GROUP"]; } else { @@ -358,7 +362,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; return; // No changes } [[[self undoManager] prepareWithInvocationTarget:self] moveEntry:entry toGroup:entry.parent index:oldIndex]; - if(self.recyleBin == target || self.recyleBin == entry.parent) { + if(self.trash == target || self.trash == entry.parent) { [[self undoManager] setActionName:@"UNDO_DELETE_ENTRY"]; } else { @@ -388,11 +392,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; if(NSNotFound == index) { return; // No object found; } - if(self.useRecylceBin) { - if(!self.recyleBin) { - [self _createRecylceBin]; + if(self.useTrash) { + if(!self.trash) { + [self _createTrashGroup]; } - [self moveEntry:entry toGroup:self.recyleBin index:[self.recyleBin.entries count]]; + [self moveEntry:entry toGroup:self.trash index:[self.trash.entries count]]; return; } [[[self undoManager] prepareWithInvocationTarget:self] group:group addEntry:entry atIndex:index]; @@ -405,15 +409,19 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; if(NSNotFound == index) { return; // No object found } + if(self.trash == aGroup) { + return; + // delete Trash? + } /* Cleaning the recyclebin is not undoable So we do this in a separate action */ - if(self.useRecylceBin) { - if(!self.recyleBin) { - [self _createRecylceBin]; + if(self.useTrash) { + if(!self.trash) { + [self _createTrashGroup]; } - [self moveGroup:aGroup toGroup:self.recyleBin index:[self.recyleBin.groups count]]; + [self moveGroup:aGroup toGroup:self.trash index:[self.trash.groups count]]; return; // Done! } [[[self undoManager] prepareWithInvocationTarget:self] group:group addGroup:aGroup atIndex:index]; @@ -437,6 +445,20 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; [entry removeObjectFromStringFieldsAtIndex:index]; } +#pragma mark Actions + +- (void)emptyTrash:(id)sender { + [self.trash clear]; +} + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { + if([menuItem action] == [MPActionHelper actionOfType:MPActionEmptyTrash]) { + BOOL hasGroups = [self.trash.groups count] > 0; + BOOL hasEntries = [self.trash.entries count] > 0; + return (hasEntries || hasGroups); + } + return YES; +} #pragma mark Private - (void)_cleanupLock { @@ -446,19 +468,22 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey"; } } -- (void)_createRecylceBin { +- (KdbGroup *)_createTrashGroup { /* Maybe push the stuff to the Tree? */ if(self.version == MPDatabaseVersion3) { + return nil; } else if(self.version == MPDatabaseVersion4) { - KdbGroup *recycleBin = [self.tree createGroup:self.tree.root]; - recycleBin.name = NSLocalizedString(@"RECYLEBIN", @"Name for the recycle bin group"); - recycleBin.image = MPIconTrash; - [self.tree.root insertObject:recycleBin inGroupsAtIndex:[self.tree.root.groups count]]; - self.treeV4.recycleBinUuid = ((Kdb4Group *)recycleBin).uuid; + KdbGroup *trash = [self.tree createGroup:self.tree.root]; + trash.name = NSLocalizedString(@"RECYLEBIN", @"Name for the recycle bin group"); + trash.image = MPIconTrash; + [self.tree.root insertObject:trash inGroupsAtIndex:[self.tree.root.groups count]]; + self.treeV4.recycleBinUuid = ((Kdb4Group *)trash).uuid; + return trash; } else { NSAssert(NO, @"Database with unknown version: %ld", _version); + return nil; } } diff --git a/MacPass/MPDocumentSettingsWindowController.h b/MacPass/MPDocumentSettingsWindowController.h index fe44a50a..a9aba5d9 100644 --- a/MacPass/MPDocumentSettingsWindowController.h +++ b/MacPass/MPDocumentSettingsWindowController.h @@ -18,6 +18,7 @@ /* General Tab */ @property (assign) IBOutlet NSTextField *databaseNameTextField; @property (assign) IBOutlet NSTextView *databaseDescriptionTextView; + /* Protection */ @property (assign) IBOutlet NSTextField *passwordTextField; @property (assign) IBOutlet NSPathControl *keyfilePathControl; @@ -31,12 +32,11 @@ /* Advanced Tab*/ -@property (assign) IBOutlet NSButton *useRecycleBinCheckButton; +@property (assign) IBOutlet NSButton *enableRecycleBinCheckButton; @property (assign) IBOutlet NSButton *emptyRecycleBinOnQuitCheckButton; @property (assign) IBOutlet NSPopUpButton *selectRecycleBinGroupPopUpButton; - - - (id)initWithDocument:(MPDocument *)document; +- (void)update; @end diff --git a/MacPass/MPDocumentSettingsWindowController.m b/MacPass/MPDocumentSettingsWindowController.m index 11c4bb93..4dd551a7 100644 --- a/MacPass/MPDocumentSettingsWindowController.m +++ b/MacPass/MPDocumentSettingsWindowController.m @@ -10,7 +10,11 @@ #import "MPDocument.h" #import "MPDocumentWindowController.h" #import "MPDatabaseVersion.h" +#import "MPIconHelper.h" + +#import "Kdb.h" #import "Kdb4Node.h" +#import "KdbGroup+MPAdditions.h" @interface MPDocumentSettingsWindowController () { MPDocument *_document; @@ -34,12 +38,14 @@ - (void)windowDidLoad { [super windowDidLoad]; + NSAssert(_document != nil, @"Document needs to be present"); + Kdb4Tree *tree = _document.treeV4; if( tree ) { [self _setupDatabase:tree]; [self _setupProtectionTab:tree]; - [self _setupHistoryTab:tree]; + [self _setupAdvancedTab:tree]; [self _setupPasswordTab:tree]; } else { @@ -52,6 +58,15 @@ [[self window] orderOut:nil]; } +- (void)update { + /* Update all stuff that might have changed */ + Kdb4Tree *tree = _document.treeV4; + if(tree) { + [self _updateTrashFolders:tree]; + } +} + +#pragma mark Private Helper - (void)_setupDatabase:(Kdb4Tree *)tree { [self.databaseNameTextField bind:NSValueBinding toObject:tree withKeyPath:@"databaseName" options:nil]; [self.databaseDescriptionTextView bind:NSValueBinding toObject:tree withKeyPath:@"databaseDescription" options:nil]; @@ -65,12 +80,52 @@ [self.protectUserNameCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"protectUserName" options:nil]; } -- (void)_setupHistoryTab:(Kdb4Tree *)tree { - +- (void)_setupAdvancedTab:(Kdb4Tree *)tree { + [self.enableRecycleBinCheckButton bind:NSValueBinding toObject:tree withKeyPath:@"recycleBinEnabled" options:nil]; + [self.selectRecycleBinGroupPopUpButton bind:NSEnabledBinding toObject:tree withKeyPath:@"recycleBinEnabled" options:nil]; + [self _updateTrashFolders:tree]; } - (void)_setupPasswordTab:(Kdb4Tree *)tree { } + +- (void)_didSelectTrashFolder:(id)sender { + NSMenuItem *menuItem = sender; + if([menuItem representedObject]) { + + } +} + +- (void)_updateTrashFolders:(Kdb4Tree *)tree { + NSMenu *menu = [self _buildTreeMenu:tree]; + [self.selectRecycleBinGroupPopUpButton setMenu:menu]; +} + +- (NSMenu *)_buildTreeMenu:(Kdb4Tree *)tree { + NSMenu *menu = [[NSMenu alloc] init]; + BOOL foundTrash = NO; + for(Kdb4Group *group in tree.root.groups) { + NSMenuItem *groupItem = [[NSMenuItem alloc] init]; + [groupItem setImage:group.icon]; + [groupItem setTitle:group.name]; + [groupItem setAction:@selector(_didSelectTrashFolder:)]; + [groupItem setTarget:self]; + [groupItem setRepresentedObject:group]; + if([group.uuid isEqual:tree.recycleBinUuid]) { + foundTrash = YES; + [groupItem setState:NSOnState]; + } + [menu addItem:groupItem]; + [groupItem release]; + } + if(!foundTrash) { + NSMenuItem *selectItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SELECT_RECYCLEBIN", @"Menu item if no reycleBin is selected") action:NULL keyEquivalent:@""]; + [selectItem setEnabled:NO]; + [menu insertItem:selectItem atIndex:0]; + [selectItem release]; + } + return [menu autorelease]; +} @end diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 7bfe739d..8f8ad56f 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -224,6 +224,7 @@ NSString *const MPCurrentItemChangedNotification = @"com.hicknhack.macpass.MPCur if(!self.documentSettingsWindowController) { _documentSettingsWindowController = [[MPDocumentSettingsWindowController alloc] initWithDocument:[self document]]; } + [_documentSettingsWindowController update]; [[NSApplication sharedApplication] beginSheet:[_documentSettingsWindowController window] modalForWindow:[self window] modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; } diff --git a/MacPass/MPRootAdapter.h b/MacPass/MPRootAdapter.h index 54843f0f..29514065 100644 --- a/MacPass/MPRootAdapter.h +++ b/MacPass/MPRootAdapter.h @@ -14,5 +14,7 @@ @property (readonly, retain) NSArray *groups; @property (nonatomic, retain) KdbTree *tree; +/* Subs to support interface */ +@property (readonly, nonatomic) NSArray *entries; @end diff --git a/MacPass/MPRootAdapter.m b/MacPass/MPRootAdapter.m index 5bb66214..908cabde 100644 --- a/MacPass/MPRootAdapter.m +++ b/MacPass/MPRootAdapter.m @@ -30,4 +30,7 @@ } } +- (NSArray *)entries { + return nil; +} @end diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index ac45c5e5..f39bb0cc 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -76,7 +76,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR"; [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; [menu addItem:actionImageItem]; [actionImageItem release]; - NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuFull]; + NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended]; for(NSMenuItem *item in menuItems) { [menu addItem:item]; } diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 4e796cb3..fa1fecfa 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 1706 + 1782 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/de.lproj/Localizable.strings b/MacPass/de.lproj/Localizable.strings index 56a65ed3b940ce15a5da0121a9109a80a2d23d8f..44f379273f52ba187015cff5637c5b467fb96f8a 100644 GIT binary patch delta 196 zcmca$&}Y2i1Yf-`Ln=caLn(s-LncEBkev%=r2)x2hI}Ad1Qe@eNM^_Z(oR4%d0_cs zAXy9)0f{Dq^`!tsv>5amxEPcef*D*He1O=QA%r2GAqdQh1oA*)P7Iz5en2$}47Nb5 zG+CFASGa^B8)#P%LlRJ=oZ$&W21Cx|haAF_1Ni*dgBZeqx`HN~bINiD18pl}Ch;Q=)z9>!rAqxbW