void xpc_array_set_value(xpc_object_t xarray, size_t index, xpc_object_t value) { struct xpc_object *xo, *xotmp, *xotmp2; struct xpc_array_head *arr; size_t i; xo = xarray; arr = &xo->xo_array; i = 0; if (index == XPC_ARRAY_APPEND) return xpc_array_append_value(xarray, value); if (index >= (size_t)xo->xo_size) return; TAILQ_FOREACH_SAFE(xotmp, arr, xo_link, xotmp2) { if (i++ == index) { TAILQ_INSERT_AFTER(arr, (struct xpc_object *)value, xotmp, xo_link); TAILQ_REMOVE(arr, xotmp, xo_link); xpc_retain(value); free(xotmp); break; } } }
void Noble::setupXpcConnection() { this->dispatchQueue = dispatch_queue_create("com.apple.blued", 0); this->xpcConnnection = xpc_connection_create_mach_service("com.apple.blued", this->dispatchQueue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED); xpc_connection_set_event_handler(this->xpcConnnection, ^(xpc_object_t event) { xpc_retain(event); this->handleXpcEvent(event); });
void XpcConnection::setup() { this->dispatchQueue = dispatch_queue_create(this->serviceName.c_str(), 0); this->xpcConnnection = xpc_connection_create_mach_service(this->serviceName.c_str(), this->dispatchQueue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED); xpc_connection_set_event_handler(this->xpcConnnection, ^(xpc_object_t event) { xpc_retain(event); // NSLog(@"event = %@", event); this->handleEvent(event); });
static void security_auth_event_handler(xpc_connection_t xpc_conn) { connection_t conn = server_register_connection(xpc_conn); if (conn) { xpc_connection_set_context(xpc_conn, conn); xpc_connection_set_finalizer_f(xpc_conn, connection_finalizer); xpc_connection_set_event_handler(xpc_conn, ^(xpc_object_t event) { xpc_retain(xpc_conn); xpc_retain(event); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ security_auth_peer_event_handler(xpc_conn, event); xpc_release(event); xpc_release(xpc_conn); }); });
void xpc_array_append_value(xpc_object_t xarray, xpc_object_t value) { struct xpc_object *xo; struct xpc_array_head *arr; xo = xarray; arr = &xo->xo_array; TAILQ_INSERT_TAIL(arr, (struct xpc_object *)value, xo_link); xpc_retain(value); }
void Connection::platformInitialize(Identifier identifier) { m_exceptionPort = MACH_PORT_NULL; if (m_isServer) { m_receivePort = identifier.port; m_sendPort = MACH_PORT_NULL; } else { m_receivePort = MACH_PORT_NULL; m_sendPort = identifier.port; } #if HAVE(XPC) m_xpcConnection = identifier.xpcConnection; // FIXME: Instead of explicitly retaining the connection here, Identifier::xpcConnection // should just be a smart pointer. if (m_xpcConnection) xpc_retain(m_xpcConnection); #endif }