2 * Copyright (c) 2012-2016 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@
28 #import <Foundation/Foundation.h>
29 #import <dispatch/queue.h>
32 #import "SOSCloudKeychainClient.h"
33 #import <utilities/debugging.h>
36 kIDSStartPingTestMessage
= 1,
37 kIDSEndPingTestMessage
= 2,
38 kIDSSendOneMessage
= 3,
39 kIDSSyncMessagesRaw
= 4,
40 kIDSSyncMessagesCompact
= 5,
41 kIDSPeerAvailability
= 6,
42 kIDSPeerAvailabilityDone
= 7,
43 kIDSKeychainSyncIDSFragmentation
= 8
47 kSecIDSErrorNoDeviceID
= -1, //default case
48 kSecIDSErrorNotRegistered
= -2,
49 kSecIDSErrorFailedToSend
=-3,
50 kSecIDSErrorCouldNotFindMatchingAuthToken
= -4,
51 kSecIDSErrorDeviceIsLocked
= -5,
52 kSecIDSErrorNoPeersAvailable
= -6
57 @interface IDSKeychainSyncingProxy
: NSObject
<IDSServiceDelegate
>
63 @
property (retain
, nonatomic
) NSMutableDictionary
*unhandledMessageBuffer
;
64 @
property (retain
, nonatomic
) NSMutableDictionary
*shadowPendingMessages
;
65 @
property (retain
, nonatomic
) NSMutableDictionary
*allFragmentedMessages
;
66 @
property (retain
, nonatomic
) NSMutableDictionary
*pingTimers
;
68 @
property (atomic
) dispatch_source_t penaltyTimer
;
69 @
property (atomic
) bool penaltyTimerScheduled
;
70 @
property (retain
, atomic
) NSMutableDictionary
*monitor
;
71 @
property (retain
, atomic
) NSDictionary
*queuedMessages
;
73 @
property (atomic
) bool isIDSInitDone
;
74 @
property (atomic
) bool isSecDRunningAsRoot
;
75 @
property (atomic
) bool doesSecDHavePeer
;
76 @
property (atomic
) dispatch_queue_t calloutQueue
;
77 @
property (atomic
) bool isLocked
;
78 @
property (atomic
) bool unlockedSinceBoot
;
79 @
property (atomic
) dispatch_source_t retryTimer
;
80 @
property (atomic
) bool retryTimerScheduled
;
81 @
property (atomic
) bool inCallout
;
82 @
property (atomic
) bool setIDSDeviceID
;
83 @
property (atomic
) bool shadowDoSetIDSDeviceID
;
85 @
property (atomic
) bool handleAllPendingMessages
;
86 @
property (atomic
) bool shadowHandleAllPendingMessages
;
88 + (IDSKeychainSyncingProxy
*) idsProxy
;
92 - (void) importIDSState
: (NSMutableDictionary
*) state
;
94 - (void) doSetIDSDeviceID
;
95 - (void) doIDSInitialization
;
96 - (void) calloutWith
: (void(^)(NSMutableDictionary
*pending
, bool handlePendingMesssages
, bool doSetDeviceID
, dispatch_queue_t queue
, void(^done
)(NSMutableDictionary
*handledMessages
, bool handledPendingMessage
, bool handledSettingDeviceID
))) callout
;
97 - (void) sendKeysCallout
: (NSMutableDictionary
*(^)(NSMutableDictionary
* pending
, NSError
** error
)) handleMessages
;
100 - (void)scheduleRetryRequestTimer
;
103 NSString
* createErrorString(NSString
* format
, ...);