1/* 2 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24// 25// CKDKVSProxy.h 26// ckd-xpc 27 28#import <Foundation/Foundation.h> 29#import <dispatch/queue.h> 30#import <xpc/xpc.h> 31 32#import <utilities/debugging.h> 33 34#import "SOSCloudKeychainConstants.h" 35#import "SOSCloudKeychainClient.h" 36 37#define XPROXYSCOPE "proxy" 38 39@interface UbiqitousKVSProxy : NSObject 40{ 41 id currentiCloudToken; 42 CloudItemsChangedBlock itemsChangedCallback; 43 int callbackMethod; 44} 45 46@property (retain, nonatomic) NSDictionary *keyParameterKeys; 47@property (retain, nonatomic) NSDictionary *circleKeys; 48@property (retain, nonatomic) NSDictionary *messageKeys; 49 50@property (retain, nonatomic) NSMutableSet *alwaysKeys; 51@property (retain, nonatomic) NSMutableSet *firstUnlockKeys; 52@property (retain, nonatomic) NSMutableSet *unlockedKeys; 53@property (retain, nonatomic) NSMutableSet *pendingKeys; 54@property (retain, nonatomic) NSMutableSet *shadowPendingKeys; 55@property (atomic) bool syncWithPeersPending; 56@property (atomic) bool shadowSyncWithPeersPending; 57@property (atomic) bool inCallout; 58@property (atomic) bool oldInCallout; 59@property (atomic) bool unlockedSinceBoot; 60@property (atomic) bool isLocked; 61@property (atomic) bool seenKVSStoreChange; 62@property (atomic) bool ensurePeerRegistration; 63@property (atomic) bool shadowEnsurePeerRegistration; 64@property (atomic) dispatch_time_t nextFreshnessTime; 65 66@property (atomic) dispatch_source_t syncTimer; 67@property (atomic) bool syncTimerScheduled; 68@property (atomic) dispatch_time_t deadline; 69@property (atomic) dispatch_time_t lastSyncTime; 70@property (atomic) dispatch_queue_t calloutQueue; 71@property (atomic) dispatch_queue_t freshParamsQueue; 72 73+ (UbiqitousKVSProxy *) sharedKVSProxy; 74- (NSString *)description; 75- (id)init; 76- (void)streamEvent:(xpc_object_t)notification; 77- (void)setItemsChangedBlock:(CloudItemsChangedBlock)itemsChangedBlock; 78 79- (void)setObject:(id)obj forKey:(id)key; 80- (id)get:(id)key; 81- (NSDictionary *)getAll; 82- (void)requestSynchronization:(bool)force; 83- (void)waitForSynchronization:(NSArray *)keys handler:(void (^)(NSDictionary *values, NSError *err))handler; 84- (void)clearStore; 85- (void)setObjectsFromDictionary:(NSDictionary *)values; 86- (void)removeObjectForKey:(NSString *)keyToRemove; 87- (void)processAllItems; 88- (void)requestSyncWithAllPeers; 89- (void)requestEnsurePeerRegistration; 90 91- (NSUbiquitousKeyValueStore *)cloudStore; 92 93-(void)registerAtTimeKeys:(NSDictionary*)keyparms; 94 95- (NSSet*) keysForCurrentLockState; 96- (void) intersectWithCurrentLockState: (NSMutableSet*) set; 97 98- (NSMutableSet*) pendKeysAndGetNewlyPended: (NSSet*) keysToPend; 99 100- (NSMutableSet*) pendingKeysForCurrentLockState; 101- (NSMutableSet*) pendKeysAndGetPendingForCurrentLockState: (NSSet*) startingSet; 102 103- (void) processPendingKeysForCurrentLockState; 104 105- (void)registerKeys: (NSDictionary*)keys; 106 107- (NSDictionary *)localNotification:(NSDictionary *)localNotificationDict outFlags:(int64_t *)outFlags; 108 109- (void)processKeyChangedEvent:(NSDictionary *)keysChangedInCloud; 110- (NSMutableDictionary *)copyValues:(NSSet *)keysOfInterest; 111 112- (void) doAfterFlush: (dispatch_block_t) block; 113 114- (void) calloutWith: (void(^)(NSSet *pending, bool syncWithPeersPending, bool ensurePeerRegistration, dispatch_queue_t queue, void(^done)(NSSet *handledKeys, bool handledSyncWithPeers, bool handledEnsurePeerRegistration))) callout; 115- (void) sendKeysCallout: (NSSet *(^)(NSSet* pending, NSError **error)) handleKeys; 116 117 118 119@end 120