1/* 2 * Copyright (c) 1998-2013 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#include "DADialog.h" 25 26#include "DAAgent.h" 27#include "DAMain.h" 28 29#include <xpc/private.h> 30 31static void __DADialogShow( DADiskRef disk, _DAAgentAction action ) 32{ 33 xpc_object_t message; 34 35 message = xpc_dictionary_create( NULL, NULL, 0 ); 36 37 if ( message ) 38 { 39 xpc_connection_t connection; 40 41 connection = xpc_connection_create_mach_service( _kDAAgentName, NULL, 0 ); 42 43 if ( connection ) 44 { 45 CFDataRef serialization; 46 47 serialization = DADiskGetSerialization( disk ); 48 49 xpc_dictionary_set_uint64( message, _kDAAgentActionKey, action ); 50 51 xpc_dictionary_set_data( message, _kDAAgentDiskKey, CFDataGetBytePtr( serialization ), CFDataGetLength( serialization ) ); 52 53 xpc_connection_set_event_handler( connection, ^( xpc_object_t object ) { } ); 54 55 xpc_connection_set_target_uid( connection, gDAConsoleUserUID ); 56 57 xpc_connection_resume( connection ); 58 59 xpc_connection_send_message( connection, message ); 60 61 xpc_release( connection ); 62 } 63 64 xpc_release( message ); 65 } 66} 67 68void DADialogShowDeviceRemoval( DADiskRef disk ) 69{ 70 __DADialogShow( disk, _kDAAgentActionShowDeviceRemoval ); 71} 72 73void DADialogShowDeviceUnreadable( DADiskRef disk ) 74{ 75 __DADialogShow( disk, _kDAAgentActionShowDeviceUnreadable ); 76} 77 78void DADialogShowDeviceUnrepairable( DADiskRef disk ) 79{ 80 __DADialogShow( disk, _kDAAgentActionShowDeviceUnrepairable ); 81} 82