mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Extended password input API to allow for custom messages.
Autotype now dispays an info message when the database needs to be unlocked
This commit is contained in:
@@ -152,7 +152,7 @@ Gw
|
|||||||
<constraint firstItem="d8O-Ha-rrS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="vxq-YP-UhR"/>
|
<constraint firstItem="d8O-Ha-rrS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="vxq-YP-UhR"/>
|
||||||
<constraint firstItem="2" firstAttribute="leading" secondItem="2pb-ZG-spA" secondAttribute="trailing" constant="12" id="ytJ-5Z-5rT"/>
|
<constraint firstItem="2" firstAttribute="leading" secondItem="2pb-ZG-spA" secondAttribute="trailing" constant="12" id="ytJ-5Z-5rT"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<point key="canvasLocation" x="-43" y="-59"/>
|
<point key="canvasLocation" x="77" y="-2"/>
|
||||||
</customView>
|
</customView>
|
||||||
</objects>
|
</objects>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#import "MPAutotypeDaemon.h"
|
#import "MPAutotypeDaemon.h"
|
||||||
#import "MPDocument.h"
|
#import "MPDocument.h"
|
||||||
|
#import "MPDocumentWindowController.h"
|
||||||
#import "MPAutotypeCommand.h"
|
#import "MPAutotypeCommand.h"
|
||||||
#import "MPAutotypeContext.h"
|
#import "MPAutotypeContext.h"
|
||||||
#import "MPAutotypePaste.h"
|
#import "MPAutotypePaste.h"
|
||||||
@@ -208,7 +209,10 @@ static MPAutotypeDaemon *_sharedInstance;
|
|||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
[NSApp.mainWindow makeKeyAndOrderFront:self];
|
[NSApp.mainWindow makeKeyAndOrderFront:self];
|
||||||
/* show the actual document window to the user */
|
/* show the actual document window to the user */
|
||||||
[documents.firstObject showWindows];
|
MPDocument *document = documents.firstObject;
|
||||||
|
[document showWindows];
|
||||||
|
MPDocumentWindowController *wc = document.windowControllers.firstObject;
|
||||||
|
[wc showPasswordInputWithMessage:NSLocalizedString(@"AUTOTYPE_MESSAGE_UNLOCK_DATABASE", @"Message displayed to the user to unlock the database to perform global autotype")];
|
||||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:nil];
|
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:nil];
|
||||||
return; // wait for the unlock to happen
|
return; // wait for the unlock to happen
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
- (void)showEntries;
|
- (void)showEntries;
|
||||||
- (void)showPasswordInput;
|
- (void)showPasswordInput;
|
||||||
|
- (void)showPasswordInputWithMessage:(NSString *)message;
|
||||||
- (void)editPasswordWithCompetionHandler:(void (^)(NSInteger result))handler;
|
- (void)editPasswordWithCompetionHandler:(void (^)(NSInteger result))handler;
|
||||||
|
|
||||||
#pragma mark Actions
|
#pragma mark Actions
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
|
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWindow *sheetWindow = ((MPDocument *)self.document).windowForSheet;
|
NSWindow *sheetWindow = ((MPDocument *)self.document).windowForSheet;
|
||||||
if(!sheetWindow) {
|
if(!sheetWindow) {
|
||||||
return;
|
return;
|
||||||
@@ -323,15 +323,19 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)showPasswordInput {
|
- (void)showPasswordInput {
|
||||||
|
[self showPasswordInputWithMessage:nil];
|
||||||
|
}
|
||||||
|
- (void)showPasswordInputWithMessage:(NSString *)message {
|
||||||
if(!self.passwordInputController) {
|
if(!self.passwordInputController) {
|
||||||
self.passwordInputController = [[MPPasswordInputController alloc] init];
|
self.passwordInputController = [[MPPasswordInputController alloc] init];
|
||||||
}
|
}
|
||||||
[self _setContentViewController:self.passwordInputController];
|
[self _setContentViewController:self.passwordInputController];
|
||||||
[self.passwordInputController requestPasswordWithCompletionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL cancel, NSError *__autoreleasing *error) {
|
[self.passwordInputController requestPasswordWithMessage:message cancelLabel:nil completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
||||||
if(cancel) {
|
if(didCancel) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
return [((MPDocument *)self.document) unlockWithPassword:password keyFileURL:keyURL error:error];
|
return [((MPDocument *)self.document) unlockWithPassword:password keyFileURL:keyURL error:error];
|
||||||
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,8 +153,12 @@
|
|||||||
self.messageInfoTextField.hidden = (nil == self.message);
|
self.messageInfoTextField.hidden = (nil == self.message);
|
||||||
if(self.message) {
|
if(self.message) {
|
||||||
self.messageInfoTextField.stringValue = self.message;
|
self.messageInfoTextField.stringValue = self.message;
|
||||||
|
self.messageImageView.image = [NSImage imageNamed:NSImageNameInfo];
|
||||||
}
|
}
|
||||||
self.messageImageView.hidden = (nil == self.message);;
|
else {
|
||||||
|
self.messageImageView.image = [NSImage imageNamed:NSImageNameCaution];
|
||||||
|
}
|
||||||
|
self.messageImageView.hidden = (nil == self.message);
|
||||||
self.cancelButton.hidden = (nil == self.cancelLabel);
|
self.cancelButton.hidden = (nil == self.cancelLabel);
|
||||||
if(self.cancelLabel) {
|
if(self.cancelLabel) {
|
||||||
self.cancelButton.stringValue = self.cancelLabel;
|
self.cancelButton.stringValue = self.cancelLabel;
|
||||||
@@ -172,6 +176,7 @@
|
|||||||
self.messageInfoTextField.stringValue = error.descriptionForErrorCode;
|
self.messageInfoTextField.stringValue = error.descriptionForErrorCode;
|
||||||
}
|
}
|
||||||
self.messageImageView.hidden = NO;
|
self.messageImageView.hidden = NO;
|
||||||
|
self.messageImageView.image = [NSImage imageNamed:NSImageNameCaution];
|
||||||
self.messageInfoTextField.hidden = NO;
|
self.messageInfoTextField.hidden = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@
|
|||||||
/* Inherit autotype settings menu item */
|
/* Inherit autotype settings menu item */
|
||||||
"AUTOTYPE_INHERIT" = "Inherit Autotype Settings";
|
"AUTOTYPE_INHERIT" = "Inherit Autotype Settings";
|
||||||
|
|
||||||
|
/* Message displayed to the user to unlock the database to perform global autotype */
|
||||||
|
"AUTOTYPE_MESSAGE_UNLOCK_DATABASE" = "Please unlock the database to use Global Autotype";
|
||||||
|
|
||||||
/* Disable autotype menu item */
|
/* Disable autotype menu item */
|
||||||
"AUTOTYPE_NO" = "Disable Autotype";
|
"AUTOTYPE_NO" = "Disable Autotype";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user