]>
Commit | Line | Data |
---|---|---|
5c19dc3a A |
1 | /* |
2 | * Copyright (c) 2015 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 | /*! | |
26 | @header SOSChangeTracker.h - Manifest caching and change propagation. | |
27 | */ | |
28 | ||
29 | #ifndef _SEC_SOSCHANGETRACKER_H_ | |
30 | #define _SEC_SOSCHANGETRACKER_H_ | |
31 | ||
32 | #include <Security/SecureObjectSync/SOSDataSource.h> | |
33 | ||
34 | __BEGIN_DECLS | |
35 | ||
36 | enum { | |
37 | kSOSErrorNotConcreteError = 1042, | |
38 | }; | |
39 | ||
40 | ||
41 | // | |
42 | // Interface to encoding and decoding changes | |
43 | // | |
44 | ||
45 | typedef CFTypeRef SOSChangeRef; | |
46 | ||
47 | static inline void SOSChangesAppendDelete(CFMutableArrayRef changes, CFTypeRef object) { | |
48 | const void *values[] = { object }; | |
49 | SOSChangeRef change = CFArrayCreate(kCFAllocatorDefault, values, array_size(values), &kCFTypeArrayCallBacks); | |
50 | CFArrayAppendValue(changes, change); | |
51 | CFReleaseSafe(change); | |
52 | } | |
53 | ||
54 | static inline void SOSChangesAppendAdd(CFMutableArrayRef changes, CFTypeRef object) { | |
55 | CFArrayAppendValue(changes, object); | |
56 | } | |
57 | ||
58 | // Return the object and return true if it's an add and false if it's a delete. | |
59 | static inline bool SOSChangeGetObject(SOSChangeRef change, CFTypeRef *object) { | |
60 | if (CFGetTypeID(change) == CFArrayGetTypeID()) { | |
61 | assert(CFArrayGetCount(change) == 1); | |
62 | *object = CFArrayGetValueAtIndex(change, 0); | |
63 | return false; | |
64 | } else { | |
65 | *object = change; | |
66 | return true; | |
67 | } | |
68 | } | |
69 | ||
70 | CFDataRef SOSChangeCopyDigest(SOSDataSourceRef dataSource, SOSChangeRef change, bool *isDel, SOSObjectRef *object, CFErrorRef *error); | |
71 | ||
72 | CFStringRef SOSChangeCopyDescription(SOSChangeRef change); | |
73 | ||
74 | CFStringRef SOSChangesCopyDescription(CFArrayRef changes); | |
75 | ||
76 | // | |
77 | // ChangeTracker | |
78 | // | |
79 | ||
80 | typedef struct __OpaqueSOSChangeTracker *SOSChangeTrackerRef; | |
81 | ||
82 | SOSChangeTrackerRef SOSChangeTrackerCreate(CFAllocatorRef allocator, bool isConcrete, CFArrayRef children, CFErrorRef *error); | |
83 | ||
84 | // Change the concreteness of the current ct (a non concrete ct does not support SOSChangeTrackerCopyManifest(). | |
85 | void SOSChangeTrackerSetConcrete(SOSChangeTrackerRef ct, bool isConcrete); | |
86 | ||
87 | typedef bool(^SOSChangeTrackerUpdatesChanges)(SOSChangeTrackerRef ct, SOSEngineRef engine, SOSTransactionRef txn, SOSDataSourceTransactionSource source, SOSDataSourceTransactionPhase phase, CFArrayRef changes, CFErrorRef *error); | |
88 | ||
89 | void SOSChangeTrackerRegisterChangeUpdate(SOSChangeTrackerRef ct, SOSChangeTrackerUpdatesChanges child); | |
90 | ||
91 | typedef bool(^SOSChangeTrackerUpdatesManifests)(SOSChangeTrackerRef ct, SOSEngineRef engine, SOSTransactionRef txn, SOSDataSourceTransactionSource source, SOSDataSourceTransactionPhase phase, SOSManifestRef removals, SOSManifestRef additions, CFErrorRef *error); | |
92 | ||
93 | void SOSChangeTrackerRegisterManifestUpdate(SOSChangeTrackerRef ct, SOSChangeTrackerUpdatesManifests child); | |
94 | ||
95 | // Remove any blocks registered though either SOSChangeTrackerRegisterChangeUpdate or SOSChangeTrackerRegisterManifestUpdate | |
96 | void SOSChangeTrackerResetRegistration(SOSChangeTrackerRef ct); | |
97 | ||
98 | // Set the manifest for this changeTracker, causing it to be updated whenever changes pass by. | |
99 | // Set the manifest to NULL to stop tracking changes (but not forwarding to children). | |
100 | void SOSChangeTrackerSetManifest(SOSChangeTrackerRef ct, SOSManifestRef manifest); | |
101 | ||
102 | // Return a snapshot of the current manifest of this ct. | |
103 | SOSManifestRef SOSChangeTrackerCopyManifest(SOSChangeTrackerRef ct, CFErrorRef *error); | |
104 | ||
105 | // Apply changes to the (cached) manifest, and notify all children accordingly | |
106 | bool SOSChangeTrackerTrackChanges(SOSChangeTrackerRef ct, SOSEngineRef engine, SOSTransactionRef txn, SOSDataSourceTransactionSource source, SOSDataSourceTransactionPhase phase, CFArrayRef changes, CFErrorRef *error); | |
107 | ||
108 | __END_DECLS | |
109 | ||
110 | #endif /* !_SEC_SOSCHANGETRACKER_H_ */ |