mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 22:52:26 +00:00
restore history entries added
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -1,3 +1,3 @@
|
||||
github "sparkle-project/Sparkle" ~> 1.17.0
|
||||
github "mstarke/KeePassKit" "ab95d3a85b2bcb86d9e3e5e74d2168c209756b8b"
|
||||
github "mstarke/KeePassKit" "b25eab0892f6101ee4929bef3f57788dbc5fa607"
|
||||
github "mstarke/HNHUi" ~> 1.1
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
github "mstarke/HNHUi" "1.1"
|
||||
github "mstarke/KeePassKit" "ab95d3a85b2bcb86d9e3e5e74d2168c209756b8b"
|
||||
github "mstarke/KeePassKit" "b25eab0892f6101ee4929bef3f57788dbc5fa607"
|
||||
github "sparkle-project/Sparkle" "1.17.0"
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPEntryInspectorViewController">
|
||||
<connections>
|
||||
<outlet property="URLTextField" destination="56" id="262"/>
|
||||
<outlet property="addAttachmentButton" destination="177" id="w3F-U0-Rpk"/>
|
||||
<outlet property="addCustomFieldButton" destination="179" id="I3F-Sp-dbI"/>
|
||||
<outlet property="addWindowAssociationButton" destination="Iy9-9L-Aev" id="kDA-Mm-lah"/>
|
||||
<outlet property="associationSequenceTextField" destination="NjR-ea-Y7k" id="kTb-Y5-XrZ"/>
|
||||
<outlet property="attachmentTableView" destination="137" id="265"/>
|
||||
<outlet property="autotypView" destination="zv7-wE-Bmg" id="m1g-dk-hFv"/>
|
||||
@@ -21,6 +23,7 @@
|
||||
<outlet property="infoTabControl" destination="82" id="264"/>
|
||||
<outlet property="obfuscateAutotypeCheckButton" destination="I7L-Am-Qpa" id="hwa-zl-24W"/>
|
||||
<outlet property="passwordTextField" destination="60" id="263"/>
|
||||
<outlet property="pickExpireDateButton" destination="8" id="cJg-5V-AL6"/>
|
||||
<outlet property="showCustomAssociationSequenceAutotypeBuilderButton" destination="m1C-m8-BKR" id="B3I-AG-TCJ"/>
|
||||
<outlet property="showCustomEntrySequenceAutotypeBuilderButton" destination="HDS-Bz-jrr" id="7u1-17-oMK"/>
|
||||
<outlet property="tabView" destination="83" id="269"/>
|
||||
@@ -94,7 +97,7 @@
|
||||
<rect key="frame" x="20" y="26" width="253" height="396"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="F3N-QI-Di5">
|
||||
<rect key="frame" x="1" y="1" width="251" height="394"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="36" rowSizeStyle="automatic" viewBased="YES" id="137">
|
||||
<rect key="frame" x="0.0" y="0.0" width="251" height="394"/>
|
||||
@@ -271,7 +274,7 @@
|
||||
<rect key="frame" x="16" y="50" width="261" height="372"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="k8G-zp-BXZ">
|
||||
<rect key="frame" x="1" y="1" width="259" height="370"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="54" rowSizeStyle="automatic" viewBased="YES" id="193">
|
||||
<rect key="frame" x="0.0" y="0.0" width="259" height="370"/>
|
||||
|
||||
@@ -31,7 +31,8 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
|
||||
MPActionToggleQuicklook,
|
||||
MPActionShowEntryHistory, // show history
|
||||
MPActionHideEntryHistory, // exit history
|
||||
MPActionPerformAutotypeForSelectedEntry // Perform Autotype for selected Entry
|
||||
MPActionPerformAutotypeForSelectedEntry, // Perform Autotype for selected Entry
|
||||
MPActionRemoveAttachment // Remove an attachment
|
||||
};
|
||||
/**
|
||||
* Helper to retrieve commonly used actions
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
@(MPActionToggleQuicklook): NSStringFromSelector(@selector(toggleQuicklookPreview:)),
|
||||
@(MPActionShowEntryHistory): NSStringFromSelector(@selector(showEntryHistory:)),
|
||||
@(MPActionHideEntryHistory): NSStringFromSelector(@selector(hideEntryHistory:)),
|
||||
@(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:))
|
||||
@(MPActionPerformAutotypeForSelectedEntry): NSStringFromSelector(@selector(performAutotypeForEntry:)),
|
||||
@(MPActionRemoveAttachment): NSStringFromSelector(@selector(removeAttachment:))
|
||||
};
|
||||
});
|
||||
return actionDict;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
MPCustomFieldTableCellView *view = [tableView makeViewWithIdentifier:@"SelectedCell" owner:tableView];
|
||||
|
||||
|
||||
[view.labelTextField bind:NSValueBinding
|
||||
toObject:view
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(key))]
|
||||
@@ -39,6 +39,14 @@
|
||||
toObject:view
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(value))]
|
||||
options:nil];
|
||||
// TODO: Move to public KeePassKit API!
|
||||
for(NSControl *control in @[view.labelTextField, view.valueTextField, view.removeButton ]) {
|
||||
[control bind:NSEnabledBinding
|
||||
toObject:view
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(entry)), NSStringFromSelector(@selector(isHistory))]
|
||||
options:@{NSConditionallySetsEditableBindingOption: @NO, NSValueTransformerNameBindingOption: NSNegateBooleanTransformerName}];
|
||||
|
||||
}
|
||||
view.removeButton.target = self.viewController;
|
||||
view.removeButton.action = @selector(removeCustomField:);
|
||||
view.removeButton.tag = row;
|
||||
|
||||
@@ -22,17 +22,22 @@ NSString *const MPDocumentHideEntryHistoryNotification = @"MPDocumentHideEntryH
|
||||
if(self.hasSearch) {
|
||||
[self exitSearch:sender];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification
|
||||
object:self
|
||||
userInfo:@{ MPDocumentEntryKey: entries.firstObject }];
|
||||
self.historyEntry = entries.firstObject;
|
||||
if(self.historyEntry) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification
|
||||
object:self
|
||||
userInfo:@{ MPDocumentEntryKey: self.historyEntry }];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hideEntryHistory:(id)sender {
|
||||
self.historyEntry = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentHideEntryHistoryNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
- (void)revertEntry:(KPKEntry *)entry toEntry:(KPKEntry *)historyEntry {
|
||||
[entry pushHistory];
|
||||
[entry revertToEntry:historyEntry];
|
||||
[self.undoManager setActionName:NSLocalizedString(@"RESTORE_HISTORY_ENTRY", "Action to restore and Entry to a previous state of it's history")];
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
|
||||
@property (nonatomic, readonly) BOOL hasSearch;
|
||||
@property (nonatomic, copy) MPEntrySearchContext *searchContext;
|
||||
@property (nonatomic, strong, readonly) NSArray *searchResult;
|
||||
@property (nonatomic, weak) KPKEntry *historyEntry;
|
||||
|
||||
+ (KPKDatabaseFormat)formatForFileType:(NSString *)fileType;
|
||||
+ (NSString *)fileTypeForVersion:(KPKDatabaseFormat)format;
|
||||
|
||||
@@ -27,14 +27,18 @@
|
||||
@property (weak) IBOutlet HNHUIRoundedSecureTextField *passwordTextField;
|
||||
@property (weak) IBOutlet NSButton *generatePasswordButton;
|
||||
@property (weak) IBOutlet NSButton *togglePassword;
|
||||
@property (weak) IBOutlet NSButton *pickExpireDateButton;
|
||||
@property (weak) IBOutlet NSButton *expiresCheckButton;
|
||||
@property (weak) IBOutlet NSTokenField *tagsTokenField;
|
||||
@property (weak) IBOutlet NSTextField *uuidTextField;
|
||||
|
||||
@property (weak) IBOutlet NSTextField *createdTextField;
|
||||
@property (weak) IBOutlet NSTextField *modifiedTextField;
|
||||
@property (weak) IBOutlet NSButton *addCustomFieldButton;
|
||||
|
||||
/* Attachments */
|
||||
@property (weak) IBOutlet NSButtonCell *addAttachmentButton;
|
||||
|
||||
@property (weak) IBOutlet NSTableView *attachmentTableView;
|
||||
@property (weak) IBOutlet NSTableView *customFieldsTableView;
|
||||
|
||||
@@ -50,6 +54,7 @@
|
||||
@property (weak) IBOutlet NSButton *showCustomAssociationSequenceAutotypeBuilderButton;
|
||||
|
||||
@property (weak) IBOutlet NSTextField *associationSequenceTextField;
|
||||
@property (weak) IBOutlet NSButton *addWindowAssociationButton;
|
||||
|
||||
- (void)registerNotificationsForDocument:(MPDocument *)document;
|
||||
|
||||
|
||||
@@ -240,6 +240,8 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
case MPActionToggleQuicklook: {
|
||||
BOOL enabled = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyEnableQuicklookPreview];
|
||||
return enabled ? [self acceptsPreviewPanelControl:nil] : NO;
|
||||
case MPActionRemoveAttachment:
|
||||
return !self.representedEntry.isHistory;
|
||||
}
|
||||
default:
|
||||
return YES;
|
||||
@@ -360,13 +362,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
#pragma mark -
|
||||
#pragma mark Entry Selection
|
||||
- (void)_setupViewBindings {
|
||||
[self _bindEntry];
|
||||
[self _bindAttachments];
|
||||
[self _bindCustomFields];
|
||||
[self _bindAutotype];
|
||||
}
|
||||
|
||||
- (void)_bindEntry {
|
||||
/* general */
|
||||
[self.titleTextField bind:NSValueBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))]
|
||||
@@ -396,21 +392,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(tags))]
|
||||
options:nil];
|
||||
|
||||
NSArray *inputs = @[self.titleTextField,
|
||||
self.passwordTextField,
|
||||
self.usernameTextField,
|
||||
self.URLTextField,
|
||||
self.expiresCheckButton,
|
||||
self.tagsTokenField,
|
||||
self.generatePasswordButton];
|
||||
|
||||
for(NSControl *control in inputs) {
|
||||
NSString *keyPath = [NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(isHistory))];
|
||||
[control bind:NSEnabledBinding
|
||||
toObject:self
|
||||
withKeyPath:keyPath
|
||||
options:@{NSConditionallySetsEditableBindingOption: @NO, NSValueTransformerNameBindingOption: NSNegateBooleanTransformerName}];
|
||||
}
|
||||
|
||||
[self.uuidTextField bind:NSValueBinding
|
||||
toObject:self
|
||||
@@ -418,23 +399,19 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
options:@{ NSConditionallySetsEditableBindingOption: @NO }];
|
||||
self.uuidTextField.editable = NO;
|
||||
|
||||
}
|
||||
|
||||
- (void)_bindAttachments {
|
||||
/* Attachments */
|
||||
[_attachmentsController bind:NSContentArrayBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(binaries))]
|
||||
options:nil];
|
||||
}
|
||||
|
||||
- (void)_bindCustomFields {
|
||||
/* CustomField */
|
||||
[_customFieldsController bind:NSContentArrayBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(customAttributes))]
|
||||
options:nil];
|
||||
}
|
||||
- (void)_bindAutotype {
|
||||
|
||||
/* Autotype */
|
||||
[self.enableAutotypeCheckButton bind:NSValueBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(autotype)), NSStringFromSelector(@selector(enabled))] options:nil];
|
||||
@@ -464,6 +441,27 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
toObject:_windowAssociationsController
|
||||
withKeyPath:[NSString stringWithFormat:@"selection.%@", NSStringFromSelector(@selector(keystrokeSequence))]
|
||||
options:nil];
|
||||
|
||||
NSArray *inputs = @[self.titleTextField,
|
||||
self.passwordTextField,
|
||||
self.usernameTextField,
|
||||
self.URLTextField,
|
||||
self.expiresCheckButton,
|
||||
self.tagsTokenField,
|
||||
self.generatePasswordButton,
|
||||
self.addAttachmentButton,
|
||||
self.addCustomFieldButton,
|
||||
self.addWindowAssociationButton];
|
||||
|
||||
for(NSControl *control in inputs) {
|
||||
NSString *keyPath = [NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(isHistory))];
|
||||
[control bind:NSEnabledBinding
|
||||
toObject:self
|
||||
withKeyPath:keyPath
|
||||
options:@{NSConditionallySetsEditableBindingOption: @NO, NSValueTransformerNameBindingOption: NSNegateBooleanTransformerName}];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -735,7 +735,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
if(historyEntries.count != 1) {
|
||||
return;
|
||||
}
|
||||
//[document restoreEntry:entry toEntry:historyEntries.firstObject];
|
||||
[document revertEntry:document.historyEntry toEntry:historyEntries.firstObject];
|
||||
}
|
||||
|
||||
- (void)_columnDoubleClick:(id)sender {
|
||||
|
||||
Reference in New Issue
Block a user