summaryrefslogtreecommitdiffstats
path: root/src/restore.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-09-25 19:29:28 +0200
committerGravatar Nikias Bassen2019-09-25 19:29:28 +0200
commitacf0a76be3c81a8ce69817af2b16a546a08f7ecb (patch)
tree5dccd332d1c3e8a0fdd02bd14703ee0c53f14d91 /src/restore.c
parenta9e69b1252e5918b6d8ada1209ccefde301cfa26 (diff)
downloadlibimobiledevice-acf0a76be3c81a8ce69817af2b16a546a08f7ecb.tar.gz
libimobiledevice-acf0a76be3c81a8ce69817af2b16a546a08f7ecb.tar.bz2
restore: Update error codes and properly convert underlying property_list_service errors
Diffstat (limited to 'src/restore.c')
-rw-r--r--src/restore.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/restore.c b/src/restore.c
index 6571a2f..0a13698 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -89,6 +89,25 @@ static void plist_dict_add_label(plist_t plist, const char *label)
89 } 89 }
90} 90}
91 91
92static restored_error_t restored_error(property_list_service_error_t err)
93{
94 switch (err) {
95 case PROPERTY_LIST_SERVICE_E_SUCCESS:
96 return RESTORE_E_SUCCESS;
97 case PROPERTY_LIST_SERVICE_E_INVALID_ARG:
98 return RESTORE_E_INVALID_ARG;
99 case PROPERTY_LIST_SERVICE_E_PLIST_ERROR:
100 return RESTORE_E_PLIST_ERROR;
101 case PROPERTY_LIST_SERVICE_E_MUX_ERROR:
102 return RESTORE_E_MUX_ERROR;
103 case PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT:
104 return RESTORE_E_RECEIVE_TIMEOUT;
105 default:
106 break;
107 }
108 return RESTORE_E_UNKNOWN_ERROR;
109}
110
92LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client) 111LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client)
93{ 112{
94 if (!client) 113 if (!client)
@@ -99,9 +118,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t cli
99 if (client->parent) { 118 if (client->parent) {
100 restored_goodbye(client); 119 restored_goodbye(client);
101 120
102 if (property_list_service_client_free(client->parent) == PROPERTY_LIST_SERVICE_E_SUCCESS) { 121 ret = restored_error(property_list_service_client_free(client->parent));
103 ret = RESTORE_E_SUCCESS;
104 }
105 } 122 }
106 123
107 if (client->udid) { 124 if (client->udid) {
@@ -134,18 +151,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client,
134 if (!client || !plist || (plist && *plist)) 151 if (!client || !plist || (plist && *plist))
135 return RESTORE_E_INVALID_ARG; 152 return RESTORE_E_INVALID_ARG;
136 153
137 restored_error_t ret = RESTORE_E_SUCCESS; 154 return restored_error(property_list_service_receive_plist(client->parent, plist));
138 property_list_service_error_t err;
139
140 err = property_list_service_receive_plist(client->parent, plist);
141 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
142 ret = RESTORE_E_UNKNOWN_ERROR;
143 }
144
145 if (!*plist)
146 ret = RESTORE_E_PLIST_ERROR;
147
148 return ret;
149} 155}
150 156
151LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist) 157LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist)
@@ -153,14 +159,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, pl
153 if (!client || !plist) 159 if (!client || !plist)
154 return RESTORE_E_INVALID_ARG; 160 return RESTORE_E_INVALID_ARG;
155 161
156 restored_error_t ret = RESTORE_E_SUCCESS; 162 return restored_error(property_list_service_send_xml_plist(client->parent, plist));
157 property_list_service_error_t err;
158
159 err = property_list_service_send_xml_plist(client->parent, plist);
160 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
161 ret = RESTORE_E_UNKNOWN_ERROR;
162 }
163 return ret;
164} 163}
165 164
166LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version) 165LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version)
@@ -305,9 +304,10 @@ LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, rest
305 }; 304 };
306 305
307 property_list_service_client_t plistclient = NULL; 306 property_list_service_client_t plistclient = NULL;
308 if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 307 ret = restored_error(property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient));
308 if (ret != RESTORE_E_SUCCESS) {
309 debug_info("could not connect to restored (device %s)", device->udid); 309 debug_info("could not connect to restored (device %s)", device->udid);
310 return RESTORE_E_MUX_ERROR; 310 return ret;
311 } 311 }
312 312
313 restored_client_t client_loc = (restored_client_t) malloc(sizeof(struct restored_client_private)); 313 restored_client_t client_loc = (restored_client_t) malloc(sizeof(struct restored_client_private));
@@ -321,7 +321,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, rest
321 idev_ret = idevice_get_udid(device, &client_loc->udid); 321 idev_ret = idevice_get_udid(device, &client_loc->udid);
322 if (IDEVICE_E_SUCCESS != idev_ret) { 322 if (IDEVICE_E_SUCCESS != idev_ret) {
323 debug_info("failed to get device udid."); 323 debug_info("failed to get device udid.");
324 ret = RESTORE_E_DEVICE_ERROR; 324 ret = RESTORE_E_UNKNOWN_ERROR;
325 } 325 }
326 debug_info("device udid: %s", client_loc->udid); 326 debug_info("device udid: %s", client_loc->udid);
327 327