summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rwxr-xr-xdev/msync.py2
-rw-r--r--dev/msyncclient.c109
2 files changed, 106 insertions, 5 deletions
diff --git a/dev/msync.py b/dev/msync.py
index 17e3121..fe7f1fd 100755
--- a/dev/msync.py
+++ b/dev/msync.py
@@ -12,7 +12,7 @@ def GetMobileSyncClient() :
if not lckd :
print "Failed to start lockdown service.\n"
return None
- msync = lckd.get_mobile_sync_client()
+ msync = lckd.get_mobilesync_client()
if not msync :
print "Failed to start mobilesync service.\n"
return None
diff --git a/dev/msyncclient.c b/dev/msyncclient.c
index e06a5fe..5eb105d 100644
--- a/dev/msyncclient.c
+++ b/dev/msyncclient.c
@@ -26,6 +26,107 @@
#include <libiphone/libiphone.h>
#include <libiphone/lockdown.h>
+#include <libiphone/mobilesync.h>
+
+static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client)
+{
+ if (!client)
+ return IPHONE_E_INVALID_ARG;
+
+ iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
+ plist_t array = NULL;
+
+ array = plist_new_array();
+ plist_add_sub_string_el(array, "SDMessageSyncDataClassWithDevice");
+ plist_add_sub_string_el(array, "com.apple.Contacts");
+ plist_add_sub_string_el(array, "---");
+ plist_add_sub_string_el(array, "2009-01-09 18:03:58 +0100");
+ plist_add_sub_uint_el(array, 106);
+ plist_add_sub_string_el(array, "___EmptyParameterString___");
+
+ ret = mobilesync_send(client, array);
+ plist_free(array);
+ array = NULL;
+
+ 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;
+
+ array = plist_new_array();
+ plist_add_sub_string_el(array, "SDMessageGetAllRecordsFromDevice");
+ plist_add_sub_string_el(array, "com.apple.Contacts");
+
+
+ ret = mobilesync_send(client, array);
+ plist_free(array);
+ array = NULL;
+
+ ret = mobilesync_recv(client, &array);
+
+ 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");
+
+ while (NULL == switch_node) {
+
+ plist_free(array);
+ array = NULL;
+
+ array = plist_new_array();
+ plist_add_sub_string_el(array, "SDMessageAcknowledgeChangesFromDevice");
+ plist_add_sub_string_el(array, "com.apple.Contacts");
+
+ ret = mobilesync_send(client, array);
+ plist_free(array);
+ array = NULL;
+
+ 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");
+ }
+
+ array = plist_new_array();
+ plist_add_sub_string_el(array, "DLMessagePing");
+ plist_add_sub_string_el(array, "Preparing to get changes for device");
+
+ ret = mobilesync_send(client, array);
+ plist_free(array);
+ array = NULL;
+
+ array = plist_new_array();
+ plist_add_sub_string_el(array, "SDMessageProcessChanges");
+ plist_add_sub_string_el(array, "com.apple.Contacts");
+ plist_add_sub_node(array, plist_new_dict());
+ plist_add_sub_bool_el(array, 0);
+ plist_t dict = plist_new_dict();
+ plist_add_sub_node(array, dict);
+ plist_add_sub_key_el(dict, "SyncDeviceLinkEntityNamesKey");
+ plist_t array2 = plist_new_array();
+ plist_add_sub_string_el(array2, "com.apple.contacts.Contact");
+ plist_add_sub_string_el(array2, "com.apple.contacts.Group");
+ plist_add_sub_key_el(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey");
+ plist_add_sub_bool_el(dict, 0);
+
+ ret = mobilesync_send(client, array);
+ plist_free(array);
+ array = NULL;
+
+ ret = mobilesync_recv(client, &array);
+ plist_free(array);
+ array = NULL;
+
+
+ return ret;
+}
int main(int argc, char *argv[])
{
@@ -50,11 +151,11 @@ int main(int argc, char *argv[])
lockdownd_start_service(client, "com.apple.mobilesync", &port);
if (port) {
- iphone_msync_client_t msync = NULL;
- iphone_msync_new_client(phone, port, &msync);
+ mobilesync_client_t msync = NULL;
+ mobilesync_new_client(phone, port, &msync);
if (msync) {
- iphone_msync_get_all_contacts(msync);
- iphone_msync_free_client(msync);
+ mobilesync_get_all_contacts(msync);
+ mobilesync_free_client(msync);
}
} else {
printf("Start service failure.\n");