2 #import <Foundation/Foundation.h>
3 #import <dispatch/dispatch.h>
5 #import "keychain/ot/proto/generated_source/OTAccountMetadataClassC.h"
7 extern NSString
* _Nonnull OTCuttlefishContextErrorDomain
;
8 typedef NS_ENUM(uint32_t, OTCuttlefishContextErrors
) {
9 OTCCNoExistingPeerID
= 0,
12 NS_ASSUME_NONNULL_BEGIN
14 @protocol OTCuttlefishAccountStateHolderNotifier
15 - (void)accountStateUpdated
:(OTAccountMetadataClassC
*)newState from
:(OTAccountMetadataClassC
*)oldState
;
18 @interface OTCuttlefishAccountStateHolder
: NSObject
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
;
25 - (OTAccountMetadataClassC
* _Nullable
)loadOrCreateAccountMetadata
:(NSError
**)error
;
26 - (OTAccountMetadataClassC
* _Nullable
)_onqueueLoadOrCreateAccountMetadata
:(NSError
**)error
;
28 - (void)registerNotification
:(id
<OTCuttlefishAccountStateHolderNotifier
>)notifier
;
30 - (BOOL
)persistNewEgoPeerID
:(NSString
*)peerID error
:(NSError
**)error
;
31 - (NSString
* _Nullable
)getEgoPeerID
:(NSError
**)error
;
33 - (BOOL
)persistNewTrustState
:(OTAccountMetadataClassC_TrustState
)newState
34 error
:(NSError
**)error
;
36 - (BOOL
)persistNewEpoch
:(uint64_t)epoch error
:(NSError
**)error
;
38 - (BOOL
)persistAccountChanges
:(OTAccountMetadataClassC
* (^)(OTAccountMetadataClassC
* metadata
))makeChanges
39 error
:(NSError
**)error
;
41 - (BOOL
)_onqueuePersistAccountChanges
:(OTAccountMetadataClassC
* (^)(OTAccountMetadataClassC
* metadata
))makeChanges
42 error
:(NSError
**)error
;
44 - (NSDate
*)lastHealthCheckupDate
:(NSError
* _Nullable
*)error
;
45 - (BOOL
)persistLastHealthCheck
:(NSDate
*)lastCheck error
:(NSError
**)error
;
47 - (OTAccountMetadataClassC_AttemptedAJoinState
)fetchPersistedJoinAttempt
:(NSError
* _Nullable
*)error
;
48 - (BOOL
)persistOctagonJoinAttempt
:(OTAccountMetadataClassC_AttemptedAJoinState
)attempt error
:(NSError
**)error
;