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 */ 42SOSPeerRef SOSPeerCreateWithEngine(SOSEngineRef engine, CFStringRef peer_id); 43void SOSPeerMarkDigestsInUse(SOSPeerRef peer, struct SOSDigestVector *mdInUse); 44bool SOSPeerDidReceiveRemovalsAndAdditions(SOSPeerRef peer, SOSManifestRef absentFromRemote, SOSManifestRef additionsFromRemote, 45 SOSManifestRef local, CFErrorRef *error); 46bool SOSPeerDidReceiveConfirmedManifest(SOSPeerRef peer, SOSManifestRef confirmed, SOSManifestRef local, CFErrorRef *error); 47bool SOSPeerDataSourceWillCommit(SOSPeerRef peer, SOSDataSourceTransactionSource source, SOSManifestRef removals, SOSManifestRef additions, CFErrorRef *error); 48 49/* Constructor called by Account */ 50SOSPeerRef SOSPeerCreate(SOSEngineRef engine, SOSPeerInfoRef peerInfo, CFErrorRef *error); 51 52/* For testing, doesn't OTR encode and uses static ID for self */ 53SOSPeerRef SOSPeerCreateSimple(SOSEngineRef engine, CFStringRef peer_id, CFIndex version, CFErrorRef *error); 54 55// 56// 57// 58 59CFIndex SOSPeerGetVersion(SOSPeerRef peer); 60CFStringRef SOSPeerGetID(SOSPeerRef peer); 61bool SOSPeersEqual(SOSPeerRef peerA, SOSPeerRef peerB); 62SOSCoderRef SOSPeerGetCoder(SOSPeerRef peer); 63void SOSPeerSetCoder(SOSPeerRef peer, SOSCoderRef coder); 64 65uint64_t SOSPeerNextSequenceNumber(SOSPeerRef peer); 66uint64_t SOSPeerGetMessageVersion(SOSPeerRef peer); 67 68// 69// MARK: State tracking helpers 70// 71 72#if 0 73bool SOSPeerJoinRequest(SOSPeerRef peer); 74void SOSPeerSetJoinRequest(SOSPeerRef peer, bool joinRequest); 75 76bool SOSPeerShouldRequestObjects(SOSPeerRef peer); 77void SOSPeerSetShouldRequestObjects(SOSPeerRef peer, bool requestObjects); 78 79bool SOSPeerSkipHello(SOSPeerRef peer); 80void SOSPeerSetSkipHello(SOSPeerRef peer, bool skipHello); 81 82// The last manifestDigest peer received couldn't be matched to a known manifest 83bool SOSPeerReceivedUnknownManifest(SOSPeerRef peer); 84void SOSPeerSetReceivedUnknownManifest(SOSPeerRef peer, bool unknownManifest); 85#endif 86 87 88// Return true if the peer is ready to transmit data. 89void SOSPeerDidConnect(SOSPeerRef peer); 90bool SOSPeerMustSendMessage(SOSPeerRef peer); 91void SOSPeerSetMustSendMessage(SOSPeerRef peer, bool must); 92 93bool SOSPeerSendObjects(SOSPeerRef peer); 94void SOSPeerSetSendObjects(SOSPeerRef peer, bool sendObjects); 95SOSEngineRef SOSPeerGetEngine(SOSPeerRef peer); 96 97SOSManifestRef SOSPeerGetProposedManifest(SOSPeerRef peer); 98SOSManifestRef SOSPeerGetConfirmedManifest(SOSPeerRef peer); 99void SOSPeerSetConfirmedManifest(SOSPeerRef peer, SOSManifestRef confirmed); 100void SOSPeerAddProposedManifest(SOSPeerRef peer, SOSManifestRef pending); 101void SOSPeerSetProposedManifest(SOSPeerRef peer, SOSManifestRef pending); 102void SOSPeerAddLocalManifest(SOSPeerRef peer, SOSManifestRef local); 103SOSManifestRef SOSPeerGetPendingObjects(SOSPeerRef peer); 104void SOSPeerSetPendingObjects(SOSPeerRef peer, SOSManifestRef pendingObjects); 105SOSManifestRef SOSPeerGetPendingDeletes(SOSPeerRef peer); 106void SOSPeerSetPendingDeletes(SOSPeerRef peer, SOSManifestRef pendingDeletes); 107 108SOSManifestRef SOSPeerGetPendingObjects(SOSPeerRef peer); 109 110__END_DECLS 111 112#endif /* !_SOSPEER_H_ */ 113