diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/device_link_service.c | 91 | ||||
| -rw-r--r-- | src/device_link_service.h | 22 | ||||
| -rw-r--r-- | src/mobilebackup.c | 5 | ||||
| -rw-r--r-- | src/mobilebackup.h | 1 | ||||
| -rw-r--r-- | src/mobilebackup2.c | 6 | ||||
| -rw-r--r-- | src/mobilebackup2.h | 2 | ||||
| -rw-r--r-- | src/mobilesync.c | 4 | ||||
| -rw-r--r-- | src/screenshotr.c | 6 | 
8 files changed, 81 insertions, 56 deletions
| diff --git a/src/device_link_service.c b/src/device_link_service.c index 007223e..856d301 100644 --- a/src/device_link_service.c +++ b/src/device_link_service.c @@ -2,7 +2,7 @@   * device_link_service.c   * DeviceLink service implementation.   * - * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,27 @@  #include "property_list_service.h"  #include "common/debug.h" +static device_link_service_error_t device_link_error(property_list_service_error_t err) +{ +	switch (err) { +		case PROPERTY_LIST_SERVICE_E_SUCCESS: +			return DEVICE_LINK_SERVICE_E_SUCCESS; +		case PROPERTY_LIST_SERVICE_E_INVALID_ARG: +			return DEVICE_LINK_SERVICE_E_INVALID_ARG; +		case PROPERTY_LIST_SERVICE_E_PLIST_ERROR: +			return DEVICE_LINK_SERVICE_E_PLIST_ERROR; +		case PROPERTY_LIST_SERVICE_E_MUX_ERROR: +			return DEVICE_LINK_SERVICE_E_MUX_ERROR; +		case PROPERTY_LIST_SERVICE_E_SSL_ERROR: +			return DEVICE_LINK_SERVICE_E_SSL_ERROR; +		case PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT: +			return DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT; +		default: +			break; +	} +	return DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR; +} +  /**   * Internally used function to extract the message string from a DL* message   * plist. @@ -89,18 +110,15 @@ device_link_service_error_t device_link_service_client_new(idevice_t device, loc  	}  	property_list_service_client_t plistclient = NULL; -	if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_MUX_ERROR; +	device_link_service_error_t err = device_link_error(property_list_service_client_new(device, service, &plistclient)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) { +		return err;  	}  	/* create client object */  	device_link_service_client_t client_loc = (device_link_service_client_t) malloc(sizeof(struct device_link_service_client_private));  	client_loc->parent = plistclient; -	/* enable SSL if requested */ -	if (service->ssl_enabled) -		property_list_service_enable_ssl(client_loc->parent); -  	/* all done, return success */  	*client = client_loc;  	return DEVICE_LINK_SERVICE_E_SUCCESS; @@ -121,11 +139,10 @@ device_link_service_error_t device_link_service_client_free(device_link_service_  	if (!client)  		return DEVICE_LINK_SERVICE_E_INVALID_ARG; -	if (property_list_service_client_free(client->parent) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR; -	} +	device_link_service_error_t err = device_link_error(property_list_service_client_free(client->parent));  	free(client); -	return DEVICE_LINK_SERVICE_E_SUCCESS; + +	return err;  }  /** @@ -157,9 +174,9 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser  	char *msg = NULL;  	/* receive DLMessageVersionExchange from device */ -	if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { +	err = device_link_error(property_list_service_receive_plist(client->parent, &array)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) {  		debug_info("Did not receive initial message from device!"); -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR;  		goto leave;  	}  	device_link_service_get_message(array, &msg); @@ -203,18 +220,18 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser  	plist_array_append_item(array, plist_new_string("DLMessageVersionExchange"));  	plist_array_append_item(array, plist_new_string("DLVersionsOk"));  	plist_array_append_item(array, plist_new_uint(version_major)); -	if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { +	err = device_link_error(property_list_service_send_binary_plist(client->parent, array)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) {  		debug_info("Error when sending DLVersionsOk"); -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR;  		goto leave;  	}  	plist_free(array);  	/* receive DeviceReady message */  	array = NULL; -	if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { +	err = device_link_error(property_list_service_receive_plist(client->parent, &array)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) {  		debug_info("Error when receiving DLMessageDeviceReady!"); -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR;  		goto leave;  	}  	device_link_service_get_message(array, &msg); @@ -258,11 +275,9 @@ device_link_service_error_t device_link_service_disconnect(device_link_service_c  	else  		plist_array_append_item(array, plist_new_string("___EmptyParameterString___")); -	device_link_service_error_t err = DEVICE_LINK_SERVICE_E_SUCCESS; -	if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR; -	} +	device_link_service_error_t err = device_link_error(property_list_service_send_binary_plist(client->parent, array));  	plist_free(array); +  	return err;  } @@ -286,11 +301,9 @@ device_link_service_error_t device_link_service_send_ping(device_link_service_cl  	plist_array_append_item(array, plist_new_string("DLMessagePing"));  	plist_array_append_item(array, plist_new_string(message)); -	device_link_service_error_t err = DEVICE_LINK_SERVICE_E_SUCCESS; -	if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR; -	} +	device_link_service_error_t err = device_link_error(property_list_service_send_binary_plist(client->parent, array));  	plist_free(array); +  	return err;  } @@ -317,11 +330,9 @@ device_link_service_error_t device_link_service_send_process_message(device_link  	plist_array_append_item(array, plist_new_string("DLMessageProcessMessage"));  	plist_array_append_item(array, plist_copy(message)); -	device_link_service_error_t err = DEVICE_LINK_SERVICE_E_SUCCESS; -	if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		err = DEVICE_LINK_SERVICE_E_MUX_ERROR; -	} +	device_link_service_error_t err = device_link_error(property_list_service_send_binary_plist(client->parent, array));  	plist_free(array); +  	return err;  } @@ -348,8 +359,9 @@ device_link_service_error_t device_link_service_receive_message(device_link_serv  		return DEVICE_LINK_SERVICE_E_INVALID_ARG;  	*msg_plist = NULL; -	if (property_list_service_receive_plist(client->parent, msg_plist) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_MUX_ERROR; +	device_link_service_error_t err = device_link_error(property_list_service_receive_plist(client->parent, msg_plist)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) { +		return err;  	}  	if (!device_link_service_get_message(*msg_plist, dlmessage)) { @@ -378,11 +390,12 @@ device_link_service_error_t device_link_service_receive_process_message(device_l  		return DEVICE_LINK_SERVICE_E_INVALID_ARG;  	plist_t pmsg = NULL; -	if (property_list_service_receive_plist(client->parent, &pmsg) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_MUX_ERROR; +	device_link_service_error_t err = device_link_error(property_list_service_receive_plist(client->parent, &pmsg)); +	if (err != DEVICE_LINK_SERVICE_E_SUCCESS) { +		return err;  	} -	device_link_service_error_t err = DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR; +	err = DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR;  	char *msg = NULL;  	device_link_service_get_message(pmsg, &msg); @@ -432,10 +445,7 @@ device_link_service_error_t device_link_service_send(device_link_service_client_  	if (!client || !plist) {  		return DEVICE_LINK_SERVICE_E_INVALID_ARG;  	} -	if (property_list_service_send_binary_plist(client->parent, plist) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_MUX_ERROR; -	} -	return DEVICE_LINK_SERVICE_E_SUCCESS; +	return device_link_error(property_list_service_send_binary_plist(client->parent, plist));  }  /* Generic device link service receive function. @@ -455,9 +465,6 @@ device_link_service_error_t device_link_service_receive(device_link_service_clie  		return DEVICE_LINK_SERVICE_E_INVALID_ARG;  	} -	if (property_list_service_receive_plist(client->parent, plist) != PROPERTY_LIST_SERVICE_E_SUCCESS) { -		return DEVICE_LINK_SERVICE_E_MUX_ERROR; -	} -	return DEVICE_LINK_SERVICE_E_SUCCESS; +	return device_link_error(property_list_service_receive_plist(client->parent, plist));  } diff --git a/src/device_link_service.h b/src/device_link_service.h index a0c8390..eae912a 100644 --- a/src/device_link_service.h +++ b/src/device_link_service.h @@ -2,7 +2,7 @@   * device_link_service.h   * Definitions for the DeviceLink service   * - * Copyright (c) 2010 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -25,16 +25,16 @@  #include "property_list_service.h"  /* Error Codes */ -#define DEVICE_LINK_SERVICE_E_SUCCESS                0 -#define DEVICE_LINK_SERVICE_E_INVALID_ARG           -1 -#define DEVICE_LINK_SERVICE_E_PLIST_ERROR           -2 -#define DEVICE_LINK_SERVICE_E_MUX_ERROR             -3 -#define DEVICE_LINK_SERVICE_E_BAD_VERSION           -4 - -#define DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR       -256 - -/** Represents an error code. */ -typedef int16_t device_link_service_error_t; +typedef enum { +	DEVICE_LINK_SERVICE_E_SUCCESS         =    0, +	DEVICE_LINK_SERVICE_E_INVALID_ARG     =   -1, +	DEVICE_LINK_SERVICE_E_PLIST_ERROR     =   -2, +	DEVICE_LINK_SERVICE_E_MUX_ERROR       =   -3, +	DEVICE_LINK_SERVICE_E_SSL_ERROR       =   -4, +	DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT =   -5, +	DEVICE_LINK_SERVICE_E_BAD_VERSION     =   -6, +	DEVICE_LINK_SERVICE_E_UNKNOWN_ERROR   = -256 +} device_link_service_error_t;  struct device_link_service_client_private {  	property_list_service_client_t parent; diff --git a/src/mobilebackup.c b/src/mobilebackup.c index b32e0ba..2682a6f 100644 --- a/src/mobilebackup.c +++ b/src/mobilebackup.c @@ -2,6 +2,7 @@   * mobilebackup.c   * Contains functions for the built-in MobileBackup client.   * + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   * Copyright (c) 2009 Martin Szulecki All Rights Reserved.   *   * This library is free software; you can redistribute it and/or @@ -52,6 +53,10 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)  			return MOBILEBACKUP_E_PLIST_ERROR;  		case DEVICE_LINK_SERVICE_E_MUX_ERROR:  			return MOBILEBACKUP_E_MUX_ERROR; +		case DEVICE_LINK_SERVICE_E_SSL_ERROR: +			return MOBILEBACKUP_E_SSL_ERROR; +		case DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT: +			return MOBILEBACKUP_E_RECEIVE_TIMEOUT;  		case DEVICE_LINK_SERVICE_E_BAD_VERSION:  			return MOBILEBACKUP_E_BAD_VERSION;  		default: diff --git a/src/mobilebackup.h b/src/mobilebackup.h index 19b9999..edda70f 100644 --- a/src/mobilebackup.h +++ b/src/mobilebackup.h @@ -2,6 +2,7 @@   * mobilebackup.h   * Definitions for the mobilebackup service   * + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   * Copyright (c) 2009 Martin Szulecki All Rights Reserved.   *   * This library is free software; you can redistribute it and/or diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c index 08ce22b..e7cc581 100644 --- a/src/mobilebackup2.c +++ b/src/mobilebackup2.c @@ -2,7 +2,7 @@   * mobilebackup2.c   * Contains functions for the built-in MobileBackup2 client (iOS4+ only)   * - * Copyright (c) 2010 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -53,6 +53,10 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err  			return MOBILEBACKUP2_E_PLIST_ERROR;  		case DEVICE_LINK_SERVICE_E_MUX_ERROR:  			return MOBILEBACKUP2_E_MUX_ERROR; +		case DEVICE_LINK_SERVICE_E_SSL_ERROR: +			return MOBILEBACKUP2_E_SSL_ERROR; +		case DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT: +			return MOBILEBACKUP2_E_RECEIVE_TIMEOUT;  		case DEVICE_LINK_SERVICE_E_BAD_VERSION:  			return MOBILEBACKUP2_E_BAD_VERSION;  		default: diff --git a/src/mobilebackup2.h b/src/mobilebackup2.h index 4dba22a..025b6bf 100644 --- a/src/mobilebackup2.h +++ b/src/mobilebackup2.h @@ -2,7 +2,7 @@   * mobilebackup2.h   * Definitions for the mobilebackup2 service (iOS4+)   * - * Copyright (c) 2010 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public diff --git a/src/mobilesync.c b/src/mobilesync.c index d903cfe..b0efc80 100644 --- a/src/mobilesync.c +++ b/src/mobilesync.c @@ -57,6 +57,10 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)  			return MOBILESYNC_E_PLIST_ERROR;  		case DEVICE_LINK_SERVICE_E_MUX_ERROR:  			return MOBILESYNC_E_MUX_ERROR; +		case DEVICE_LINK_SERVICE_E_SSL_ERROR: +			return MOBILESYNC_E_SSL_ERROR; +		case DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT: +			return MOBILESYNC_E_RECEIVE_TIMEOUT;  		case DEVICE_LINK_SERVICE_E_BAD_VERSION:  			return MOBILESYNC_E_BAD_VERSION;  		default: diff --git a/src/screenshotr.c b/src/screenshotr.c index 5c4a53f..ddb9d6e 100644 --- a/src/screenshotr.c +++ b/src/screenshotr.c @@ -2,7 +2,7 @@   * screenshotr.c   * com.apple.mobile.screenshotr service implementation.   * - * Copyright (c) 2010 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.   *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -50,6 +50,10 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)  			return SCREENSHOTR_E_PLIST_ERROR;  		case DEVICE_LINK_SERVICE_E_MUX_ERROR:  			return SCREENSHOTR_E_MUX_ERROR; +		case DEVICE_LINK_SERVICE_E_SSL_ERROR: +			return SCREENSHOTR_E_SSL_ERROR; +		case DEVICE_LINK_SERVICE_E_RECEIVE_TIMEOUT: +			return SCREENSHOTR_E_RECEIVE_TIMEOUT;  		case DEVICE_LINK_SERVICE_E_BAD_VERSION:  			return SCREENSHOTR_E_BAD_VERSION;  		default: | 
