]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/IDSKeychainSyncingProxy/IDSProxy.h
Security-57336.10.29.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / IDSKeychainSyncingProxy / IDSProxy.h
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 // IDSProxy.h
26 // ids-xpc
27
28 #import <Foundation/Foundation.h>
29 #import <dispatch/queue.h>
30 #import <xpc/xpc.h>
31 #import <IDS/IDS.h>
32 #import "SOSCloudKeychainClient.h"
33 #import <utilities/debugging.h>
34
35 #define IDSPROXYSCOPE "IDSProxy"
36 #define IDSServiceNameKeychainSync "com.apple.private.alloy.keychainsync"
37
38 typedef enum {
39 kIDSStartPingTestMessage = 1,
40 kIDSEndPingTestMessage= 2,
41 kIDSSendOneMessage = 3,
42 kIDSSyncMessagesRaw = 4,
43 kIDSSyncMessagesCompact = 5,
44 kIDSPeerAvailability = 6,
45 kIDSPeerAvailabilityDone = 7
46 } idsOperation;
47
48 typedef enum {
49 kSecIDSErrorNoDeviceID = -1, //default case
50 kSecIDSErrorNotRegistered = -2,
51 kSecIDSErrorFailedToSend=-3,
52 kSecIDSErrorCouldNotFindMatchingAuthToken = -4,
53 kSecIDSErrorDeviceIsLocked = -5,
54 kSecIDSErrorBatchControllerUninitialized = -6
55 } idsError;
56
57
58 @interface IDSKeychainSyncingProxy : NSObject <IDSServiceDelegate, IDSBatchIDQueryControllerDelegate>
59 {
60 CloudItemsChangedBlock itemsChangedCallback;
61 IDSService *_service;
62 NSString *_deviceID;
63 NSMutableDictionary *_unhandledMessageBuffer;
64 }
65
66 @property (retain, nonatomic) NSMutableDictionary *unhandledMessageBuffer;
67 @property (retain, nonatomic) NSMutableDictionary *shadowPendingMessages;
68
69 @property (atomic) bool isIDSInitDone;
70 @property (atomic) bool isSecDRunningAsRoot;
71 @property (atomic) dispatch_queue_t calloutQueue;
72 @property (atomic) bool isLocked;
73 @property (atomic) bool unlockedSinceBoot;
74 @property (atomic) dispatch_source_t syncTimer;
75 @property (atomic) bool syncTimerScheduled;
76 @property (atomic) dispatch_time_t deadline;
77 @property (atomic) dispatch_time_t lastSyncTime;
78 @property (atomic) bool inCallout;
79 @property (atomic) bool oldInCallout;
80 @property (atomic) bool setIDSDeviceID;
81 @property (atomic) bool shadowDoSetIDSDeviceID;
82
83 @property (atomic) bool handleAllPendingMessages;
84 @property (atomic) bool shadowHandleAllPendingMessages;
85
86 + (IDSKeychainSyncingProxy *) idsProxy;
87
88 - (id)init;
89 - (void)setItemsChangedBlock:(CloudItemsChangedBlock)itemsChangedBlock;
90 - (void)streamEvent:(xpc_object_t)notification;
91
92 - (BOOL) sendIDSMessage:(NSDictionary*)data name:(NSString*)deviceName peer:(NSString*) peerID error:(NSError**) error;
93 - (BOOL) doSetIDSDeviceID: (NSError**)error;
94 - (void) doIDSInitialization;
95 - (void) calloutWith: (void(^)(NSMutableDictionary *pending, bool handlePendingMesssages, bool doSetDeviceID, dispatch_queue_t queue, void(^done)(NSMutableDictionary *handledMessages, bool handledPendingMessage, bool handledSettingDeviceID))) callout;
96 - (void) sendKeysCallout: (NSMutableDictionary *(^)(NSMutableDictionary* pending, NSError** error)) handleMessages;
97
98 @end