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>
10 #include <utilities/SecCFWrappers.h>
11 #include <SOSInternal.h>
12 #include <SOSCloudKeychainClient.h>
13 #include <AssertMacros.h>
15 CFGiblisWithCompareFor(SOSTransportCircle
);
17 SOSTransportCircleRef
SOSTransportCircleCreateForSubclass(size_t size
, SOSAccountRef account
, CFErrorRef
*error
)
19 SOSTransportCircleRef tpt
= CFTypeAllocateWithSpace(SOSTransportCircle
, size
, kCFAllocatorDefault
);
20 tpt
->account
= CFRetainSafe(account
);
24 static CFStringRef
SOSTransportCircleCopyFormatDescription(CFTypeRef aObj
, CFDictionaryRef formatOptions
) {
25 SOSTransportCircleRef t
= (SOSTransportCircleRef
) aObj
;
27 return CFStringCreateWithFormat(NULL
, NULL
, CFSTR("<SOSTransportCircle@%p\n>"), t
);
30 static void SOSTransportCircleDestroy(CFTypeRef aObj
) {
31 SOSTransportCircleRef transport
= (SOSTransportCircleRef
) aObj
;
32 if(transport
->destroy
)
33 transport
->destroy(transport
);
34 CFReleaseNull(transport
->account
);
37 static CFHashCode
SOSTransportCircleHash(CFTypeRef obj
)
39 return (intptr_t) obj
;
42 static Boolean
SOSTransportCircleCompare(CFTypeRef lhs
, CFTypeRef rhs
)
44 return SOSTransportCircleHash(lhs
) == SOSTransportCircleHash(rhs
);
47 SOSAccountRef
SOSTransportCircleGetAccount(SOSTransportCircleRef transport
){
48 return transport
->account
;
51 bool SOSTransportCircleFlushChanges(SOSTransportCircleRef transport
, CFErrorRef
*error
) {
52 return transport
->flushChanges(transport
, error
);
55 bool SOSTransportCirclePostCircle(SOSTransportCircleRef transport
, CFStringRef circleName
, CFDataRef circle_data
, CFErrorRef
*error
) {
56 return transport
->postCircle(transport
, circleName
, circle_data
, error
);
59 CFDictionaryRef
SOSTransportCircleHandleRetirementMessages(SOSTransportCircleRef transport
, CFMutableDictionaryRef circle_retirement_messages_table
, CFErrorRef
*error
) {
60 return transport
->handleRetirementMessages(transport
, circle_retirement_messages_table
, error
);
64 CFArrayRef
SOSTransportCircleHandleCircleMessages(SOSTransportCircleRef transport
, CFMutableDictionaryRef circle_circle_messages_table
, CFErrorRef
*error
) {
65 return transport
->handleCircleMessages(transport
, circle_circle_messages_table
, error
);
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
);
72 bool SOSTransportCircleExpireRetirementRecords(SOSTransportCircleRef transport
, CFDictionaryRef retirements
, CFErrorRef
*error
){
73 return transport
->expireRetirementRecords(transport
, retirements
, error
);