mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Renaming, moving functionality to KeePassKit where suitable
This commit is contained in:
Submodule KeePassKit updated: 00cad2b169...ea2208e6f2
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPDatabaseSettingsWindowController">
|
||||
@@ -13,8 +12,8 @@
|
||||
<outlet property="databaseDescriptionTextView" destination="1531" id="1553"/>
|
||||
<outlet property="databaseNameTextField" destination="231" id="655"/>
|
||||
<outlet property="defaultUsernameTextField" destination="1730" id="1819"/>
|
||||
<outlet property="emptyRecycleBinOnQuitCheckButton" destination="539" id="689"/>
|
||||
<outlet property="enableRecycleBinCheckButton" destination="535" id="815"/>
|
||||
<outlet property="emptyTrashOnQuitCheckButton" destination="539" id="pgQ-AP-HB2"/>
|
||||
<outlet property="enableTrashCheckButton" destination="535" id="UNd-h9-aw3"/>
|
||||
<outlet property="encryptionRoundsTextField" destination="1647" id="1773"/>
|
||||
<outlet property="enforceKeyChangeCheckButton" destination="upv-b3-vCc" id="JjM-CX-15q"/>
|
||||
<outlet property="enforceKeyChangeIntervalTextField" destination="VYh-cm-fix" id="aqu-Dm-tlH"/>
|
||||
@@ -26,7 +25,7 @@
|
||||
<outlet property="recommendKeyChangeCheckButton" destination="Hqc-B0-xyz" id="3CK-D7-b8S"/>
|
||||
<outlet property="recommendKeyChangeIntervalTextField" destination="19r-LE-7X5" id="c5C-1h-LpD"/>
|
||||
<outlet property="sectionTabView" destination="357" id="699"/>
|
||||
<outlet property="selectRecycleBinGroupPopUpButton" destination="678" id="690"/>
|
||||
<outlet property="selectTrashGoupPopUpButton" destination="678" id="MmE-QI-reD"/>
|
||||
<outlet property="templateGroupPopUpButton" destination="1738" id="1796"/>
|
||||
<outlet property="window" destination="1" id="265"/>
|
||||
</connections>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import "MPContextBarViewController.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKTree.h"
|
||||
#import "KPKMetaData.h"
|
||||
|
||||
#import "MPDocument+HistoryBrowsing.h"
|
||||
#import "MPDocument+Search.h"
|
||||
@@ -117,7 +119,8 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
|
||||
- (void)_didChangeCurrentItem:(NSNotification *)notification {
|
||||
MPDocument *document = [notification object];
|
||||
BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]);
|
||||
|
||||
BOOL showTrash = document.tree.metaData.useTrash && (document.selectedItem.isTrashed || document.selectedItem.isTrash);
|
||||
if(showTrash && ! document.hasSearch) {
|
||||
self.activeTab = MPContextTabTrash;
|
||||
[self _updateBindings];
|
||||
|
||||
@@ -38,9 +38,9 @@ typedef NS_ENUM(NSUInteger, MPDatabaseSettingsTab) {
|
||||
@property (weak) IBOutlet NSButton *benchmarkButton;
|
||||
|
||||
/* Advanced Tab*/
|
||||
@property (weak) IBOutlet NSButton *enableRecycleBinCheckButton;
|
||||
@property (weak) IBOutlet NSButton *emptyRecycleBinOnQuitCheckButton;
|
||||
@property (weak) IBOutlet NSPopUpButton *selectRecycleBinGroupPopUpButton;
|
||||
@property (weak) IBOutlet NSButton *enableTrashCheckButton;
|
||||
@property (weak) IBOutlet NSButton *emptyTrashOnQuitCheckButton;
|
||||
@property (weak) IBOutlet NSPopUpButton *selectTrashGoupPopUpButton;
|
||||
@property (weak) IBOutlet NSTextField *defaultUsernameTextField;
|
||||
@property (weak) IBOutlet NSPopUpButton *templateGroupPopUpButton;
|
||||
|
||||
|
||||
@@ -80,10 +80,10 @@
|
||||
}
|
||||
|
||||
/* Advanced */
|
||||
metaData.recycleBinEnabled = self.trashEnabled;
|
||||
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
|
||||
metaData.useTrash = self.trashEnabled;
|
||||
NSMenuItem *trashMenuItem = [self.selectTrashGoupPopUpButton selectedItem];
|
||||
KPKGroup *trashGroup = [trashMenuItem representedObject];
|
||||
((MPDocument *)self.document).trash = trashGroup;
|
||||
((MPDocument *)self.document).tree.trash = trashGroup;
|
||||
|
||||
NSMenuItem *templateMenuItem = [self.templateGroupPopUpButton selectedItem];
|
||||
KPKGroup *templateGroup = [templateMenuItem representedObject];
|
||||
@@ -202,9 +202,9 @@
|
||||
|
||||
- (void)_setupAdvancedTab:(KPKTree *)tree {
|
||||
/* TODO Do not use bindings, as the user should be able to cancel */
|
||||
[self bind:@"trashEnabled" toObject:tree.metaData withKeyPath:@"recycleBinEnabled" options:nil];
|
||||
[self.enableRecycleBinCheckButton bind:NSValueBinding toObject:self withKeyPath:@"trashEnabled" options:nil];
|
||||
[self.selectRecycleBinGroupPopUpButton bind:NSEnabledBinding toObject:self withKeyPath:@"trashEnabled" options:nil];
|
||||
[self bind:NSStringFromSelector(@selector(trashEnabled)) toObject:tree.metaData withKeyPath:NSStringFromSelector(@selector(trashEnabled)) options:nil];
|
||||
[self.enableTrashCheckButton bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(trashEnabled)) options:nil];
|
||||
[self.selectTrashGoupPopUpButton bind:NSEnabledBinding toObject:self withKeyPath:NSStringFromSelector(@selector(trashEnabled)) options:nil];
|
||||
[self _updateTrashFolders:tree];
|
||||
|
||||
[self.defaultUsernameTextField setStringValue:tree.metaData.defaultUserName];
|
||||
@@ -253,7 +253,7 @@
|
||||
|
||||
- (void)_updateTrashFolders:(KPKTree *)tree {
|
||||
NSMenu *menu = [self _buildTrashTreeMenu:tree];
|
||||
[self.selectRecycleBinGroupPopUpButton setMenu:menu];
|
||||
[self.selectTrashGoupPopUpButton setMenu:menu];
|
||||
}
|
||||
|
||||
- (void)_updateTemplateGroup:(KPKTree *)tree {
|
||||
@@ -262,7 +262,7 @@
|
||||
}
|
||||
|
||||
- (NSMenu *)_buildTrashTreeMenu:(KPKTree *)tree {
|
||||
NSMenu *menu = [self _buildTreeMenu:tree preselect:tree.metaData.recycleBinUuid];
|
||||
NSMenu *menu = [self _buildTreeMenu:tree preselect:tree.metaData.trashUuid];
|
||||
|
||||
NSMenuItem *selectItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"AUTOCREATE_TRASH_FOLDER", @"Menu item for automatic trash creation")
|
||||
action:NULL
|
||||
|
||||
@@ -67,8 +67,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
|
||||
@property (strong, readonly, nonatomic) KPKTree *tree;
|
||||
@property (nonatomic, weak, readonly) KPKGroup *root;
|
||||
@property (nonatomic, weak) KPKGroup *trash;
|
||||
@property (nonatomic, readonly) BOOL useTrash;
|
||||
@property (nonatomic, weak) KPKGroup *templates;
|
||||
|
||||
@property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey;
|
||||
@@ -147,15 +145,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
- (BOOL)shouldRecommendPasswordChange;
|
||||
- (BOOL)shouldEnforcePasswordChange;
|
||||
|
||||
/**
|
||||
* Determines, whether the given item is inside the trash.
|
||||
* The trash group itself is not considered as trashed.
|
||||
* Hence when sending this message with the trash group as item, NO is returned
|
||||
* @param item Item to test if trashed or not
|
||||
* @return YES, if the item is inside the trash, NO otherwise (and if item is trash group)
|
||||
*/
|
||||
- (BOOL)isItemTrashed:(id)item;
|
||||
|
||||
- (void)writeXMLToURL:(NSURL *)url;
|
||||
- (void)readXMLfromURL:(NSURL *)url;
|
||||
|
||||
|
||||
@@ -364,15 +364,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
}
|
||||
|
||||
- (KPKGroup *)trash {
|
||||
/* Caching is dangerous, as we might have deleted the trashcan */
|
||||
if(self.useTrash) {
|
||||
return [self findGroup:self.tree.metaData.recycleBinUuid];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)useTrash {
|
||||
return self.tree.metaData.recycleBinEnabled;
|
||||
return self.tree.trash;
|
||||
}
|
||||
|
||||
- (KPKGroup *)templates {
|
||||
@@ -384,14 +376,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
return self.searchContext != nil;
|
||||
}
|
||||
|
||||
- (void)setTrash:(KPKGroup *)trash {
|
||||
if(self.useTrash) {
|
||||
if(![self.tree.metaData.recycleBinUuid isEqual:trash.uuid]) {
|
||||
self.tree.metaData.recycleBinUuid = trash.uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTemplates:(KPKGroup *)templates {
|
||||
if(![self.tree.metaData.entryTemplatesGroup isEqual:templates.uuid]) {
|
||||
self.tree.metaData.entryTemplatesGroup = templates.uuid;
|
||||
@@ -447,26 +431,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
return self.tree.allGroups;
|
||||
}
|
||||
|
||||
- (BOOL)isItemTrashed:(id)item {
|
||||
BOOL validItem = [item isKindOfClass:[KPKEntry class]] || [item isKindOfClass:[KPKGroup class]];
|
||||
if(!item) {
|
||||
return NO;
|
||||
}
|
||||
if(item == self.trash) {
|
||||
return NO; // No need to look further as this is the trashcan
|
||||
}
|
||||
if(validItem) {
|
||||
BOOL isTrashed = NO;
|
||||
id parent = [item parent];
|
||||
while( parent && !isTrashed ) {
|
||||
isTrashed = (parent == self.trash);
|
||||
parent = [parent parent];
|
||||
}
|
||||
return isTrashed;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)shouldEnforcePasswordChange {
|
||||
KPKMetaData *metaData = self.tree.metaData;
|
||||
if(!metaData.enforceMasterKeyChange) { return NO; }
|
||||
@@ -484,12 +448,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(!parent) {
|
||||
return nil; // No parent
|
||||
}
|
||||
if(parent == self.trash) {
|
||||
if(parent.isTrash || parent.isTrashed) {
|
||||
return nil; // no new Groups in trash
|
||||
}
|
||||
if([self isItemTrashed:parent]) {
|
||||
return nil;
|
||||
}
|
||||
KPKEntry *newEntry = [self.tree createEntry:parent];
|
||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||
if([self.tree.metaData.defaultUserName length] > 0) {
|
||||
@@ -510,12 +471,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(!parent) {
|
||||
return nil; // no parent!
|
||||
}
|
||||
if(parent == self.trash) {
|
||||
if(parent.isTrash || parent.isTrashed) {
|
||||
return nil; // no new Groups in trash
|
||||
}
|
||||
if([self isItemTrashed:parent]) {
|
||||
return nil;
|
||||
}
|
||||
KPKGroup *newGroup = [self.tree createGroup:parent];
|
||||
newGroup.name = NSLocalizedString(@"DEFAULT_GROUP_NAME", @"Title for a newly created group");
|
||||
newGroup.iconId = MPIconFolder;
|
||||
@@ -547,8 +505,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(!entry) {
|
||||
return; // Nothing to do;
|
||||
}
|
||||
if(self.useTrash) {
|
||||
if([self isItemTrashed:entry]) {
|
||||
if(self.tree.metaData.useTrash) {
|
||||
if(entry.isTrashed) {
|
||||
[self _presentTrashAlertForItem:entry];
|
||||
return;
|
||||
}
|
||||
@@ -571,8 +529,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(!group) {
|
||||
return; // Nothing to do;
|
||||
}
|
||||
if(self.useTrash) {
|
||||
if([self isItemTrashed:group]) {
|
||||
if(self.tree.metaData.useTrash) {
|
||||
if(group.isTrashed) {
|
||||
[self _presentTrashAlertForItem:group];
|
||||
return;
|
||||
}
|
||||
@@ -580,7 +538,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
[self _createTrashGroup];
|
||||
}
|
||||
if(group == self.trash) {
|
||||
return; //Groups is trash!
|
||||
return; //Group is trash!
|
||||
}
|
||||
[group moveToGroup:self.trash atIndex:[self.trash.groups count]];
|
||||
[[self undoManager] setActionName:NSLocalizedString(@"TRASH_GROUP", "Move Group to Trash")];
|
||||
@@ -717,17 +675,18 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
switch([MPActionHelper typeForAction:[anItem action]]) {
|
||||
case MPActionAddGroup:
|
||||
valid &= (nil != targetGroup);
|
||||
valid &= (self.trash != targetGroup);
|
||||
valid &= ![self isItemTrashed:targetGroup];
|
||||
valid &= !targetGroup.isTrash;
|
||||
valid &= !targetGroup.isTrashed;
|
||||
break;
|
||||
case MPActionAddEntry:
|
||||
valid &= (nil != targetGroup);
|
||||
valid &= (self.trash != targetGroup);
|
||||
valid &= ![self isItemTrashed:targetGroup];
|
||||
valid &= !targetGroup.isTrash;
|
||||
valid &= !targetGroup.isTrashed;
|
||||
break;
|
||||
case MPActionDelete:
|
||||
valid &= (nil != targetNode);
|
||||
valid &= (self.trash != targetNode);
|
||||
valid &= (targetNode != self.tree.root);
|
||||
//valid &= ![self isItemTrashed:targetNode];
|
||||
break;
|
||||
case MPActionDuplicateEntry:
|
||||
@@ -798,7 +757,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(wasEnabled) {
|
||||
[self.undoManager enableUndoRegistration];
|
||||
}
|
||||
self.tree.metaData.recycleBinUuid = trash.uuid;
|
||||
self.tree.metaData.trashUuid = trash.uuid;
|
||||
return trash;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#import "KPKNode+IconImage.h"
|
||||
#import "KPKAttribute.h"
|
||||
#import "KPKTimeInfo.h"
|
||||
#import "KPKTree.h"
|
||||
#import "KPKMetaData.h"
|
||||
|
||||
#import "HNHTableHeaderCell.h"
|
||||
@@ -503,7 +504,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
- (void)_updateContextBar {
|
||||
MPDocument *document = [[self windowController] document];
|
||||
if(!document.hasSearch) {
|
||||
BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]);
|
||||
BOOL showTrash = document.tree.metaData.useTrash && (document.selectedGroup.isTrash || document.selectedItem.isTrashed);
|
||||
if(showTrash) {
|
||||
[self _showContextBar];
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ NSString *const _MPOutlineMenuTemplate = @"Template";
|
||||
if(group && document.root == group ) {
|
||||
|
||||
}
|
||||
if(group && document.trash == group) {
|
||||
if(group.isTrash) {
|
||||
[self _updateTrashMenu:menu];
|
||||
}
|
||||
else if( group && document.templates == group) {
|
||||
[self _updateTemplateMenu:menu];
|
||||
}
|
||||
else if([document isItemTrashed:group]) {
|
||||
else if(group.isTrashed) {
|
||||
[self _updateTrashItemMenu:menu];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
validTarget &= index != NSOutlineViewDropOnItemIndex;
|
||||
validTarget &= index != [self.localDraggedGroup.parent.groups indexOfObject:self.localDraggedGroup];
|
||||
}
|
||||
BOOL isAnchesor = [self.localDraggedGroup isAnchestorOfGroup:targetGroup];
|
||||
BOOL isAnchesor = [self.localDraggedGroup isAnchestorOf:targetGroup];
|
||||
validTarget &= !isAnchesor;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -279,14 +279,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
if(![document validateUserInterfaceItem:menuItem]) {
|
||||
return NO;
|
||||
}
|
||||
id selected = [[self currentTargetNode] asGroup];
|
||||
if(!selected) {
|
||||
return NO;
|
||||
}
|
||||
if(selected == document.trash) {
|
||||
return NO;
|
||||
}
|
||||
return ![document isItemTrashed:selected];
|
||||
KPKGroup *group = [[self currentTargetNode] asGroup];
|
||||
return group.isTrash && group.isTrashed;
|
||||
}
|
||||
|
||||
- (NSMenu *)_contextMenu {
|
||||
|
||||
Reference in New Issue
Block a user