diff options
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 @@ | |||
| 27 | #include <libiphone/lockdown.h> | 27 | #include <libiphone/lockdown.h> |
| 28 | #include <libiphone/mobilesync.h> | 28 | #include <libiphone/mobilesync.h> |
| 29 | 29 | ||
| 30 | static char check_string(plist_t node, char* string) | ||
| 31 | { | ||
| 32 | char ret = 1; | ||
| 33 | char* msg = NULL; | ||
| 34 | plist_type type = plist_get_node_type(node); | ||
| 35 | if (PLIST_STRING == type) { | ||
| 36 | plist_get_string_val(node, &msg); | ||
| 37 | } | ||
| 38 | if (PLIST_STRING != type || strcmp(msg, string)) { | ||
| 39 | log_debug_msg("%s: ERROR: MobileSync client did not find %s !\n", __func__, string); | ||
| 40 | ret = 0; | ||
| 41 | } | ||
| 42 | free(msg); | ||
| 43 | msg = NULL; | ||
| 44 | return ret; | ||
| 45 | } | ||
| 46 | |||
| 30 | static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) | 47 | static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) |
| 31 | { | 48 | { |
| 32 | if (!client) | 49 | if (!client) |
| @@ -49,11 +66,6 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client | |||
| 49 | 66 | ||
| 50 | ret = mobilesync_recv(client, &array); | 67 | ret = mobilesync_recv(client, &array); |
| 51 | 68 | ||
| 52 | plist_t rep_node = plist_find_node_by_string(array, "SDSyncTypeSlow"); | ||
| 53 | |||
| 54 | if (!rep_node) | ||
| 55 | return ret; | ||
| 56 | |||
| 57 | plist_free(array); | 69 | plist_free(array); |
| 58 | array = NULL; | 70 | array = NULL; |
| 59 | 71 | ||
| @@ -70,10 +82,12 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client | |||
| 70 | plist_t contact_node; | 82 | plist_t contact_node; |
| 71 | plist_t switch_node; | 83 | plist_t switch_node; |
| 72 | 84 | ||
| 73 | contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); | 85 | contact_node = plist_array_get_item(array, 0); |
| 74 | switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); | 86 | switch_node = plist_array_get_item(array, 0); |
| 75 | 87 | ||
| 76 | while (NULL == switch_node) { | 88 | while (NULL == switch_node |
| 89 | && check_string(contact_node, "com.apple.Contacts") | ||
| 90 | && check_string(switch_node, "SDMessageDeviceReadyToReceiveChanges")) { | ||
| 77 | 91 | ||
| 78 | plist_free(array); | 92 | plist_free(array); |
| 79 | array = NULL; | 93 | array = NULL; |
| @@ -88,8 +102,8 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client | |||
| 88 | 102 | ||
| 89 | ret = mobilesync_recv(client, &array); | 103 | ret = mobilesync_recv(client, &array); |
| 90 | 104 | ||
| 91 | contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); | 105 | contact_node = plist_array_get_item(array, 0); |
| 92 | switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); | 106 | switch_node = plist_array_get_item(array, 0); |
| 93 | } | 107 | } |
| 94 | 108 | ||
| 95 | array = plist_new_array(); | 109 | array = plist_new_array(); |
