]> git.saurik.com Git - apple/security.git/blame - KeychainSyncingOverIDSProxy/IDSProxy.h
Security-58286.1.32.tar.gz
[apple/security.git] / KeychainSyncingOverIDSProxy / IDSProxy.h
CommitLineData
5c19dc3a 1/*
866f8763 2 * Copyright (c) 2012-2017 Apple Inc. All Rights Reserved.
5c19dc3a
A
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
5c19dc3a
A
24#import <Foundation/Foundation.h>
25#import <dispatch/queue.h>
26#import <xpc/xpc.h>
27#import <IDS/IDS.h>
28#import "SOSCloudKeychainClient.h"
29#import <utilities/debugging.h>
866f8763 30#import <Security/SecureObjectSync/SOSInternal.h>
5c19dc3a 31
5c19dc3a
A
32typedef enum {
33 kIDSStartPingTestMessage = 1,
34 kIDSEndPingTestMessage= 2,
35 kIDSSendOneMessage = 3,
6b200bc3 36 kIDSPeerReceivedACK = 4,
e0e0d90e 37 kIDSPeerAvailability = 6,
fa7225c8 38 kIDSPeerAvailabilityDone = 7,
6b200bc3 39 kIDSKeychainSyncIDSFragmentation = 8,
5c19dc3a
A
40} idsOperation;
41
6b200bc3 42@interface KeychainSyncingOverIDSProxy : NSObject <IDSServiceDelegate>
5c19dc3a 43{
5c19dc3a 44 IDSService *_service;
6b200bc3
A
45 NSString *deviceID;
46 NSMutableDictionary *deviceIDFromAuthToken;
5c19dc3a
A
47}
48
6b200bc3 49@property (retain, nonatomic) NSMutableDictionary *deviceIDFromAuthToken;
866f8763 50@property (retain, nonatomic) NSString *deviceID;
5c19dc3a 51@property (retain, nonatomic) NSMutableDictionary *shadowPendingMessages;
fa7225c8 52@property (retain, nonatomic) NSMutableDictionary *allFragmentedMessages;
866f8763
A
53@property (retain, atomic) NSMutableDictionary *pingTimers;
54@property (retain, nonatomic) NSMutableDictionary *peerNextSendCache; //dictionary of device ID -> time stamp of when to send next
55
56// Only touch these three dictionaries from the dataQueue or you will crash, eventually.
6b200bc3 57@property (retain, nonatomic) NSMutableDictionary *messagesInFlight;
866f8763
A
58@property (retain, nonatomic) NSMutableDictionary *unhandledMessageBuffer;
59@property (retain, nonatomic) NSMutableDictionary *monitor;
60
61@property (retain, nonatomic) NSArray* listOfDevices;
6b200bc3 62
866f8763
A
63@property (atomic) dispatch_source_t penaltyTimer;
64@property (atomic) bool penaltyTimerScheduled;
65@property (retain, atomic) NSDictionary *queuedMessages;
fa7225c8 66
866f8763
A
67@property (retain, atomic) NSMutableDictionary *counterValues;
68@property (atomic) NSInteger outgoingMessages;
69@property (atomic) NSInteger incomingMessages;
5c19dc3a
A
70
71@property (atomic) bool isIDSInitDone;
6b200bc3 72@property (atomic) bool shadowDoInitializeIDSService;
5c19dc3a 73@property (atomic) bool isSecDRunningAsRoot;
fa7225c8 74@property (atomic) bool doesSecDHavePeer;
866f8763 75
5c19dc3a 76@property (atomic) dispatch_queue_t calloutQueue;
866f8763
A
77@property (atomic) dispatch_queue_t pingQueue;
78@property dispatch_queue_t dataQueue;
79
5c19dc3a
A
80@property (atomic) bool isLocked;
81@property (atomic) bool unlockedSinceBoot;
fa7225c8
A
82@property (atomic) dispatch_source_t retryTimer;
83@property (atomic) bool retryTimerScheduled;
5c19dc3a 84@property (atomic) bool inCallout;
5c19dc3a
A
85@property (atomic) bool setIDSDeviceID;
86@property (atomic) bool shadowDoSetIDSDeviceID;
87
88@property (atomic) bool handleAllPendingMessages;
89@property (atomic) bool shadowHandleAllPendingMessages;
6b200bc3 90@property (atomic) bool sendRestoredMessages;
5c19dc3a 91
6b200bc3 92+ (KeychainSyncingOverIDSProxy *) idsProxy;
5c19dc3a
A
93
94- (id)init;
5c19dc3a 95
fa7225c8 96- (void) doSetIDSDeviceID;
5c19dc3a 97- (void) doIDSInitialization;
866f8763
A
98- (void) calloutWith: (void(^)(NSMutableDictionary *pending,
99 bool handlePendingMesssages,
100 bool doSetDeviceID,
101 dispatch_queue_t queue,
102 void(^done)(NSMutableDictionary *handledMessages,
103 bool handledPendingMessage,
104 bool handledSettingDeviceID))) callout;
5c19dc3a 105- (void) sendKeysCallout: (NSMutableDictionary *(^)(NSMutableDictionary* pending, NSError** error)) handleMessages;
866f8763 106- (void) persistState;
6b200bc3
A
107- (void) sendPersistedMessagesAgain;
108- (NSDictionary*) retrievePendingMessages;
866f8763
A
109- (NSDictionary*) collectStats;
110- (void) scheduleRetryRequestTimer;
111- (BOOL) haveMessagesInFlight;
5c19dc3a 112@end
fa7225c8 113
866f8763
A
114NSString* createErrorString(NSString* format, ...)
115 NS_FORMAT_FUNCTION(1, 2);