#include "SecADWrapper.h"
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
#include <AggregateDictionary/ADClient.h>
static typeof(ADClientAddValueForScalarKey) *soft_ADClientAddValueForScalarKey = NULL;
static typeof(ADClientClearScalarKey) *soft_ADClientClearScalarKey = NULL;
static typeof(ADClientSetValueForScalarKey) *soft_ADClientSetValueForScalarKey = NULL;
static typeof(ADClientPushValueForDistributionKey) *soft_ADClientPushValueForDistributionKey = NULL;
static bool
setup(void)
{
static dispatch_once_t onceToken;
static CFBundleRef bundle = NULL;
dispatch_once(&onceToken, ^{
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/System/Library/PrivateFrameworks/AggregateDictionary.framework"), kCFURLPOSIXPathStyle, true);
if (url == NULL)
return;
bundle = CFBundleCreate(kCFAllocatorDefault, url);
CFRelease(url);
if (bundle == NULL)
return;
soft_ADClientClearScalarKey = CFBundleGetFunctionPointerForName(bundle, CFSTR("ADClientClearScalarKey"));
soft_ADClientSetValueForScalarKey = CFBundleGetFunctionPointerForName(bundle, CFSTR("ADClientSetValueForScalarKey"));
soft_ADClientAddValueForScalarKey = CFBundleGetFunctionPointerForName(bundle, CFSTR("ADClientAddValueForScalarKey"));
soft_ADClientPushValueForDistributionKey = CFBundleGetFunctionPointerForName(bundle, CFSTR("ADClientPushValueForDistributionKey"));
if (soft_ADClientClearScalarKey == NULL ||
soft_ADClientSetValueForScalarKey == NULL ||
soft_ADClientAddValueForScalarKey == NULL ||
soft_ADClientPushValueForDistributionKey == NULL)
{
CFRelease(bundle);
bundle = NULL;
}
});
return bundle != NULL;
}
#endif
void
SecADClearScalarKey(CFStringRef key)
{
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
if (setup())
soft_ADClientClearScalarKey(key);
#endif
}
void
SecADSetValueForScalarKey(CFStringRef key, int64_t value)
{
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
if (setup())
soft_ADClientSetValueForScalarKey(key, value);
#endif
}
void
SecADAddValueForScalarKey(CFStringRef key, int64_t value)
{
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
if (setup())
soft_ADClientAddValueForScalarKey(key, value);
#endif
}
void
SecADClientPushValueForDistributionKey(CFStringRef key, int64_t value)
{
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
if (setup())
soft_ADClientPushValueForDistributionKey(key, value);
#endif
}