mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
Recovery attempt for save without password now also adheres to cancel
This commit is contained in:
@@ -21,19 +21,29 @@
|
|||||||
*/
|
*/
|
||||||
- (void)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex delegate:(nullable id)delegate didRecoverSelector:(nullable SEL)didRecoverSelector contextInfo:(nullable void *)contextInfo {
|
- (void)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex delegate:(nullable id)delegate didRecoverSelector:(nullable SEL)didRecoverSelector contextInfo:(nullable void *)contextInfo {
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:didRecoverSelector]];
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:didRecoverSelector]];
|
||||||
|
__block void *contextInfoCopy = contextInfo;
|
||||||
if(error.code == MPErrorNoPasswordOrKeyFile) {
|
if(error.code == MPErrorNoPasswordOrKeyFile) {
|
||||||
if([delegate isKindOfClass:[MPDocument class]]) {
|
if([delegate isKindOfClass:[MPDocument class]]) {
|
||||||
MPDocument *document = delegate;
|
MPDocument *document = delegate;
|
||||||
|
BOOL didRecover = NO;
|
||||||
|
if(recoveryOptionIndex == 0) {
|
||||||
[document.windowControllers.firstObject editPasswordWithCompetionHandler:^(NSInteger result) {
|
[document.windowControllers.firstObject editPasswordWithCompetionHandler:^(NSInteger result) {
|
||||||
BOOL didRecover = result == NSModalResponseOK;
|
BOOL didRecover = result == NSModalResponseOK;
|
||||||
invocation.target = delegate;
|
invocation.target = delegate;
|
||||||
invocation.selector = didRecoverSelector;
|
invocation.selector = didRecoverSelector;
|
||||||
[invocation setArgument:&didRecover atIndex:2];
|
[invocation setArgument:&didRecover atIndex:2];
|
||||||
[invocation setArgument:&contextInfo atIndex:3];
|
[invocation setArgument:&contextInfoCopy atIndex:3];
|
||||||
[invocation invoke];
|
[invocation invoke];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
invocation.target = delegate;
|
||||||
|
invocation.selector = didRecoverSelector;
|
||||||
|
[invocation setArgument:&didRecover atIndex:2];
|
||||||
|
[invocation setArgument:&contextInfo atIndex:3];
|
||||||
|
[invocation invoke];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user