mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 19:22:25 +00:00
Adoped new KeePassKit placeholder delegation.
Added primitive support for {PICKCHARS} currently without support for options
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -1,3 +1,3 @@
|
||||
github "sparkle-project/Sparkle" ~> 1.18.1
|
||||
github "MacPass/KeePassKit" ~> 1.7.6
|
||||
github "MacPass/KeePassKit" ~> 1.8
|
||||
github "mstarke/HNHUi" ~> 1.4.1
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
github "MacPass/KeePassKit" "1.7.7"
|
||||
github "MacPass/KeePassKit" "1.8"
|
||||
github "mstarke/HNHUi" "1.4.1"
|
||||
github "sparkle-project/Sparkle" "1.18.1"
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
4CA2335A176DBFE100F0B6AC /* MPLockDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA23359176DBFE100F0B6AC /* MPLockDaemon.m */; };
|
||||
4CA334CA18AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA334C918AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m */; };
|
||||
4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */; };
|
||||
4CA4B3461FC8833A007DF507 /* PickcharView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA4B3451FC88339007DF507 /* PickcharView.xib */; };
|
||||
4CAAA8271D787B8B00CDE977 /* MPAutotypeBuilderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */; };
|
||||
4CAD748C15B889B700104512 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748B15B889B700104512 /* Security.framework */; };
|
||||
4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; };
|
||||
@@ -218,6 +219,7 @@
|
||||
4CD034AA1BFE113B003C002C /* MPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD034A51BFE113B003C002C /* MPPlugin.m */; };
|
||||
4CD034AC1BFE113B003C002C /* MPPluginHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD034A91BFE113B003C002C /* MPPluginHost.m */; };
|
||||
4CD2B9061849424B0051B395 /* MPAutotypeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */; };
|
||||
4CD4EE131FC7284000EA6EB3 /* MPPickcharViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD4EE111FC7284000EA6EB3 /* MPPickcharViewController.m */; };
|
||||
4CD5D705177A5F3300100649 /* MPDatabaseSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD5D704177A5F3300100649 /* MPDatabaseSettingsWindowController.m */; };
|
||||
4CD60C131C104AD4005BE5F8 /* HNHUi.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4CC281881C0F675B00B9174D /* HNHUi.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
4CD7223B17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD7223A17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m */; };
|
||||
@@ -681,6 +683,7 @@
|
||||
4CA334C918AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPWindowAssociationsTableViewDelegate.m; sourceTree = "<group>"; };
|
||||
4CA3530918A53CB800839B0F /* MPKeyMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyMapper.h; sourceTree = "<group>"; };
|
||||
4CA3530A18A53CB800839B0F /* MPKeyMapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyMapper.m; sourceTree = "<group>"; };
|
||||
4CA4B3451FC88339007DF507 /* PickcharView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PickcharView.xib; sourceTree = "<group>"; };
|
||||
4CAAA8241D787B8B00CDE977 /* MPAutotypeBuilderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeBuilderViewController.h; sourceTree = "<group>"; };
|
||||
4CAAA8251D787B8B00CDE977 /* MPAutotypeBuilderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeBuilderViewController.m; sourceTree = "<group>"; };
|
||||
4CAD748B15B889B700104512 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
@@ -715,6 +718,8 @@
|
||||
4CD034A91BFE113B003C002C /* MPPluginHost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPluginHost.m; path = MacPass/MPPluginHost.m; sourceTree = SOURCE_ROOT; };
|
||||
4CD2B9041849424B0051B395 /* MPAutotypeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeContext.h; sourceTree = "<group>"; };
|
||||
4CD2B9051849424B0051B395 /* MPAutotypeContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeContext.m; sourceTree = "<group>"; };
|
||||
4CD4EE101FC7284000EA6EB3 /* MPPickcharViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPickcharViewController.h; sourceTree = "<group>"; };
|
||||
4CD4EE111FC7284000EA6EB3 /* MPPickcharViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPickcharViewController.m; sourceTree = "<group>"; };
|
||||
4CD5D703177A5F3300100649 /* MPDatabaseSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseSettingsWindowController.h; sourceTree = "<group>"; };
|
||||
4CD5D704177A5F3300100649 /* MPDatabaseSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseSettingsWindowController.m; sourceTree = "<group>"; };
|
||||
4CD7223917A7CB0700F5A1E1 /* MPWorkflowSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPWorkflowSettingsController.h; sourceTree = "<group>"; };
|
||||
@@ -1432,6 +1437,12 @@
|
||||
4CA182711F963FF600DD4A4A /* MPTitlebarColorAccessoryViewController.h */,
|
||||
4CA182721F963FF600DD4A4A /* MPTitlebarColorAccessoryViewController.m */,
|
||||
4CA182731F963FF600DD4A4A /* TitlebarColorAccessoryViewController.xib */,
|
||||
4C6DCC5E1FA24C2100C8AD3F /* MPAutotypeCandidateSelectionViewController.h */,
|
||||
4C6DCC5F1FA24C2100C8AD3F /* MPAutotypeCandidateSelectionViewController.m */,
|
||||
FA9FD3291FB5E8F4003CEDD6 /* AutotypeCandidateSelectionView.xib */,
|
||||
4CD4EE101FC7284000EA6EB3 /* MPPickcharViewController.h */,
|
||||
4CD4EE111FC7284000EA6EB3 /* MPPickcharViewController.m */,
|
||||
4CA4B3451FC88339007DF507 /* PickcharView.xib */,
|
||||
);
|
||||
name = "View Controller";
|
||||
sourceTree = "<group>";
|
||||
@@ -1496,9 +1507,6 @@
|
||||
4C8990F41EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.h */,
|
||||
4C8990F51EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m */,
|
||||
4CA1827A1F96523600DD4A4A /* DuplicateEntryOptionsWindow.xib */,
|
||||
4C6DCC5E1FA24C2100C8AD3F /* MPAutotypeCandidateSelectionViewController.h */,
|
||||
4C6DCC5F1FA24C2100C8AD3F /* MPAutotypeCandidateSelectionViewController.m */,
|
||||
FA9FD3291FB5E8F4003CEDD6 /* AutotypeCandidateSelectionView.xib */,
|
||||
);
|
||||
name = "Window Controller";
|
||||
sourceTree = "<group>";
|
||||
@@ -1710,6 +1718,7 @@
|
||||
4C431BCF16E2BAB000700A81 /* OverlayWindow.xib in Resources */,
|
||||
4C3826B61AD04D8E007D7D67 /* 41_VectorTemplate.pdf in Resources */,
|
||||
4C17F105184E630200E85625 /* 14_BatteryTemplate.pdf in Resources */,
|
||||
4CA4B3461FC8833A007DF507 /* PickcharView.xib in Resources */,
|
||||
4C76156D1764C0E20015A1A6 /* InspectorView.xib in Resources */,
|
||||
4C888C9016EB6C91003D34A1 /* Localizable.strings in Resources */,
|
||||
4C3826B01AD04D8E007D7D67 /* 35_BrowserWindowTemplate.pdf in Resources */,
|
||||
@@ -1891,6 +1900,7 @@
|
||||
4CD2B9061849424B0051B395 /* MPAutotypeContext.m in Sources */,
|
||||
4CFB18E418A17FA20097A34B /* MPUpdateSettingsController.m in Sources */,
|
||||
4C7B63771C0CB51F00D7038C /* TTTStringTransformers.m in Sources */,
|
||||
4CD4EE131FC7284000EA6EB3 /* MPPickcharViewController.m in Sources */,
|
||||
4CCEDE2A179F203B008402BE /* MPOutlineView.m in Sources */,
|
||||
4CB33F861EAF54A000C9341E /* KPKNode+MPIsHistory.m in Sources */,
|
||||
4CCEDE2E179F213B008402BE /* MPNotifications.m in Sources */,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -142,7 +142,7 @@ DQ
|
||||
<constraint firstItem="7cB-re-3ys" firstAttribute="top" secondItem="kDw-2l-7gQ" secondAttribute="bottom" constant="8" symbolic="YES" id="ss6-Ku-XPY"/>
|
||||
<constraint firstAttribute="trailing" secondItem="kDw-2l-7gQ" secondAttribute="trailing" constant="20" symbolic="YES" id="zSz-fH-fVn"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-128" y="-54"/>
|
||||
<point key="canvasLocation" x="176" y="-39"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -532,7 +532,7 @@
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="58" secondAttribute="trailing" constant="20" symbolic="YES" id="rbs-i7-bti"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6" secondAttribute="trailing" constant="20" symbolic="YES" id="uuh-ba-z4h"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-525" y="-927"/>
|
||||
<point key="canvasLocation" x="-679" y="-1054"/>
|
||||
</customView>
|
||||
<view translatesAutoresizingMaskIntoConstraints="NO" id="zv7-wE-Bmg" customClass="HNHUIScrollDocumentViewAdapter">
|
||||
<rect key="frame" x="0.0" y="0.0" width="301" height="424"/>
|
||||
@@ -900,7 +900,7 @@
|
||||
<connections>
|
||||
<outlet property="nextKeyView" destination="QSX-Xo-tcH" id="KP9-D4-4cC"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-899" y="-949"/>
|
||||
<point key="canvasLocation" x="-1015" y="-1275"/>
|
||||
</scrollView>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -239,8 +239,7 @@ static MPAutotypeDaemon *_sharedInstance;
|
||||
usleep(1 * NSEC_PER_MSEC);
|
||||
}
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSArray<MPAutotypeCommand *> *commands = [MPAutotypeCommand commandsForContext:context];
|
||||
for(MPAutotypeCommand *command in commands) {
|
||||
for(MPAutotypeCommand *command in [MPAutotypeCommand commandsForContext:context]) {
|
||||
[command execute];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// MPAutotypePickchars.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 23.11.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPAutotypePickchars.h"
|
||||
#import "MPPickcharViewController.h"
|
||||
|
||||
@implementation MPAutotypePickchars
|
||||
|
||||
- (void)execute {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
|
||||
|
||||
MPPickcharViewController *vc = [[MPPickcharViewController alloc] init];
|
||||
vc.sourceValue = @"ThisIsANicePassword";
|
||||
vc.countToPick = 10;
|
||||
|
||||
|
||||
NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
||||
styleMask:NSWindowStyleMaskNonactivatingPanel|NSWindowStyleMaskTitled
|
||||
backing:NSBackingStoreRetained
|
||||
defer:YES];
|
||||
panel.level = NSScreenSaverWindowLevel;
|
||||
panel.contentViewController = vc;
|
||||
[panel center];
|
||||
[panel makeKeyAndOrderFront:self];
|
||||
|
||||
if(NSModalResponseOK == [NSApp runModalForWindow:panel]) {
|
||||
// Do some stuff!
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
23
MacPass/MPPickcharViewController.h
Normal file
23
MacPass/MPPickcharViewController.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// MPPickcharViewController.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 23.11.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPPickcharViewController : NSViewController
|
||||
|
||||
@property (copy) NSString *sourceValue;
|
||||
@property (nonatomic, copy) NSString *pickedValue;
|
||||
@property NSInteger countToPick;
|
||||
@property (nonatomic) BOOL hideSource;
|
||||
|
||||
- (IBAction)reset:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
121
MacPass/MPPickcharViewController.m
Normal file
121
MacPass/MPPickcharViewController.m
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// MPPickcharViewController.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 23.11.17.
|
||||
// Copyright © 2017 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPickcharViewController.h"
|
||||
#import "NSString+MPComposedCharacterAdditions.h"
|
||||
|
||||
#import <HNHUi/HNHUi.h>
|
||||
|
||||
@interface MPPickcharViewController () <NSTableViewDelegate, NSTableViewDataSource>
|
||||
@property (weak) IBOutlet NSTableView *characterTableView;
|
||||
@property (weak) IBOutlet NSTextField *pickedValueTextField;
|
||||
@property (weak) IBOutlet NSButton *togglePasswordDisplayButton;
|
||||
@property (weak) IBOutlet NSTextField *pickedStatusTextField;
|
||||
@end
|
||||
|
||||
@implementation MPPickcharViewController
|
||||
|
||||
- (NSNibName)nibName {
|
||||
return @"PickcharView";
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
self = [super initWithCoder:coder];
|
||||
if(self) {
|
||||
self.hideSource = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNibName:(NSNibName)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if(self) {
|
||||
self.hideSource = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)reset:(id)sender {
|
||||
self.pickedValue = @"";
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
for(NSTableColumn *column in self.characterTableView.tableColumns) {
|
||||
[self.characterTableView removeTableColumn:column];
|
||||
}
|
||||
for(NSUInteger count = 0; count < self.sourceValue.composedCharacterLength; count++) {
|
||||
|
||||
NSString *columnTitle = [NSString stringWithFormat:@"%ld", count];
|
||||
NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:columnTitle];
|
||||
column.maxWidth = 32.0;
|
||||
column.minWidth = column.maxWidth;
|
||||
column.headerCell.stringValue = columnTitle;
|
||||
[self.characterTableView addTableColumn:column];
|
||||
}
|
||||
self.characterTableView.enclosingScrollView.horizontalScroller.scrollerStyle = NSScrollerStyleLegacy;
|
||||
[self.pickedValueTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(pickedValue)) options:nil];
|
||||
[self.togglePasswordDisplayButton bind:NSValueBinding toObject:self.pickedValueTextField withKeyPath:NSStringFromSelector(@selector(showPassword)) options:nil];
|
||||
|
||||
[self reset:self];
|
||||
}
|
||||
|
||||
- (void)setHideSource:(BOOL)hideSource {
|
||||
if(_hideSource != hideSource) {
|
||||
_hideSource = hideSource;
|
||||
[self.characterTableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPickedValue:(NSString *)pickedValue {
|
||||
_pickedValue = [pickedValue copy];
|
||||
[self _updatePickedStatus];
|
||||
}
|
||||
|
||||
- (void)_updatePickedStatus {
|
||||
self.pickedStatusTextField.stringValue = [NSString stringWithFormat:@"%ld characters remaining", self.pickedValue.composedCharacterLength];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
||||
if(tableView != self.characterTableView) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
NSTableCellView *view = [tableView makeViewWithIdentifier:@"Cell" owner:self];
|
||||
NSInteger index = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn];
|
||||
if(index == NSNotFound) {
|
||||
view.textField.stringValue = @"?";
|
||||
}
|
||||
view.textField.stringValue = self.hideSource ? @"•" : [self.sourceValue composedCharacterAtIndex:index];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn {
|
||||
NSInteger index = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn];
|
||||
if(index == NSNotFound) {
|
||||
return;
|
||||
}
|
||||
if(self.pickedValue) {
|
||||
self.pickedValue = [self.pickedValue stringByAppendingString:[self.sourceValue composedCharacterAtIndex:index]];
|
||||
}
|
||||
else {
|
||||
self.pickedValue = [self.sourceValue composedCharacterAtIndex:index];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)finishedPicking:(id)sender {
|
||||
[NSApp stopModalWithCode:NSModalResponseOK];
|
||||
}
|
||||
|
||||
- (IBAction)cancelPicking:(id)sender {
|
||||
[NSApp stopModalWithCode:NSModalResponseCancel];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -25,6 +25,8 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MPPluginHost;
|
||||
@class MPAutotypeCommand;
|
||||
@class KPKEntry;
|
||||
|
||||
FOUNDATION_EXPORT NSString *const kMPPluginFileExtension;
|
||||
|
||||
@@ -35,6 +37,14 @@ FOUNDATION_EXPORT NSString *const kMPPluginFileExtension;
|
||||
@property (copy, readonly) NSString *version;
|
||||
@property (nonatomic, strong, readonly) NSBundle *bundle;
|
||||
|
||||
|
||||
/**
|
||||
If your plugin needs initalization override this method but you have to call [super initWithPluginHost:]
|
||||
Otherwise your plugin might not get registered correctly
|
||||
|
||||
@param host plugin host hosting the pluing - MacPass
|
||||
@return the plugin instance ready for use
|
||||
*/
|
||||
- (instancetype)initWithPluginHost:(MPPluginHost *)host NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@@ -49,6 +59,43 @@ FOUNDATION_EXPORT NSString *const kMPPluginFileExtension;
|
||||
|
||||
@end
|
||||
|
||||
/* Adopt this protocoll if you plugin supplied additinal autotype commands */
|
||||
@protocol MPAutotypePlugin <NSObject>
|
||||
@required
|
||||
/**
|
||||
Returns an array of string of commands supported by this pluing. Leave out enclosing curly brackets!
|
||||
E.g. if you support {FOO} and {BAR} you will return @[ @"FOO", @"BAR" ]. The autotype system is case insenstivie.
|
||||
*/
|
||||
@property (nonatomic,copy) NSArray <NSString *> *commandStrings;
|
||||
/**
|
||||
Will be called by the plugin host to generate autotype commands for the corresponding string.
|
||||
Command strings are considered case insensitive but mostly will be used in upper case.
|
||||
You should therefore compare case insensitive.
|
||||
|
||||
@param commandString The command string without any enclosing curly brackets. The string is normalized to upper cased.
|
||||
@param entry The entry for which the command will be used
|
||||
@return a command for the supplied string, return nil if parsing fails or an unsupported command is supplied
|
||||
*/
|
||||
- (MPAutotypeCommand * _Nullable)commandForString:(NSString *)commandString entry:(KPKEntry *)entry;
|
||||
@end
|
||||
|
||||
/*
|
||||
Adopt this protocoll if your plugin supports actions on entries.
|
||||
Actions will get listed in various places in menues. You should shoudl supply a valid menu item
|
||||
that is wired up with the correct target and action. Since there's responder chain resolving involved
|
||||
as well as a
|
||||
*/
|
||||
@protocol MPEntryActionPlugin <NSObject>
|
||||
@optional
|
||||
- (NSMenuItem * _Nullable)menuItemForEntry;
|
||||
@end
|
||||
|
||||
@protocol MPCustomAttributePlugin <NSObject>
|
||||
@optional
|
||||
/* Supply a list of attribute keys that will get suggested for autocompletion as well as added to the extend add for custom fields */
|
||||
@property (nonatomic,copy) NSArray<NSString *>* attributeKeys;
|
||||
@end
|
||||
|
||||
@interface MPPlugin (Deprecated)
|
||||
|
||||
- (instancetype)initWithPluginManager:(id)manager;
|
||||
|
||||
@@ -44,4 +44,8 @@ FOUNDATION_EXPORT NSString *const MPPluginHostPluginBundleIdentifiyerKey;
|
||||
- (void)disablePlugin:(MPPlugin *)plugin;
|
||||
- (void)enablePlugin:(MPPlugin *)plugin;
|
||||
|
||||
/*
|
||||
- (NSArray <MPPlugin __kindof*>*)autotypePlugins;
|
||||
- (NSArray <MPPlugin __kindof*>*)entryContextMenuPlugins;
|
||||
*/
|
||||
@end
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "MPPickcharViewController.h"
|
||||
|
||||
@interface MPTreeDelegate ();
|
||||
|
||||
@@ -53,15 +54,12 @@
|
||||
return self.document.undoManager;
|
||||
}
|
||||
|
||||
- (NSString *)resolvePlaceholder:(NSString *)placeholder forTree:(KPKTree *)tree {
|
||||
- (NSString *)tree:(KPKTree *)tree resolvePlaceholder:(NSString *)placeholder forEntry:(KPKEntry *)entry {
|
||||
if([placeholder isEqualToString:kKPKPlaceholderDatabasePath]) {
|
||||
return self.document.fileURL.path;
|
||||
}
|
||||
if([placeholder isEqualToString:kKPKPlaceholderDatabaseFolder]) {
|
||||
return self.document.fileURL.path;
|
||||
}
|
||||
if([placeholder isEqualToString:kKPKPlaceholderDatabaseName]) {
|
||||
return self.document.tree.metaData.databaseName;
|
||||
return self.document.fileURL.path;
|
||||
}
|
||||
if([placeholder isEqualToString:kKPKPlaceholderDatabaseBasename]) {
|
||||
return @"";
|
||||
@@ -80,4 +78,35 @@
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
- (NSString *)tree:(KPKTree *)tree resolvePickFieldPlaceholderForEntry:(KPKEntry *)entry {
|
||||
return @"";
|
||||
}
|
||||
|
||||
- (NSString *)tree:(KPKTree *)tree resolvePickCharsPlaceholderForEntry:(KPKEntry *)entry field:(NSString *)field options:(NSString *)options {
|
||||
|
||||
NSString *value = [[entry valueForAttributeWithKey:field] kpk_finalValueForEntry:entry];
|
||||
if(value.length == 0) {
|
||||
return @""; // error while retrieving source value
|
||||
}
|
||||
|
||||
MPPickcharViewController *pickCharViewController = [[MPPickcharViewController alloc] init];
|
||||
|
||||
pickCharViewController.sourceValue = value;
|
||||
pickCharViewController.countToPick = 10;
|
||||
|
||||
|
||||
NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
||||
styleMask:NSWindowStyleMaskNonactivatingPanel|NSWindowStyleMaskTitled|NSWindowStyleMaskResizable
|
||||
backing:NSBackingStoreRetained
|
||||
defer:YES];
|
||||
panel.level = NSScreenSaverWindowLevel;
|
||||
panel.contentViewController = pickCharViewController;
|
||||
[panel center];
|
||||
if(NSModalResponseOK == [NSApp runModalForWindow:panel]) {
|
||||
/* add appropriate key press comamnds? or let the pick-char view-controller handel this? */
|
||||
return pickCharViewController.pickedValue;
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
@end
|
||||
|
||||
163
MacPass/PickcharView.xib
Normal file
163
MacPass/PickcharView.xib
Normal file
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPPickcharViewController">
|
||||
<connections>
|
||||
<outlet property="characterTableView" destination="KJq-FZ-rAE" id="H5Y-kG-Mvm"/>
|
||||
<outlet property="pickedStatusTextField" destination="e2q-qh-Zlv" id="paL-BH-g7a"/>
|
||||
<outlet property="pickedValueTextField" destination="KQ1-tZ-qja" id="ETe-j3-jdp"/>
|
||||
<outlet property="togglePasswordDisplayButton" destination="hKI-WP-N93" id="ZDt-Rp-Ix2"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="410" height="165"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KQ1-tZ-qja" customClass="HNHUIRoundedSecureTextField">
|
||||
<rect key="frame" x="20" y="49" width="276" height="24"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Wi0-xp-KgI">
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hKI-WP-N93">
|
||||
<rect key="frame" x="361" y="48" width="29" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSQuickLookTemplate" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="95g-dp-50Q">
|
||||
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<scrollView horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="MVS-ug-wys">
|
||||
<rect key="frame" x="20" y="81" width="370" height="64"/>
|
||||
<clipView key="contentView" drawsBackground="NO" id="8aa-cB-mUF">
|
||||
<rect key="frame" x="1" y="0.0" width="368" height="63"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="24" rowSizeStyle="systemDefault" headerView="GRO-H1-N4r" viewBased="YES" id="KJq-FZ-rAE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="368" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn width="365" minWidth="40" maxWidth="1000" id="Q1b-ir-hyW">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="pUG-4c-rTt">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="Cell" id="Nz8-0B-uHk">
|
||||
<rect key="frame" x="1" y="1" width="365" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="prY-vi-i8N">
|
||||
<rect key="frame" x="0.0" y="0.0" width="365" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="v3T-2f-yWm">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="prY-vi-i8N" id="uX4-gz-scd"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="-2" id="UrQ-DY-2jn"/>
|
||||
<outlet property="delegate" destination="-2" id="JRz-9a-dkH"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<nil key="backgroundColor"/>
|
||||
</clipView>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="64" id="AIX-Tc-QJA"/>
|
||||
</constraints>
|
||||
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="sA9-kc-O5g">
|
||||
<rect key="frame" x="1" y="47" width="368" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="mSX-pm-wrh">
|
||||
<rect key="frame" x="-100" y="-100" width="15" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<tableHeaderView key="headerView" id="GRO-H1-N4r">
|
||||
<rect key="frame" x="0.0" y="0.0" width="368" height="23"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</tableHeaderView>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="k8l-uy-C3l">
|
||||
<rect key="frame" x="324" y="13" width="72" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Done" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8vP-Ka-vsA">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="finishedPicking:" target="-1" id="Gb1-1S-8bv"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Y8X-Bm-qLt">
|
||||
<rect key="frame" x="304" y="48" width="49" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Reset" bezelStyle="texturedRounded" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Emo-pg-Mfe">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="reset:" target="-2" id="jCN-qH-N8O"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e2q-qh-Zlv">
|
||||
<rect key="frame" x="187" y="20" width="37" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="M3h-q8-FLO">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="hKI-WP-N93" secondAttribute="trailing" constant="20" symbolic="YES" id="0IY-n6-nZi"/>
|
||||
<constraint firstItem="hKI-WP-N93" firstAttribute="centerY" secondItem="KQ1-tZ-qja" secondAttribute="centerY" id="1CC-7F-3GU"/>
|
||||
<constraint firstItem="KQ1-tZ-qja" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" symbolic="YES" id="1D9-Zk-KrZ"/>
|
||||
<constraint firstItem="k8l-uy-C3l" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="e2q-qh-Zlv" secondAttribute="trailing" constant="8" symbolic="YES" id="7VJ-ri-ltE"/>
|
||||
<constraint firstItem="MVS-ug-wys" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" symbolic="YES" id="9cE-TT-pqS"/>
|
||||
<constraint firstItem="hKI-WP-N93" firstAttribute="leading" secondItem="Y8X-Bm-qLt" secondAttribute="trailing" constant="8" id="AVv-zt-6sj"/>
|
||||
<constraint firstAttribute="trailing" secondItem="k8l-uy-C3l" secondAttribute="trailing" constant="20" symbolic="YES" id="Eaa-oF-Lt5"/>
|
||||
<constraint firstItem="MVS-ug-wys" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" symbolic="YES" id="Klq-Q9-Rjp"/>
|
||||
<constraint firstItem="Y8X-Bm-qLt" firstAttribute="leading" secondItem="KQ1-tZ-qja" secondAttribute="trailing" constant="8" id="Qxu-Wk-ckL"/>
|
||||
<constraint firstItem="Y8X-Bm-qLt" firstAttribute="centerY" secondItem="KQ1-tZ-qja" secondAttribute="centerY" id="T81-yL-LEh"/>
|
||||
<constraint firstAttribute="bottom" secondItem="k8l-uy-C3l" secondAttribute="bottom" constant="20" symbolic="YES" id="UXs-2n-gB5"/>
|
||||
<constraint firstItem="k8l-uy-C3l" firstAttribute="top" secondItem="KQ1-tZ-qja" secondAttribute="bottom" constant="8" symbolic="YES" id="kn5-3q-Pae"/>
|
||||
<constraint firstAttribute="bottom" secondItem="e2q-qh-Zlv" secondAttribute="bottom" constant="20" symbolic="YES" id="l3c-Ig-Z3V"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MVS-ug-wys" secondAttribute="trailing" constant="20" symbolic="YES" id="mMv-HC-fEv"/>
|
||||
<constraint firstItem="KQ1-tZ-qja" firstAttribute="top" secondItem="MVS-ug-wys" secondAttribute="bottom" constant="8" symbolic="YES" id="nKb-eh-ba4"/>
|
||||
<constraint firstItem="e2q-qh-Zlv" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="tE5-PK-tp0"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-769" y="-173"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSQuickLookTemplate" width="19" height="12"/>
|
||||
</resources>
|
||||
</document>
|
||||
Reference in New Issue
Block a user