]> git.saurik.com Git - apple/security.git/blob - Security/sec/SOSCircle/SecureObjectSync/SOSTransportCircle.c
Security-57031.40.6.tar.gz
[apple/security.git] / Security / sec / SOSCircle / SecureObjectSync / SOSTransportCircle.c
1
2 #include <CoreFoundation/CoreFoundation.h>
3 #include <SecureObjectSync/SOSTransportCircle.h>
4 #include <SecureObjectSync/SOSTransportCircleKVS.h>
5 #include <SecureObjectSync/SOSTransport.h>
6 #include <SecureObjectSync/SOSKVSKeys.h>
7 #include <SecureObjectSync/SOSAccount.h>
8 #include <SecureObjectSync/SOSAccountPriv.h>
9
10 #include <utilities/SecCFWrappers.h>
11 #include <SOSInternal.h>
12 #include <SOSCloudKeychainClient.h>
13 #include <AssertMacros.h>
14
15 CFGiblisWithCompareFor(SOSTransportCircle);
16
17 SOSTransportCircleRef SOSTransportCircleCreateForSubclass(size_t size, SOSAccountRef account, CFErrorRef *error)
18 {
19 SOSTransportCircleRef tpt = CFTypeAllocateWithSpace(SOSTransportCircle, size, kCFAllocatorDefault);
20 tpt->account = CFRetainSafe(account);
21 return tpt;
22 }
23
24 static CFStringRef SOSTransportCircleCopyFormatDescription(CFTypeRef aObj, CFDictionaryRef formatOptions) {
25 SOSTransportCircleRef t = (SOSTransportCircleRef) aObj;
26
27 return CFStringCreateWithFormat(NULL, NULL, CFSTR("<SOSTransportCircle@%p\n>"), t);
28 }
29
30 static void SOSTransportCircleDestroy(CFTypeRef aObj) {
31 SOSTransportCircleRef transport = (SOSTransportCircleRef) aObj;
32 if(transport->destroy)
33 transport->destroy(transport);
34 CFReleaseNull(transport->account);
35 }
36
37 static CFHashCode SOSTransportCircleHash(CFTypeRef obj)
38 {
39 return (intptr_t) obj;
40 }
41
42 static Boolean SOSTransportCircleCompare(CFTypeRef lhs, CFTypeRef rhs)
43 {
44 return SOSTransportCircleHash(lhs) == SOSTransportCircleHash(rhs);
45 }
46
47 SOSAccountRef SOSTransportCircleGetAccount(SOSTransportCircleRef transport){
48 return transport->account;
49 }
50
51 bool SOSTransportCircleFlushChanges(SOSTransportCircleRef transport, CFErrorRef *error) {
52 return transport->flushChanges(transport, error);
53 }
54
55 bool SOSTransportCirclePostCircle(SOSTransportCircleRef transport, CFStringRef circleName, CFDataRef circle_data, CFErrorRef *error) {
56 return transport->postCircle(transport, circleName, circle_data, error);
57 }
58 CF_RETURNS_RETAINED
59 CFDictionaryRef SOSTransportCircleHandleRetirementMessages(SOSTransportCircleRef transport, CFMutableDictionaryRef circle_retirement_messages_table, CFErrorRef *error) {
60 return transport->handleRetirementMessages(transport, circle_retirement_messages_table, error);
61 }
62
63 CF_RETURNS_RETAINED
64 CFArrayRef SOSTransportCircleHandleCircleMessages(SOSTransportCircleRef transport, CFMutableDictionaryRef circle_circle_messages_table, CFErrorRef *error) {
65 return transport->handleCircleMessages(transport, circle_circle_messages_table, error);
66 }
67
68 bool SOSTransportCirclePostRetirement(SOSTransportCircleRef transport, CFStringRef circleName, CFStringRef peer_id, CFDataRef retirement_data, CFErrorRef *error) {
69 return transport->postRetirement(transport, circleName, peer_id, retirement_data, error);
70 }
71
72 bool SOSTransportCircleExpireRetirementRecords(SOSTransportCircleRef transport, CFDictionaryRef retirements, CFErrorRef *error){
73 return transport->expireRetirementRecords(transport, retirements, error);
74 }
75
76