summaryrefslogtreecommitdiffstats
path: root/dev
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 /dev
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 'dev')
-rw-r--r--dev/msyncclient.c34
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();