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@
26 * SOSCloudKeychainClient.h - Implementation of the transport layer from CKBridge to SOSAccount/SOSCircle
30 @header SOSCloudKeychainClient
31 The functions provided in SOSCloudTransport.h provide an interface
32 from CKBridge to SOSAccount/SOSCircle
35 #ifndef _SOSCLOUDKEYCHAINCLIENT_H_
36 #define _SOSCLOUDKEYCHAINCLIENT_H_
38 #include <CoreFoundation/CFArray.h>
39 #include <CoreFoundation/CFDictionary.h>
40 #include <CoreFoundation/CFError.h>
41 #include <dispatch/dispatch.h>
46 // MARK: ---------- SOSCloudTransport ----------
50 kSOSObjectMallocFailed
= 1,
52 kSOSObjectNotFoundError
= 1,
53 kSOSObjectCantBeConvertedToXPCObject
,
54 kSOSOUnexpectedConnectionEvent
,
56 kSOSOUnexpectedXPCEvent
,
60 typedef CFArrayRef (^CloudItemsChangedBlock
)(CFDictionaryRef values
);
61 typedef void (^CloudKeychainReplyBlock
)(CFDictionaryRef returnedValues
, CFErrorRef error
);
63 /* SOSCloudTransport protocol. */
64 typedef struct SOSCloudTransport
*SOSCloudTransportRef
;
65 struct SOSCloudTransport
67 void (*put
)(SOSCloudTransportRef transport
, CFDictionaryRef valuesToPut
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
68 void (*updateKeys
)(SOSCloudTransportRef transport
, CFDictionaryRef keys
, CFStringRef accountUUID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
70 void (*sendIDSMessage
)(SOSCloudTransportRef transport
, CFDictionaryRef data
, CFStringRef deviceName
, CFStringRef peerID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
71 void (*sendFragmentedIDSMessage
)(SOSCloudTransportRef transport
, CFDictionaryRef data
, CFStringRef deviceName
, CFStringRef peerID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
72 void (*retrieveMessages
) (SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
73 void (*getDeviceID
)(SOSCloudTransportRef transport
, CloudKeychainReplyBlock replyBlock
);
76 void (*get
)(SOSCloudTransportRef transport
, CFArrayRef keysToGet
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
77 void (*getAll
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
78 void (*synchronize
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
79 void (*synchronizeAndWait
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
81 void (*clearAll
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
82 void (*removeObjectForKey
)(SOSCloudTransportRef transport
, CFStringRef keyToRemove
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
84 bool (*hasPendingKey
)(SOSCloudTransportRef transport
, CFStringRef keyName
, CFErrorRef
* error
);
86 void (*requestSyncWithPeers
)(SOSCloudTransportRef transport
, CFArrayRef
/* CFStringRef */ peers
, CFArrayRef
/* CFStringRef */ backupPeers
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
87 bool (*hasPeerSyncPending
)(SOSCloudTransportRef transport
, CFStringRef peerID
, CFErrorRef
* error
);
89 void (*requestEnsurePeerRegistration
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
90 void (*requestPerfCounters
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
91 void (*flush
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
92 const void *itemsChangedBlock
;
93 void (*getIDSDeviceAvailability
)(SOSCloudTransportRef transport
, CFArrayRef ids
, CFStringRef peerID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
94 void (*removeKeys
)(SOSCloudTransportRef transport
, CFArrayRef keys
, CFStringRef accountUUID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
95 void (*counters
)(SOSCloudTransportRef transport
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
99 /* Call this function before calling any other function in this header to provide
100 an alternate transport, the default transport talks to CloudKeychainProxy via xpc. */
101 void SOSCloudKeychainSetTransport(SOSCloudTransportRef transport
);
103 void SOSCloudKeychainGetIDSDeviceID(CloudKeychainReplyBlock replyBlock
);
104 void SOSCloudKeychainSendIDSMessage(CFDictionaryRef message
, CFStringRef deviceName
, CFStringRef peerID
, dispatch_queue_t processQueue
, CFBooleanRef fragmentation
, CloudKeychainReplyBlock replyBlock
);
105 void SOSCloudKeychainRetrievePendingMessageFromProxy(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
107 void SOSCloudKeychainUpdateKeys(CFDictionaryRef keys
, CFStringRef accountUUID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
108 void SOSCloudKeychainUnRegisterKeys(CFArrayRef keysToUnregister
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
110 void SOSCloudKeychainPutObjectsInCloud(CFDictionaryRef objects
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
112 void SOSCloudKeychainSetItemsChangedBlock(CloudItemsChangedBlock itemsChangedBlock
);
114 CF_RETURNS_RETAINED CFArrayRef
SOSCloudKeychainHandleUpdateMessage(CFDictionaryRef updates
);
115 void SOSCloudKeychainSynchronizeAndWait(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
119 void SOSCloudKeychainGetObjectsFromCloud(CFArrayRef keysToGet
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
120 void SOSCloudKeychainSynchronize(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
121 void SOSCloudKeychainClearAll(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
122 void SOSCloudKeychainGetAllObjectsFromCloud(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
123 bool SOSCloudKeychainHasPendingKey(CFStringRef keyName
, CFErrorRef
* error
);
125 void SOSCloudKeychainRequestSyncWithPeers(CFArrayRef
/* CFStringRef */ peers
, CFArrayRef
/* CFStringRef */ backupPeers
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
126 bool SOSCloudKeychainHasPendingSyncWithPeer(CFStringRef peerID
, CFErrorRef
* error
);
128 void SOSCloudKeychainRequestEnsurePeerRegistration(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
129 void SOSCloudKeychainRequestPerfCounters(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
131 void SOSCloudKeychainFlush(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
132 CFDictionaryRef
SOSCloudCopyKVSState(void);
133 void SOSCloudKeychainGetIDSDeviceAvailability(CFArrayRef ids
, CFStringRef peerID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
134 void SOSCloudKeychainRemoveKeys(CFArrayRef keys
, CFStringRef accountUUID
, dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
135 void SOSCloudKeychainRetrieveCountersFromIDSProxy(dispatch_queue_t processQueue
, CloudKeychainReplyBlock replyBlock
);
140 #endif /* !_SOSCLOUDKEYCHAINCLIENT_H_ */