#import <Foundation/Foundation.h>
#import <dispatch/queue.h>
#import <xpc/xpc.h>
#import <IDS/IDS.h>
#import <utilities/debugging.h>
#import "SOSCloudKeychainConstants.h"
#import "SOSCloudKeychainClient.h"
#import "CKDStore.h"
#import "CKDAccount.h"
#define XPROXYSCOPE "proxy"
typedef void (^FreshnessResponseBlock)(bool success, NSError *err);
@interface UbiqitousKVSProxy : NSObject
{
id currentiCloudToken;
int callbackMethod;
}
@property (readonly) NSObject<CKDStore>* store;
@property (readonly) NSObject<CKDAccount>* account;
@property (retain, nonatomic) NSMutableSet *alwaysKeys;
@property (retain, nonatomic) NSMutableSet *firstUnlockKeys;
@property (retain, nonatomic) NSMutableSet *unlockedKeys;
@property (atomic) bool unlockedSinceBoot;
@property (atomic) bool isLocked;
@property (atomic) bool seenKVSStoreChange;
@property (retain, nonatomic) NSMutableSet *pendingKeys;
@property (retain, nonatomic) NSMutableSet *shadowPendingKeys;
@property (retain, nonatomic) NSString *dsid;
@property (atomic) bool syncWithPeersPending;
@property (atomic) bool shadowSyncWithPeersPending;
@property (atomic) bool ensurePeerRegistration;
@property (atomic) bool shadowEnsurePeerRegistration;
@property (atomic) bool inCallout;
@property (retain, nonatomic) NSMutableArray<FreshnessResponseBlock> *freshnessCompletions;
@property (atomic) dispatch_time_t nextFreshnessTime;
@property (atomic) dispatch_source_t syncTimer;
@property (atomic) bool syncTimerScheduled;
@property (atomic) dispatch_time_t deadline;
@property (atomic) dispatch_time_t lastSyncTime;
@property (atomic) dispatch_queue_t calloutQueue;
@property (atomic) dispatch_queue_t ckdkvsproxy_queue;
@property (atomic) dispatch_source_t penaltyTimer;
@property (atomic) bool penaltyTimerScheduled;
@property (retain, atomic) NSMutableDictionary *monitor;
@property (retain, atomic) NSDictionary *queuedMessages;
@property (copy, atomic) dispatch_block_t shadowFlushBlock;
+ (UbiqitousKVSProxy *) sharedKVSProxy;
- (NSString *)description;
- (id)init NS_UNAVAILABLE;
- (id)initWithAccount:(NSObject<CKDAccount>*) account
store:(NSObject<CKDStore>*) store NS_DESIGNATED_INITIALIZER;
- (void)clearStore;
- (void)synchronizeStore;
- (id) objectForKey: (NSString*) key;
- (NSDictionary<NSString *, id>*) copyAsDictionary;
- (void)setObjectsFromDictionary:(NSDictionary<NSString*, NSObject*> *)otherDictionary;
- (void)waitForSynchronization:(void (^)(NSDictionary<NSString*, NSObject*> *results, NSError *err))handler;
- (void)storeKeysChanged: (NSSet<NSString*>*) changedKeys initial: (bool) initial;
- (void)storeAccountChanged;
- (void)streamEvent:(xpc_object_t)notification;
- (void)processAllItems;
- (void)requestSyncWithAllPeers;
- (void)requestEnsurePeerRegistration;
- (void)registerAtTimeKeys:(NSDictionary*)keyparms;
- (NSSet*) keysForCurrentLockState;
- (void) intersectWithCurrentLockState: (NSMutableSet*) set;
- (NSMutableSet*) pendKeysAndGetNewlyPended: (NSSet*) keysToPend;
- (NSMutableSet*) pendingKeysForCurrentLockState;
- (NSMutableSet*) pendKeysAndGetPendingForCurrentLockState: (NSSet*) startingSet;
- (void)processPendingKeysForCurrentLockState;
- (void)registerKeys: (NSDictionary*)keys;
- (void)processKeyChangedEvent:(NSDictionary *)keysChangedInCloud;
- (NSMutableDictionary *)copyValues:(NSSet *)keysOfInterest;
- (void) doAfterFlush: (dispatch_block_t) block;
- (void) calloutWith: (void(^)(NSSet *pending, bool syncWithPeersPending, bool ensurePeerRegistration, dispatch_queue_t queue, void(^done)(NSSet *handledKeys, bool handledSyncWithPeers, bool handledEnsurePeerRegistration))) callout;
- (void) sendKeysCallout: (NSSet *(^)(NSSet* pending, NSError **error)) handleKeys;
- (void)recordWriteToKVS:(NSDictionary *)values;
- (NSDictionary*)recordHaltedValuesAndReturnValuesToSafelyWrite:(NSDictionary *)values;
@end