diff options
author | Martin Szulecki | 2009-11-11 21:26:33 +0100 |
---|---|---|
committer | Martin Szulecki | 2009-11-11 21:26:33 +0100 |
commit | fea0152549d5e77f914f75c0ac315f30f9e26426 (patch) | |
tree | 4d7064468d46a4d4dfbae7dfa9b0e7d812aeecda /dev | |
parent | d4bdab8bd7cc5030341d2bf13dbd006fc13a6a1c (diff) | |
parent | 28d1fcac0eda09e829ef8c8b46fad0e45590af16 (diff) | |
download | libimobiledevice-fea0152549d5e77f914f75c0ac315f30f9e26426.tar.gz libimobiledevice-fea0152549d5e77f914f75c0ac315f30f9e26426.tar.bz2 |
Merge branch 'master' of git://github.com/MattColyer/libiphone into martin
Diffstat (limited to 'dev')
-rw-r--r-- | dev/msyncclient.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/dev/msyncclient.c b/dev/msyncclient.c index b3cc81e..08092cb 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -27,6 +27,23 @@ #include <libiphone/lockdown.h> #include <libiphone/mobilesync.h> +static char check_string(plist_t node, char* string) +{ + char ret = 1; + char* msg = NULL; + plist_type type = plist_get_node_type(node); + if (PLIST_STRING == type) { + plist_get_string_val(node, &msg); + } + if (PLIST_STRING != type || strcmp(msg, string)) { + log_debug_msg("%s: ERROR: MobileSync client did not find %s !\n", __func__, string); + ret = 0; + } + free(msg); + msg = NULL; + return ret; +} + static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) { if (!client) @@ -49,11 +66,6 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client ret = mobilesync_recv(client, &array); - plist_t rep_node = plist_find_node_by_string(array, "SDSyncTypeSlow"); - - if (!rep_node) - return ret; - plist_free(array); array = NULL; @@ -70,10 +82,12 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client plist_t contact_node; plist_t switch_node; - contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); - switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); + contact_node = plist_array_get_item(array, 0); + switch_node = plist_array_get_item(array, 0); - while (NULL == switch_node) { + while (NULL == switch_node + && check_string(contact_node, "com.apple.Contacts") + && check_string(switch_node, "SDMessageDeviceReadyToReceiveChanges")) { plist_free(array); array = NULL; @@ -88,8 +102,8 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client ret = mobilesync_recv(client, &array); - contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); - switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); + contact_node = plist_array_get_item(array, 0); + switch_node = plist_array_get_item(array, 0); } array = plist_new_array(); |