@@ -53,6 +53,22 @@ struct wi_private {
5353//
5454// CONNECT
5555//
56+ static const char * lockdownd_err_to_string (int ldret ) {
57+ switch (ldret ) {
58+ case LOCKDOWN_E_PASSWORD_PROTECTED :
59+ return "Please enter the passcode on the device, then try again." ;
60+ case LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING :
61+ return "Please accept the trust dialog on the screen of device, then try again." ;
62+ case LOCKDOWN_E_USER_DENIED_PAIRING :
63+ return "User denied the trust dialog. Re-plug device and try again." ;
64+ case LOCKDOWN_E_INVALID_CONF :
65+ case LOCKDOWN_E_INVALID_HOST_ID :
66+ return "Device is not paired with this host. Re-plug device and try again." ;
67+ default :
68+ return "Could not connect to lockdownd, error code: %d." ;
69+ }
70+ }
71+
5672int wi_connect (const char * device_id , char * * to_device_id ,
5773 char * * to_device_name , int * to_device_os_version ,
5874 void * * to_ssl_session , int recv_timeout ) {
@@ -76,7 +92,7 @@ int wi_connect(const char *device_id, char **to_device_id,
7692 lockdownd_error_t ldret ;
7793 if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake (
7894 phone , & client , "ios_webkit_debug_proxy" ))) {
79- fprintf (stderr , "Could not connect to lockdownd, error code %d. Exiting. \n" , ldret );
95+ fprintf (stderr , "%s \n" , lockdownd_err_to_string ( ldret ) );
8096 goto leave_cleanup ;
8197 }
8298
@@ -111,9 +127,9 @@ int wi_connect(const char *device_id, char **to_device_id,
111127 }
112128
113129 // start webinspector, get port
114- lockdownd_error_t lerr = lockdownd_start_service (client , "com.apple.webinspector" , & service );
115- if ( !service || service -> port == 0 ) {
116- fprintf (stderr , "Could not start com.apple.webinspector! Error code: %d\n" , lerr );
130+ if ( LOCKDOWN_E_SUCCESS != ( ldret = lockdownd_start_service (client ,
131+ "com.apple.webinspector" , & service )) || !service || ! service -> port ) {
132+ fprintf (stderr , "Could not start com.apple.webinspector! Error code: %d\n" , ldret );
117133 goto leave_cleanup ;
118134 }
119135
0 commit comments