2 * Copyright (c) 2012-2014 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@
27 The functions provided in SOSPeer provide an interface to a
28 secure object syncing peer in a circle
34 #include <SecureObjectSync/SOSEngine.h>
35 #include <SecureObjectSync/SOSFullPeerInfo.h>
36 #include <SecureObjectSync/SOSPeerInfo.h>
37 #include <SecureObjectSync/SOSCoder.h>
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
);
49 /* Constructor called by Account */
50 SOSPeerRef
SOSPeerCreate(SOSEngineRef engine
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
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
);
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
);
65 uint64_t SOSPeerNextSequenceNumber(SOSPeerRef peer
);
66 uint64_t SOSPeerGetMessageVersion(SOSPeerRef peer
);
69 // MARK: State tracking helpers
73 bool SOSPeerJoinRequest(SOSPeerRef peer
);
74 void SOSPeerSetJoinRequest(SOSPeerRef peer
, bool joinRequest
);
76 bool SOSPeerShouldRequestObjects(SOSPeerRef peer
);
77 void SOSPeerSetShouldRequestObjects(SOSPeerRef peer
, bool requestObjects
);
79 bool SOSPeerSkipHello(SOSPeerRef peer
);
80 void SOSPeerSetSkipHello(SOSPeerRef peer
, bool skipHello
);
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
);
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
);
93 bool SOSPeerSendObjects(SOSPeerRef peer
);
94 void SOSPeerSetSendObjects(SOSPeerRef peer
, bool sendObjects
);
95 SOSEngineRef
SOSPeerGetEngine(SOSPeerRef peer
);
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
);
108 SOSManifestRef
SOSPeerGetPendingObjects(SOSPeerRef peer
);
112 #endif /* !_SOSPEER_H_ */