bool SOSAccountSendIKSPSyncList(SOSAccountRef account, CFErrorRef *error){ bool result = true; __block CFErrorRef localError = NULL; __block CFMutableArrayRef ids = NULL; SOSCircleRef circle = NULL; require_action_quiet(SOSAccountIsInCircle(account, NULL), xit, SOSCreateError(kSOSErrorNoCircle, CFSTR("This device is not in circle"), NULL, &localError)); circle = SOSAccountGetCircle(account, error); ids = CFArrayCreateMutableForCFTypes(kCFAllocatorDefault); SOSCircleForEachValidPeer(circle, account->user_public, ^(SOSPeerInfoRef peer) { if (!SOSAccountIsThisPeerIDMe(account, SOSPeerInfoGetPeerID(peer))) { if(SOSPeerInfoShouldUseIDSTransport(SOSFullPeerInfoGetPeerInfo(account->my_identity), peer) && SOSPeerInfoShouldUseIDSMessageFragmentation(SOSFullPeerInfoGetPeerInfo(account->my_identity), peer) && !SOSPeerInfoShouldUseACKModel(SOSFullPeerInfoGetPeerInfo(account->my_identity), peer)){ SOSTransportMessageIDSSetFragmentationPreference(account->ids_message_transport, kCFBooleanTrue); CFStringRef deviceID = SOSPeerInfoCopyDeviceID(peer); if(deviceID != NULL){ CFArrayAppendValue(ids, deviceID); } CFReleaseNull(deviceID); } } });
static CFMutableArrayRef get_log_handlers() { static dispatch_once_t handlers_once; dispatch_once(&handlers_once, ^{ sSecurityLogHandlers = CFArrayCreateMutableForCFTypes(kCFAllocatorDefault); CFArrayAppendValue(sSecurityLogHandlers, ^(const char *level, CFStringRef scope, const char *function, const char *file, int line, CFStringRef message){ CFStringRef logStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ %s %@\n"), scope ? scope : CFSTR(""), function, message); CFStringPerformWithCString(logStr, ^(const char *logMsg) { aslmsg msg = asl_new(ASL_TYPE_MSG); if (scope) { CFStringPerformWithCString(scope, ^(const char *scopeStr) { asl_set(msg, ASL_KEY_FACILITY, scopeStr); }); } asl_set(msg, ASL_KEY_LEVEL, level); asl_set(msg, ASL_KEY_MSG, logMsg); asl_send(NULL, msg); asl_free(msg); }); CFReleaseSafe(logStr); });
CFStringRef peerid = SOSPeerInfoGetPeerID(mypi); if (!peerid) return false; return SOSAccountIsActivePeerInCircleNamed(account, circle_name, peerid, error); } // // MARK: Peer Querying // static CFArrayRef SOSAccountCopySortedPeerArray(SOSAccountRef account, CFErrorRef *error, void (^action)(SOSCircleRef circle, CFMutableArrayRef appendPeersTo)) { if (!SOSAccountHasPublicKey(account, error)) return NULL; CFMutableArrayRef peers = CFArrayCreateMutableForCFTypes(kCFAllocatorDefault); SOSAccountForEachCircle(account, ^(SOSCircleRef circle) { action(circle, peers); }); CFArrayOfSOSPeerInfosSortByID(peers); return peers; } CFArrayRef SOSAccountCopyNotValidPeers(SOSAccountRef account, CFErrorRef *error) { return SOSAccountCopySortedPeerArray(account, error, ^(SOSCircleRef circle, CFMutableArrayRef appendPeersTo) { SOSCircleForEachPeer(circle, ^(SOSPeerInfoRef peer) { if(!SOSPeerInfoApplicationVerify(peer, account->user_public, NULL)) {