]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/CloudKeychainProxy/CKDKVSProxy.h
Security-57337.50.23.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / CloudKeychainProxy / CKDKVSProxy.h
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 #import <IDS/IDS.h>
32
33 #import <utilities/debugging.h>
34
35 #import "SOSCloudKeychainConstants.h"
36 #import "SOSCloudKeychainClient.h"
37
38 #define XPROXYSCOPE "proxy"
39
40 @interface UbiqitousKVSProxy : NSObject
41 {
42 id currentiCloudToken;
43 CloudItemsChangedBlock itemsChangedCallback;
44 int callbackMethod;
45 }
46
47 @property (retain, nonatomic) NSDictionary *keyParameterKeys;
48 @property (retain, nonatomic) NSDictionary *circleKeys;
49 @property (retain, nonatomic) NSDictionary *messageKeys;
50
51 @property (retain, nonatomic) NSMutableSet *alwaysKeys;
52 @property (retain, nonatomic) NSMutableSet *firstUnlockKeys;
53 @property (retain, nonatomic) NSMutableSet *unlockedKeys;
54 @property (retain, nonatomic) NSMutableSet *pendingKeys;
55 @property (retain, nonatomic) NSMutableSet *shadowPendingKeys;
56 @property (retain, nonatomic) NSString *dsid;
57
58 @property (atomic) bool syncWithPeersPending;
59 @property (atomic) bool shadowSyncWithPeersPending;
60 @property (atomic) bool inCallout;
61 @property (atomic) bool oldInCallout;
62 @property (atomic) bool unlockedSinceBoot;
63 @property (atomic) bool isLocked;
64 @property (atomic) bool seenKVSStoreChange;
65 @property (atomic) bool ensurePeerRegistration;
66 @property (atomic) bool shadowEnsurePeerRegistration;
67 @property (atomic) dispatch_time_t nextFreshnessTime;
68
69 @property (atomic) dispatch_source_t syncTimer;
70 @property (atomic) bool syncTimerScheduled;
71 @property (atomic) dispatch_time_t deadline;
72 @property (atomic) dispatch_time_t lastSyncTime;
73 @property (atomic) dispatch_queue_t calloutQueue;
74 @property (atomic) dispatch_queue_t freshParamsQueue;
75
76 @property (atomic) dispatch_queue_t ckdkvsproxy_queue;
77 @property (atomic) dispatch_source_t penaltyTimer;
78 @property (atomic) bool penaltyTimerScheduled;
79 @property (retain, atomic) NSMutableDictionary *monitor;
80 @property (retain, atomic) NSDictionary *queuedMessages;
81
82 + (UbiqitousKVSProxy *) sharedKVSProxy;
83 - (NSString *)description;
84 - (id)init;
85 - (void)streamEvent:(xpc_object_t)notification;
86 - (void)setItemsChangedBlock:(CloudItemsChangedBlock)itemsChangedBlock;
87
88 - (void)setObject:(id)obj forKey:(id)key;
89 - (id)get:(id)key;
90 - (NSDictionary *)getAll;
91 - (void)requestSynchronization:(bool)force;
92 - (void)waitForSynchronization:(NSArray *)keys handler:(void (^)(NSDictionary *values, NSError *err))handler;
93 - (void)clearStore;
94 - (void)setObjectsFromDictionary:(NSDictionary *)values;
95 - (void)removeObjectForKey:(NSString *)keyToRemove;
96 - (void)processAllItems;
97 - (void)requestSyncWithAllPeers;
98 - (void)requestEnsurePeerRegistration;
99
100 - (NSUbiquitousKeyValueStore *)cloudStore;
101
102 -(void)registerAtTimeKeys:(NSDictionary*)keyparms;
103
104 - (NSSet*) keysForCurrentLockState;
105 - (void) intersectWithCurrentLockState: (NSMutableSet*) set;
106
107 - (NSMutableSet*) pendKeysAndGetNewlyPended: (NSSet*) keysToPend;
108
109 - (NSMutableSet*) pendingKeysForCurrentLockState;
110 - (NSMutableSet*) pendKeysAndGetPendingForCurrentLockState: (NSSet*) startingSet;
111
112 - (void) processPendingKeysForCurrentLockState;
113
114 - (void)registerKeys: (NSDictionary*)keys;
115
116 - (NSDictionary *)localNotification:(NSDictionary *)localNotificationDict outFlags:(int64_t *)outFlags;
117
118 - (void)processKeyChangedEvent:(NSDictionary *)keysChangedInCloud;
119 - (NSMutableDictionary *)copyValues:(NSSet *)keysOfInterest;
120
121 - (void) doAfterFlush: (dispatch_block_t) block;
122 - (void) calloutWith: (void(^)(NSSet *pending, bool syncWithPeersPending, bool ensurePeerRegistration, dispatch_queue_t queue, void(^done)(NSSet *handledKeys, bool handledSyncWithPeers, bool handledEnsurePeerRegistration))) callout;
123 - (void) sendKeysCallout: (NSSet *(^)(NSSet* pending, NSError **error)) handleKeys;
124
125 - (void)recordWriteToKVS:(NSDictionary *)values;
126 - (NSDictionary*)recordHaltedValuesAndReturnValuesToSafelyWrite:(NSDictionary *)values;
127
128 @end