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:
Michael Starke
2018-11-05 18:38:16 +01:00
parent c260202924
commit 0ff6597487
6 changed files with 23 additions and 6 deletions

View File

@@ -285,7 +285,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
return;
}
NSWindow *sheetWindow = ((MPDocument *)self.document).windowForSheet;
if(!sheetWindow) {
return;
@@ -323,15 +323,19 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}
- (void)showPasswordInput {
[self showPasswordInputWithMessage:nil];
}
- (void)showPasswordInputWithMessage:(NSString *)message {
if(!self.passwordInputController) {
self.passwordInputController = [[MPPasswordInputController alloc] init];
}
[self _setContentViewController:self.passwordInputController];
[self.passwordInputController requestPasswordWithCompletionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL cancel, NSError *__autoreleasing *error) {
if(cancel) {
[self.passwordInputController requestPasswordWithMessage:message cancelLabel:nil completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
if(didCancel) {
return NO;
}
return [((MPDocument *)self.document) unlockWithPassword:password keyFileURL:keyURL error:error];
}];
}