]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CloudKitDependencies.h
Security-59306.140.5.tar.gz
[apple/security.git] / keychain / ckks / CloudKitDependencies.h
1 /*
2 * Copyright (c) 2016 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 #ifndef CloudKitDependencies_h
25 #define CloudKitDependencies_h
26
27 #import <ApplePushService/ApplePushService.h>
28 #import <CloudKit/CloudKit.h>
29 #import <Foundation/Foundation.h>
30 #import <Foundation/NSDistributedNotificationCenter.h>
31
32 NS_ASSUME_NONNULL_BEGIN
33
34 /* CKModifyRecordZonesOperation */
35 @protocol CKKSModifyRecordZonesOperation <NSObject>
36 + (instancetype)alloc;
37 - (instancetype)initWithRecordZonesToSave:(nullable NSArray<CKRecordZone*>*)recordZonesToSave
38 recordZoneIDsToDelete:(nullable NSArray<CKRecordZoneID*>*)recordZoneIDsToDelete;
39
40 @property (nonatomic, strong, nullable) CKDatabase* database;
41 @property (nonatomic, copy, nullable) NSArray<CKRecordZone*>* recordZonesToSave;
42 @property (nonatomic, copy, nullable) NSArray<CKRecordZoneID*>* recordZoneIDsToDelete;
43 @property NSOperationQueuePriority queuePriority;
44 @property NSQualityOfService qualityOfService;
45 @property (nonatomic, strong, nullable) CKOperationGroup* group;
46 @property (nonatomic, copy, null_resettable) CKOperationConfiguration *configuration;
47
48 @property (nonatomic, copy, nullable) void (^modifyRecordZonesCompletionBlock)
49 (NSArray<CKRecordZone*>* _Nullable savedRecordZones, NSArray<CKRecordZoneID*>* _Nullable deletedRecordZoneIDs, NSError* _Nullable operationError);
50
51 @end
52
53 @interface CKModifyRecordZonesOperation (SecCKKSModifyRecordZonesOperation) <CKKSModifyRecordZonesOperation>
54 ;
55 @end
56
57 /* CKModifySubscriptionsOperation */
58 @protocol CKKSModifySubscriptionsOperation <NSObject>
59 + (instancetype)alloc;
60 - (instancetype)initWithSubscriptionsToSave:(nullable NSArray<CKSubscription*>*)subscriptionsToSave
61 subscriptionIDsToDelete:(nullable NSArray<NSString*>*)subscriptionIDsToDelete;
62
63 @property (nonatomic, strong, nullable) CKDatabase* database;
64 @property (nonatomic, copy, nullable) NSArray<CKSubscription*>* subscriptionsToSave;
65 @property (nonatomic, copy, nullable) NSArray<NSString*>* subscriptionIDsToDelete;
66 @property NSOperationQueuePriority queuePriority;
67 @property NSQualityOfService qualityOfService;
68 @property (nonatomic, strong, nullable) CKOperationGroup* group;
69 @property (nonatomic, copy, null_resettable) CKOperationConfiguration *configuration;
70
71 @property (nonatomic, copy, nullable) void (^modifySubscriptionsCompletionBlock)
72 (NSArray<CKSubscription*>* _Nullable savedSubscriptions, NSArray<NSString*>* _Nullable deletedSubscriptionIDs, NSError* _Nullable operationError);
73 @end
74
75 @interface CKModifySubscriptionsOperation (SecCKKSModifySubscriptionsOperation) <CKKSModifySubscriptionsOperation>
76 ;
77 @end
78
79 /* CKFetchRecordZoneChangesOperation */
80 @protocol CKKSFetchRecordZoneChangesOperation <NSObject>
81 + (instancetype)alloc;
82 - (instancetype)initWithRecordZoneIDs:(NSArray<CKRecordZoneID*>*)recordZoneIDs
83 configurationsByRecordZoneID:(nullable NSDictionary<CKRecordZoneID*, CKFetchRecordZoneChangesConfiguration*>*)configurationsByRecordZoneID;
84
85 @property (nonatomic, strong, nullable) CKDatabase *database;
86 @property (nonatomic, copy, nullable) NSArray<CKRecordZoneID*>* recordZoneIDs;
87 @property (nonatomic, copy, nullable) NSDictionary<CKRecordZoneID*, CKFetchRecordZoneChangesConfiguration*>* configurationsByRecordZoneID;
88
89 @property (nonatomic, assign) BOOL fetchAllChanges;
90 @property (nonatomic, copy, nullable) void (^recordChangedBlock)(CKRecord* record);
91 @property (nonatomic, copy, nullable) void (^recordWithIDWasDeletedBlock)(CKRecordID* recordID, NSString* recordType);
92 @property (nonatomic, copy, nullable) void (^recordZoneChangeTokensUpdatedBlock)
93 (CKRecordZoneID* recordZoneID, CKServerChangeToken* _Nullable serverChangeToken, NSData* _Nullable clientChangeTokenData);
94 @property (nonatomic, copy, nullable) void (^recordZoneFetchCompletionBlock)(CKRecordZoneID* recordZoneID,
95 CKServerChangeToken* _Nullable serverChangeToken,
96 NSData* _Nullable clientChangeTokenData,
97 BOOL moreComing,
98 NSError* _Nullable recordZoneError);
99 @property (nonatomic, copy, nullable) void (^fetchRecordZoneChangesCompletionBlock)(NSError* _Nullable operationError);
100
101 @property (nonatomic, strong, nullable) CKOperationGroup* group;
102 @property (nonatomic, copy, null_resettable) CKOperationConfiguration *configuration;
103
104 @property (nonatomic, copy) NSString *operationID;
105 @property (nonatomic, readonly, strong, nullable) CKOperationConfiguration *resolvedConfiguration;
106 @end
107
108 @interface CKFetchRecordZoneChangesOperation () <CKKSFetchRecordZoneChangesOperation>
109 @end
110
111 /* CKFetchRecordsOperation */
112 @protocol CKKSFetchRecordsOperation <NSObject>
113 + (instancetype)alloc;
114 - (instancetype)init;
115 - (instancetype)initWithRecordIDs:(NSArray<CKRecordID*>*)recordIDs;
116
117 @property (nonatomic, strong, nullable) CKDatabase *database;
118 @property (nonatomic, copy, nullable) NSArray<CKRecordID*>* recordIDs;
119 @property (nonatomic, copy, nullable) NSArray<NSString*>* desiredKeys;
120 @property (nonatomic, copy, nullable) CKOperationConfiguration* configuration;
121 @property (nonatomic, copy, nullable) void (^perRecordProgressBlock)(CKRecordID* recordID, double progress);
122 @property (nonatomic, copy, nullable) void (^perRecordCompletionBlock)
123 (CKRecord* _Nullable record, CKRecordID* _Nullable recordID, NSError* _Nullable error);
124 @property (nonatomic, copy, nullable) void (^fetchRecordsCompletionBlock)
125 (NSDictionary<CKRecordID*, CKRecord*>* _Nullable recordsByRecordID, NSError* _Nullable operationError);
126 @end
127
128 @interface CKFetchRecordsOperation () <CKKSFetchRecordsOperation>
129 @end
130
131 /* CKQueryOperation */
132
133 @protocol CKKSQueryOperation <NSObject>
134 + (instancetype)alloc;
135 - (instancetype)initWithQuery:(CKQuery*)query;
136 //Not implemented: - (instancetype)initWithCursor:(CKQueryCursor *)cursor;
137
138 @property (nonatomic, copy, nullable) CKQuery* query;
139 @property (nonatomic, copy, nullable) CKQueryCursor* cursor;
140
141 @property (nonatomic, copy, nullable) CKRecordZoneID* zoneID;
142 @property (nonatomic, assign) NSUInteger resultsLimit;
143 @property (nonatomic, copy, nullable) NSArray<NSString*>* desiredKeys;
144
145 @property (nonatomic, copy, nullable) void (^recordFetchedBlock)(CKRecord* record);
146 @property (nonatomic, copy, nullable) void (^queryCompletionBlock)(CKQueryCursor* _Nullable cursor, NSError* _Nullable operationError);
147 @end
148
149 @interface CKQueryOperation () <CKKSQueryOperation>
150 @end
151
152 /* APSConnection */
153 @protocol OctagonAPSConnection <NSObject>
154 + (instancetype)alloc;
155 - (id)initWithEnvironmentName:(NSString*)environmentName
156 namedDelegatePort:(NSString*)namedDelegatePort
157 queue:(dispatch_queue_t)queue;
158
159 - (void)setEnabledTopics:(NSArray<NSString *> *)enabledTopics;
160 - (void)setDarkWakeTopics:(NSArray<NSString *> *)darkWakeTopics;
161
162 @property (nonatomic, readwrite, assign) id<APSConnectionDelegate> delegate;
163 @end
164
165 @interface APSConnection (SecOctagonAPSConnection) <OctagonAPSConnection>
166 @end
167
168 /* NSNotificationCenter */
169 @protocol CKKSNSNotificationCenter <NSObject>
170 + (instancetype)defaultCenter;
171 - (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject;
172 - (void)removeObserver:(id)observer;
173 @end
174 @interface NSNotificationCenter (CKKSMock) <CKKSNSNotificationCenter>
175 @end
176
177 @protocol CKKSNSDistributedNotificationCenter <NSObject>
178 + (instancetype)defaultCenter;
179 - (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject;
180 - (void)removeObserver:(id)observer;
181 - (void)postNotificationName:(NSNotificationName)name object:(nullable NSString *)object userInfo:(nullable NSDictionary *)userInfo options:(NSDistributedNotificationOptions)options;
182 @end
183
184 @interface NSDistributedNotificationCenter (CKKSMock) <CKKSNSDistributedNotificationCenter>
185 @end
186
187 /* Since CKDatabase doesn't share any types with NSOperationQueue, tell the type system about addOperation */
188 @protocol CKKSOperationQueue <NSObject>
189 - (void)addOperation:(NSOperation*)operation;
190 @end
191
192 @interface CKDatabase () <CKKSOperationQueue>
193 @end
194
195 @interface NSOperationQueue () <CKKSOperationQueue>
196 @end
197
198 NS_ASSUME_NONNULL_END
199
200 #endif /* CloudKitDependencies_h */