1
2#include <SecureObjectSync/SOSAccount.h>
3#include <SecureObjectSync/SOSTransport.h>
4#include <SecureObjectSync/SOSTransportKeyParameter.h>
5#include <SecureObjectSync/SOSKVSKeys.h>
6
7#include <utilities/SecCFWrappers.h>
8#include <SecureObjectSync/SOSAccountPriv.h>
9#include <SOSCloudKeychainClient.h>
10
11CFGiblisWithCompareFor(SOSTransportKeyParameter);
12
13SOSTransportKeyParameterRef SOSTransportKeyParameterCreateForSubclass(size_t size, SOSAccountRef account, CFErrorRef *error)
14{
15    SOSTransportKeyParameterRef tpt = CFTypeAllocateWithSpace(SOSTransportKeyParameter, size, kCFAllocatorDefault);
16    tpt->account = CFRetainSafe(account);
17    return tpt;
18}
19
20bool SOSTransportKeyParameterHandleNewAccount(SOSTransportKeyParameterRef transport){
21    return transport->setToNewAccount(transport);
22}
23
24static CFStringRef SOSTransportKeyParameterCopyDescription(CFTypeRef aObj) {
25    SOSTransportKeyParameterRef t = (SOSTransportKeyParameterRef) aObj;
26
27    return CFStringCreateWithFormat(NULL, NULL, CFSTR("<SOSTransportKeyParameter@%p\n>"), t);
28}
29
30static void SOSTransportKeyParameterDestroy(CFTypeRef aObj) {
31    SOSTransportKeyParameterRef transport = (SOSTransportKeyParameterRef) aObj;
32
33    if(transport->destroy)
34        transport->destroy(transport);
35
36    CFReleaseNull(transport->account);
37
38}
39
40bool SOSTransportKeyParameterHandleKeyParameterChanges(SOSTransportKeyParameterRef transport, CFDataRef data, CFErrorRef error){
41    return transport->handleKeyParameterChanges(transport, data, error);
42}
43
44
45static CFHashCode SOSTransportKeyParameterHash(CFTypeRef obj)
46{
47    return (intptr_t) obj;
48}
49
50static Boolean SOSTransportKeyParameterCompare(CFTypeRef lhs, CFTypeRef rhs)
51{
52    return SOSTransportKeyParameterHash(lhs) == SOSTransportKeyParameterHash(rhs);
53}
54
55
56bool SOSTrasnportKeyParameterPublishCloudParameters(SOSTransportKeyParameterRef transport, CFDataRef data, CFErrorRef* error) {
57    return transport->publishCloudParameters(transport, data, error);
58}
59
60SOSAccountRef SOSTransportKeyParameterGetAccount(SOSTransportKeyParameterRef transport){
61    return transport->account;
62}
63