1/* 2 * Copyright (c) 2012 Apple Computer, 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@property (retain, nonatomic) NSString *myID; 46@property (retain, nonatomic) NSArray *keysToRead; 47@property (retain, nonatomic) NSArray *keysToWrite; 48@property (retain, nonatomic) NSArray *keysReadWrite; 49 50@property (retain, nonatomic) NSSet *alwaysKeys; 51@property (retain, nonatomic) NSSet *firstUnlockKeys; 52@property (retain, nonatomic) NSSet *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 unlockedSinceBoot; 59@property (atomic) bool isLocked; 60@property (atomic) bool seenKVSStoreChange; 61 62@property (atomic) dispatch_source_t syncTimer; 63@property (atomic) bool syncTimerScheduled; 64@property (atomic) dispatch_time_t deadline; 65@property (atomic) dispatch_time_t lastSyncTime; 66 67+ (UbiqitousKVSProxy *) sharedKVSProxy; 68- (NSString *)description; 69- (id)init; 70- (void)streamEvent:(xpc_object_t)notification; 71- (void)setItemsChangedBlock:(CloudItemsChangedBlock)itemsChangedBlock; 72 73- (void)setObject:(id)obj forKey:(id)key; 74- (id)get:(id)key; 75- (NSDictionary *)getAll; 76- (void)requestSynchronization:(bool)force; 77- (void)waitForSynchronization:(NSArray *)keys handler:(void (^)(NSDictionary *values, NSError *err))handler; 78- (void)clearStore; 79- (void)setObjectsFromDictionary:(NSDictionary *)values; 80- (void)removeObjectForKey:(NSString *)keyToRemove; 81- (void)processAllItems; 82- (void)requestSyncWithAllPeers; 83 84- (NSUbiquitousKeyValueStore *)cloudStore; 85 86- (NSSet*) keysForCurrentLockState; 87- (NSSet*) filterKeySetWithLockState: (NSSet*) startingSet; 88- (NSDictionary *)registerKeysAndGet:(BOOL)getNewKeysOnly always:(NSArray *)keysToRegister reqFirstUnlock:(NSArray *)reqFirstUnlock reqUnlocked:(NSArray *)reqUnlocked; 89 90- (NSDictionary *)localNotification:(NSDictionary *)localNotificationDict outFlags:(int64_t *)outFlags; 91- (void)processKeyChangedEvent:(NSDictionary *)keysChangedInCloud; 92- (NSMutableDictionary *)copyChangedValues:(NSSet *)keysOfInterest; 93- (void)setParams:(NSDictionary *)paramsDict; 94 95@end 96