]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/CloudKeychainProxy/CKDKVSProxy.h
Security-57740.1.18.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
74 @property (atomic) dispatch_queue_t ckdkvsproxy_queue;
75 @property (atomic) dispatch_queue_t calloutQueue;
76 @property (atomic) dispatch_queue_t freshParamsQueue;
77
78 @property (atomic) dispatch_source_t penaltyTimer;
79 @property (atomic) bool penaltyTimerScheduled;
80 @property (retain, atomic) NSMutableDictionary *monitor;
81 @property (retain, atomic) NSDictionary *queuedMessages;
82
83 + (UbiqitousKVSProxy *) sharedKVSProxy;
84 - (NSString *)description;
85 - (id)init;
86 - (void)streamEvent:(xpc_object_t)notification;
87 - (void)setItemsChangedBlock:(CloudItemsChangedBlock)itemsChangedBlock;
88
89 - (void)setObject:(id)obj forKey:(id)key;
90 - (id)get:(id)key;
91 - (NSDictionary *)getAll;
92 - (void)requestSynchronization:(bool)force;
93 - (void)waitForSynchronization:(NSArray *)keys handler:(void (^)(NSDictionary *values, NSError *err))handler;
94 - (void)clearStore;
95 - (void)recordWriteToKVS:(NSDictionary *)values;
96 - (NSDictionary*)recordHaltedValuesAndReturnValuesToSafelyWrite:(NSDictionary *)values;
97 - (void)setObjectsFromDictionary:(NSDictionary *)values;
98 - (void)removeObjectForKey:(NSString *)keyToRemove;
99 - (void)processAllItems;
100 - (void)requestSyncWithAllPeers;
101 - (void)requestEnsurePeerRegistration;
102
103 - (NSUbiquitousKeyValueStore *)cloudStore;
104
105 -(void)registerAtTimeKeys:(NSDictionary*)keyparms;
106
107 - (NSSet*) keysForCurrentLockState;
108 - (void) intersectWithCurrentLockState: (NSMutableSet*) set;
109
110 - (NSMutableSet*) pendKeysAndGetNewlyPended: (NSSet*) keysToPend;
111
112 - (NSMutableSet*) pendingKeysForCurrentLockState;
113 - (NSMutableSet*) pendKeysAndGetPendingForCurrentLockState: (NSSet*) startingSet;
114
115 - (void) processPendingKeysForCurrentLockState;
116
117 - (void)registerKeys: (NSDictionary*)keys;
118
119 - (void)processKeyChangedEvent:(NSDictionary *)keysChangedInCloud;
120 - (NSMutableDictionary *)copyValues:(NSSet *)keysOfInterest;
121
122 - (void) doAfterFlush: (dispatch_block_t) block;
123 - (void) calloutWith: (void(^)(NSSet *pending, bool syncWithPeersPending, bool ensurePeerRegistration, dispatch_queue_t queue, void(^done)(NSSet *handledKeys, bool handledSyncWithPeers, bool handledEnsurePeerRegistration))) callout;
124 - (void) sendKeysCallout: (NSSet *(^)(NSSet* pending, NSError **error)) handleKeys;
125
126 @end