]> git.saurik.com Git - apple/security.git/blob - Security/sec/SOSCircle/SecureObjectSync/SOSPeer.h
Security-57031.10.10.tar.gz
[apple/security.git] / Security / sec / SOSCircle / SecureObjectSync / SOSPeer.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 /*!
26 @header SOSPeer
27 The functions provided in SOSPeer provide an interface to a
28 secure object syncing peer in a circle
29 */
30
31 #ifndef _SOSPEER_H_
32 #define _SOSPEER_H_
33
34 #include <SecureObjectSync/SOSEngine.h>
35 #include <SecureObjectSync/SOSFullPeerInfo.h>
36 #include <SecureObjectSync/SOSPeerInfo.h>
37 #include <SecureObjectSync/SOSCoder.h>
38
39 __BEGIN_DECLS
40
41 /* Constructor called by Engine */
42 SOSPeerRef SOSPeerCreateWithEngine(SOSEngineRef engine, CFStringRef peer_id);
43 void SOSPeerMarkDigestsInUse(SOSPeerRef peer, struct SOSDigestVector *mdInUse);
44 bool SOSPeerDidReceiveRemovalsAndAdditions(SOSPeerRef peer, SOSManifestRef absentFromRemote, SOSManifestRef additionsFromRemote,
45 SOSManifestRef local, CFErrorRef *error);
46 bool SOSPeerDidReceiveConfirmedManifest(SOSPeerRef peer, SOSManifestRef confirmed, SOSManifestRef local, CFErrorRef *error);
47 bool SOSPeerDataSourceWillCommit(SOSPeerRef peer, SOSDataSourceTransactionSource source, SOSManifestRef removals, SOSManifestRef additions, CFErrorRef *error);
48
49 /* Constructor called by Account */
50 SOSPeerRef SOSPeerCreate(SOSEngineRef engine, SOSPeerInfoRef peerInfo, CFErrorRef *error);
51
52 /* For testing, doesn't OTR encode and uses static ID for self */
53 SOSPeerRef SOSPeerCreateSimple(SOSEngineRef engine, CFStringRef peer_id, CFIndex version, CFErrorRef *error);
54
55 //
56 //
57 //
58
59 CFIndex SOSPeerGetVersion(SOSPeerRef peer);
60 CFStringRef SOSPeerGetID(SOSPeerRef peer);
61 bool SOSPeersEqual(SOSPeerRef peerA, SOSPeerRef peerB);
62 SOSCoderRef SOSPeerGetCoder(SOSPeerRef peer);
63 void SOSPeerSetCoder(SOSPeerRef peer, SOSCoderRef coder);
64
65 uint64_t SOSPeerNextSequenceNumber(SOSPeerRef peer);
66 uint64_t SOSPeerGetMessageVersion(SOSPeerRef peer);
67
68 //
69 // MARK: State tracking helpers
70 //
71
72 #if 0
73 bool SOSPeerJoinRequest(SOSPeerRef peer);
74 void SOSPeerSetJoinRequest(SOSPeerRef peer, bool joinRequest);
75
76 bool SOSPeerShouldRequestObjects(SOSPeerRef peer);
77 void SOSPeerSetShouldRequestObjects(SOSPeerRef peer, bool requestObjects);
78
79 bool SOSPeerSkipHello(SOSPeerRef peer);
80 void SOSPeerSetSkipHello(SOSPeerRef peer, bool skipHello);
81
82 // The last manifestDigest peer received couldn't be matched to a known manifest
83 bool SOSPeerReceivedUnknownManifest(SOSPeerRef peer);
84 void SOSPeerSetReceivedUnknownManifest(SOSPeerRef peer, bool unknownManifest);
85 #endif
86
87
88 // Return true if the peer is ready to transmit data.
89 void SOSPeerDidConnect(SOSPeerRef peer);
90 bool SOSPeerMustSendMessage(SOSPeerRef peer);
91 void SOSPeerSetMustSendMessage(SOSPeerRef peer, bool must);
92
93 bool SOSPeerSendObjects(SOSPeerRef peer);
94 void SOSPeerSetSendObjects(SOSPeerRef peer, bool sendObjects);
95 SOSEngineRef SOSPeerGetEngine(SOSPeerRef peer);
96
97 SOSManifestRef SOSPeerGetProposedManifest(SOSPeerRef peer);
98 SOSManifestRef SOSPeerGetConfirmedManifest(SOSPeerRef peer);
99 void SOSPeerSetConfirmedManifest(SOSPeerRef peer, SOSManifestRef confirmed);
100 void SOSPeerAddProposedManifest(SOSPeerRef peer, SOSManifestRef pending);
101 void SOSPeerSetProposedManifest(SOSPeerRef peer, SOSManifestRef pending);
102 void SOSPeerAddLocalManifest(SOSPeerRef peer, SOSManifestRef local);
103 SOSManifestRef SOSPeerGetPendingObjects(SOSPeerRef peer);
104 void SOSPeerSetPendingObjects(SOSPeerRef peer, SOSManifestRef pendingObjects);
105 SOSManifestRef SOSPeerGetPendingDeletes(SOSPeerRef peer);
106 void SOSPeerSetPendingDeletes(SOSPeerRef peer, SOSManifestRef pendingDeletes);
107
108 SOSManifestRef SOSPeerGetPendingObjects(SOSPeerRef peer);
109
110 __END_DECLS
111
112 #endif /* !_SOSPEER_H_ */