]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTCuttlefishAccountStateHolder.h
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / ot / OTCuttlefishAccountStateHolder.h
1
2 #import <Foundation/Foundation.h>
3 #import <dispatch/dispatch.h>
4
5 #import "keychain/ot/proto/generated_source/OTAccountMetadataClassC.h"
6
7 extern NSString* _Nonnull OTCuttlefishContextErrorDomain;
8 typedef NS_ENUM(uint32_t, OTCuttlefishContextErrors) {
9 OTCCNoExistingPeerID = 0,
10 };
11
12 NS_ASSUME_NONNULL_BEGIN
13
14 @protocol OTCuttlefishAccountStateHolderNotifier
15 - (void)accountStateUpdated:(OTAccountMetadataClassC*)newState from:(OTAccountMetadataClassC*)oldState;
16 @end
17
18 @interface OTCuttlefishAccountStateHolder : NSObject
19
20 // If you already know you're on this queue, call the _onqueue versions below.
21 - (instancetype)initWithQueue:(dispatch_queue_t)queue
22 container:(NSString*)containerName
23 context:(NSString*)contextID;
24
25 - (OTAccountMetadataClassC* _Nullable)loadOrCreateAccountMetadata:(NSError**)error;
26 - (OTAccountMetadataClassC* _Nullable)_onqueueLoadOrCreateAccountMetadata:(NSError**)error;
27
28 - (void)registerNotification:(id<OTCuttlefishAccountStateHolderNotifier>)notifier;
29
30 - (BOOL)persistNewEgoPeerID:(NSString*)peerID error:(NSError**)error;
31 - (NSString * _Nullable)getEgoPeerID:(NSError **)error;
32
33 - (BOOL)persistNewTrustState:(OTAccountMetadataClassC_TrustState)newState
34 error:(NSError**)error;
35
36 - (BOOL)persistNewEpoch:(uint64_t)epoch error:(NSError**)error;
37
38 - (BOOL)persistAccountChanges:(OTAccountMetadataClassC* (^)(OTAccountMetadataClassC* metadata))makeChanges
39 error:(NSError**)error;
40
41 - (BOOL)_onqueuePersistAccountChanges:(OTAccountMetadataClassC* (^)(OTAccountMetadataClassC* metadata))makeChanges
42 error:(NSError**)error;
43
44 - (NSDate *)lastHealthCheckupDate:(NSError * _Nullable *)error;
45 - (BOOL)persistLastHealthCheck:(NSDate*)lastCheck error:(NSError**)error;
46
47 - (OTAccountMetadataClassC_AttemptedAJoinState)fetchPersistedJoinAttempt:(NSError * _Nullable *)error;
48 - (BOOL)persistOctagonJoinAttempt:(OTAccountMetadataClassC_AttemptedAJoinState)attempt error:(NSError**)error;
49
50 @end
51
52 NS_ASSUME_NONNULL_END