summaryrefslogtreecommitdiffstats
path: root/src/MobileSync.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-11-10 23:31:49 +0100
committerGravatar Matt Colyer2009-11-11 07:33:08 -0800
commiteaf80002c6e82c6b7a376bb61c9884ec3cf750b4 (patch)
treefc273d59ad7e5db3db2aba1006bebc6d8e0ac28d /src/MobileSync.c
parentfdf94756f8f6a9fc9d218725f429d64fd91d7679 (diff)
downloadlibimobiledevice-eaf80002c6e82c6b7a376bb61c9884ec3cf750b4.tar.gz
libimobiledevice-eaf80002c6e82c6b7a376bb61c9884ec3cf750b4.tar.bz2
Finish migration to latest plist API.
[#77 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/MobileSync.c')
-rw-r--r--src/MobileSync.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/MobileSync.c b/src/MobileSync.c
index 9e52f32..77d2710 100644
--- a/src/MobileSync.c
+++ b/src/MobileSync.c
@@ -54,9 +54,21 @@ mobilesync_error_t mobilesync_client_new(iphone_device_t device, int dst_port,
/* first receive version */
ret = mobilesync_recv(client_loc, &array);
- plist_t msg_node = plist_find_node_by_string(array, "DLMessageVersionExchange");
- plist_t ver_1 = plist_get_next_sibling(msg_node);
- plist_t ver_2 = plist_get_next_sibling(ver_1);
+ plist_t msg_node = plist_array_get_item(array, 0);
+
+ char* msg = NULL;
+ plist_type type = plist_get_node_type(msg_node);
+ if (PLIST_STRING == type) {
+ plist_get_string_val(msg_node, &msg);
+ }
+ if (PLIST_STRING != type || strcmp(msg, "DLMessageVersionExchange") || plist_array_get_size(array) < 3) {
+ log_debug_msg("%s: ERROR: MobileSync client expected a version exchange !\n", __func__);
+ }
+ free(msg);
+ msg = NULL;
+
+ plist_t ver_1 = plist_array_get_item(array, 1);
+ plist_t ver_2 = plist_array_get_item(array, 2);
plist_type ver_1_type = plist_get_node_type(ver_1);
plist_type ver_2_type = plist_get_node_type(ver_2);
@@ -85,16 +97,24 @@ mobilesync_error_t mobilesync_client_new(iphone_device_t device, int dst_port,
array = NULL;
ret = mobilesync_recv(client_loc, &array);
- plist_t rep_node = plist_find_node_by_string(array, "DLMessageDeviceReady");
+ plist_t rep_node = plist_array_get_item(array, 0);
- if (rep_node) {
- ret = MOBILESYNC_E_SUCCESS;
- *client = client_loc;
+ type = plist_get_node_type(rep_node);
+ if (PLIST_STRING == type) {
+ plist_get_string_val(rep_node, &msg);
+ }
+ if (PLIST_STRING != type || strcmp(msg, "DLMessageDeviceReady")) {
+ log_debug_msg("%s: ERROR: MobileSync client failed to start session !\n", __func__);
+ ret = MOBILESYNC_E_BAD_VERSION;
}
else
{
- ret = MOBILESYNC_E_BAD_VERSION;
+ ret = MOBILESYNC_E_SUCCESS;
+ *client = client_loc;
}
+ free(msg);
+ msg = NULL;
+
plist_free(array);
array = NULL;
}