2 * Copyright (c) 2016 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef CloudKitDependencies_h
25 #define CloudKitDependencies_h
27 #import <ApplePushService/ApplePushService.h>
28 #import <CloudKit/CloudKit.h>
29 #import <Foundation/Foundation.h>
30 #import <Foundation/NSDistributedNotificationCenter.h>
32 NS_ASSUME_NONNULL_BEGIN
34 /* CKModifyRecordZonesOperation */
35 @protocol CKKSModifyRecordZonesOperation
<NSObject
>
36 + (instancetype
)alloc
;
37 - (instancetype
)initWithRecordZonesToSave
:(nullable NSArray
<CKRecordZone
*>*)recordZonesToSave
38 recordZoneIDsToDelete
:(nullable NSArray
<CKRecordZoneID
*>*)recordZoneIDsToDelete
;
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
;
48 @
property (nonatomic
, copy
, nullable
) void (^modifyRecordZonesCompletionBlock
)
49 (NSArray
<CKRecordZone
*>* _Nullable savedRecordZones
, NSArray
<CKRecordZoneID
*>* _Nullable deletedRecordZoneIDs
, NSError
* _Nullable operationError
);
53 @interface
CKModifyRecordZonesOperation (SecCKKSModifyRecordZonesOperation
) <CKKSModifyRecordZonesOperation
>
57 /* CKModifySubscriptionsOperation */
58 @protocol CKKSModifySubscriptionsOperation
<NSObject
>
59 + (instancetype
)alloc
;
60 - (instancetype
)initWithSubscriptionsToSave
:(nullable NSArray
<CKSubscription
*>*)subscriptionsToSave
61 subscriptionIDsToDelete
:(nullable NSArray
<NSString
*>*)subscriptionIDsToDelete
;
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
;
71 @
property (nonatomic
, copy
, nullable
) void (^modifySubscriptionsCompletionBlock
)
72 (NSArray
<CKSubscription
*>* _Nullable savedSubscriptions
, NSArray
<NSString
*>* _Nullable deletedSubscriptionIDs
, NSError
* _Nullable operationError
);
75 @interface
CKModifySubscriptionsOperation (SecCKKSModifySubscriptionsOperation
) <CKKSModifySubscriptionsOperation
>
79 /* CKFetchRecordZoneChangesOperation */
80 @protocol CKKSFetchRecordZoneChangesOperation
<NSObject
>
81 + (instancetype
)alloc
;
82 - (instancetype
)initWithRecordZoneIDs
:(NSArray
<CKRecordZoneID
*>*)recordZoneIDs
83 configurationsByRecordZoneID
:(nullable NSDictionary
<CKRecordZoneID
*, CKFetchRecordZoneChangesConfiguration
*>*)configurationsByRecordZoneID
;
85 @
property (nonatomic
, strong
, nullable
) CKDatabase
*database
;
86 @
property (nonatomic
, copy
, nullable
) NSArray
<CKRecordZoneID
*>* recordZoneIDs
;
87 @
property (nonatomic
, copy
, nullable
) NSDictionary
<CKRecordZoneID
*, CKFetchRecordZoneChangesConfiguration
*>* configurationsByRecordZoneID
;
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
,
98 NSError
* _Nullable recordZoneError
);
99 @
property (nonatomic
, copy
, nullable
) void (^fetchRecordZoneChangesCompletionBlock
)(NSError
* _Nullable operationError
);
101 @
property (nonatomic
, strong
, nullable
) CKOperationGroup
* group
;
102 @
property (nonatomic
, copy
, null_resettable
) CKOperationConfiguration
*configuration
;
104 @
property (nonatomic
, copy
) NSString
*operationID
;
105 @
property (nonatomic
, readonly
, strong
, nullable
) CKOperationConfiguration
*resolvedConfiguration
;
108 @interface
CKFetchRecordZoneChangesOperation () <CKKSFetchRecordZoneChangesOperation
>
111 /* CKFetchRecordsOperation */
112 @protocol CKKSFetchRecordsOperation
<NSObject
>
113 + (instancetype
)alloc
;
114 - (instancetype
)init
;
115 - (instancetype
)initWithRecordIDs
:(NSArray
<CKRecordID
*>*)recordIDs
;
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
);
128 @interface
CKFetchRecordsOperation () <CKKSFetchRecordsOperation
>
131 /* CKQueryOperation */
133 @protocol CKKSQueryOperation
<NSObject
>
134 + (instancetype
)alloc
;
135 - (instancetype
)initWithQuery
:(CKQuery
*)query
;
136 //Not implemented: - (instancetype)initWithCursor:(CKQueryCursor *)cursor;
138 @
property (nonatomic
, copy
, nullable
) CKQuery
* query
;
139 @
property (nonatomic
, copy
, nullable
) CKQueryCursor
* cursor
;
141 @
property (nonatomic
, copy
, nullable
) CKRecordZoneID
* zoneID
;
142 @
property (nonatomic
, assign
) NSUInteger resultsLimit
;
143 @
property (nonatomic
, copy
, nullable
) NSArray
<NSString
*>* desiredKeys
;
145 @
property (nonatomic
, copy
, nullable
) void (^recordFetchedBlock
)(CKRecord
* record
);
146 @
property (nonatomic
, copy
, nullable
) void (^queryCompletionBlock
)(CKQueryCursor
* _Nullable cursor
, NSError
* _Nullable operationError
);
149 @interface
CKQueryOperation () <CKKSQueryOperation
>
153 @protocol OctagonAPSConnection
<NSObject
>
154 + (instancetype
)alloc
;
155 - (id
)initWithEnvironmentName
:(NSString
*)environmentName
156 namedDelegatePort
:(NSString
*)namedDelegatePort
157 queue
:(dispatch_queue_t
)queue
;
159 - (void)setEnabledTopics
:(NSArray
<NSString
*> *)enabledTopics
;
160 - (void)setDarkWakeTopics
:(NSArray
<NSString
*> *)darkWakeTopics
;
162 @
property (nonatomic
, readwrite
, assign
) id
<APSConnectionDelegate
> delegate
;
165 @interface
APSConnection (SecOctagonAPSConnection
) <OctagonAPSConnection
>
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
;
174 @interface
NSNotificationCenter (CKKSMock
) <CKKSNSNotificationCenter
>
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
;
184 @interface
NSDistributedNotificationCenter (CKKSMock
) <CKKSNSDistributedNotificationCenter
>
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
;
192 @interface
CKDatabase () <CKKSOperationQueue
>
195 @interface
NSOperationQueue () <CKKSOperationQueue
>
198 NS_ASSUME_NONNULL_END
200 #endif /* CloudKitDependencies_h */