]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTLocalCKKSResetOperation.m
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / ot / OTLocalCKKSResetOperation.m
1
2 #if OCTAGON
3
4 #import "utilities/debugging.h"
5
6 #import "keychain/ot/OTLocalCKKSResetOperation.h"
7 #import "keychain/ckks/CloudKitCategories.h"
8 #import "keychain/ckks/CKKSKeychainView.h"
9 #import "keychain/ckks/CKKSViewManager.h"
10
11 #import "keychain/TrustedPeersHelper/TrustedPeersHelperProtocol.h"
12 #import "keychain/ot/ObjCImprovements.h"
13
14 @interface OTLocalCKKSResetOperation ()
15 @property OTOperationDependencies* operationDependencies;
16
17 @property NSOperation* finishedOp;
18 @end
19
20 @implementation OTLocalCKKSResetOperation
21 @synthesize nextState = _nextState;
22 @synthesize intendedState = _intendedState;
23
24 - (instancetype)initWithDependencies:(OTOperationDependencies*)dependencies
25 intendedState:(OctagonState*)intendedState
26 errorState:(OctagonState*)errorState
27 {
28 if((self = [super init])) {
29 _operationDependencies = dependencies;
30
31 _intendedState = intendedState;
32 _nextState = errorState;
33 }
34 return self;
35 }
36
37 - (void)groupStart
38 {
39 secnotice("octagon-ckks", "Beginning an 'reset CKKS' operation");
40
41 WEAKIFY(self);
42
43 self.finishedOp = [NSBlockOperation blockOperationWithBlock:^{
44 STRONGIFY(self);
45 secnotice("octagon-ckks", "Finishing a ckks-local-reset operation with %@", self.error ?: @"no error");
46 }];
47 [self dependOnBeforeGroupFinished:self.finishedOp];
48
49 [self.operationDependencies.viewManager rpcResetLocal:nil reply: ^(NSError* _Nullable resultError) {
50 STRONGIFY(self);
51
52 secnotice("octagon-ckks", "Finished ckks-local-reset with %@", self.error ?: @"no error");
53
54 if(resultError == nil) {
55 self.nextState = self.intendedState;
56 } else {
57 self.error = resultError;
58 }
59 [self runBeforeGroupFinished:self.finishedOp];
60 }];
61 }
62
63 @end
64
65 #endif // OCTAGON