2 // KCAccountKCCircleDelegate.m
5 // Created by Mitch Adler on 4/11/16.
9 #import <KeychainCircle/KCAccountKCCircleDelegate.h>
11 #include <Security/SecureObjectSync/SOSCloudCircle.h>
14 @implementation KCJoiningRequestAccountCircleDelegate
16 Get this devices peer info (As Application)
19 SOSPeerInfoRef object or NULL if we had an error.
21 - (SOSPeerInfoRef) copyPeerInfoError: (NSError**) error {
22 CFErrorRef failure = NULL;
23 SOSPeerInfoRef result = SOSCCCopyApplication(error ? &failure : NULL);
24 if (failure != NULL && error != nil) {
25 *error = (__bridge_transfer NSError*) failure;
31 Handle recipt of confirmed circleJoinData over the channel
33 @parameter circleJoinData
34 Data the acceptor made to allow us to join the circle.
37 - (bool) processCircleJoinData: (NSData*) circleJoinData version:(PiggyBackProtocolVersion) version error: (NSError**)error {
38 CFErrorRef failure = NULL;
39 bool result = SOSCCJoinWithCircleJoiningBlob((__bridge CFDataRef) circleJoinData, version, &failure);
40 if (failure != NULL && error != nil) {
41 *error = (__bridge_transfer NSError*) failure;
46 + (instancetype) delegate {
47 return [[KCJoiningRequestAccountCircleDelegate alloc] init];
52 @implementation KCJoiningAcceptAccountCircleDelegate
54 Handle the request's peer info and get the blob they can use to get in circle
56 SOSPeerInfo sent from requestor to apply to the circle
58 Error resulting in looking at peer and trying to produce circle join data
60 Data containing blob the requestor can use to get in circle
62 - (NSData*) circleJoinDataFor: (SOSPeerInfoRef) peer
63 error: (NSError**) error {
64 CFErrorRef failure = NULL;
65 CFDataRef result = SOSCCCopyCircleJoiningBlob(peer, &failure);
66 if (failure != NULL && error != nil) {
67 *error = (__bridge_transfer NSError*) failure;
69 return (__bridge_transfer NSData*) result;
72 -(NSData*) circleGetInitialSyncViews: (NSError**) error{
73 CFErrorRef failure = NULL;
74 CFDataRef result = SOSCCCopyInitialSyncData(&failure);
75 if (failure != NULL && error != nil) {
76 *error = (__bridge_transfer NSError*) failure;
78 return (__bridge_transfer NSData*) result;
81 + (instancetype) delegate {
82 return [[KCJoiningAcceptAccountCircleDelegate alloc] init];