diff options
Diffstat (limited to 'dev')
| -rwxr-xr-x | dev/msync.py | 2 | ||||
| -rw-r--r-- | dev/msyncclient.c | 109 |
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() : | |||
| 12 | if not lckd : | 12 | if not lckd : |
| 13 | print "Failed to start lockdown service.\n" | 13 | print "Failed to start lockdown service.\n" |
| 14 | return None | 14 | return None |
| 15 | msync = lckd.get_mobile_sync_client() | 15 | msync = lckd.get_mobilesync_client() |
| 16 | if not msync : | 16 | if not msync : |
| 17 | print "Failed to start mobilesync service.\n" | 17 | print "Failed to start mobilesync service.\n" |
| 18 | return None | 18 | 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 @@ | |||
| 26 | 26 | ||
| 27 | #include <libiphone/libiphone.h> | 27 | #include <libiphone/libiphone.h> |
| 28 | #include <libiphone/lockdown.h> | 28 | #include <libiphone/lockdown.h> |
| 29 | #include <libiphone/mobilesync.h> | ||
| 30 | |||
| 31 | static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) | ||
| 32 | { | ||
| 33 | if (!client) | ||
| 34 | return IPHONE_E_INVALID_ARG; | ||
| 35 | |||
| 36 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | ||
| 37 | plist_t array = NULL; | ||
| 38 | |||
| 39 | array = plist_new_array(); | ||
| 40 | plist_add_sub_string_el(array, "SDMessageSyncDataClassWithDevice"); | ||
| 41 | plist_add_sub_string_el(array, "com.apple.Contacts"); | ||
| 42 | plist_add_sub_string_el(array, "---"); | ||
| 43 | plist_add_sub_string_el(array, "2009-01-09 18:03:58 +0100"); | ||
| 44 | plist_add_sub_uint_el(array, 106); | ||
| 45 | plist_add_sub_string_el(array, "___EmptyParameterString___"); | ||
| 46 | |||
| 47 | ret = mobilesync_send(client, array); | ||
| 48 | plist_free(array); | ||
| 49 | array = NULL; | ||
| 50 | |||
| 51 | ret = mobilesync_recv(client, &array); | ||
| 52 | |||
| 53 | plist_t rep_node = plist_find_node_by_string(array, "SDSyncTypeSlow"); | ||
| 54 | |||
| 55 | if (!rep_node) | ||
| 56 | return ret; | ||
| 57 | |||
| 58 | plist_free(array); | ||
| 59 | array = NULL; | ||
| 60 | |||
| 61 | array = plist_new_array(); | ||
| 62 | plist_add_sub_string_el(array, "SDMessageGetAllRecordsFromDevice"); | ||
| 63 | plist_add_sub_string_el(array, "com.apple.Contacts"); | ||
| 64 | |||
| 65 | |||
| 66 | ret = mobilesync_send(client, array); | ||
| 67 | plist_free(array); | ||
| 68 | array = NULL; | ||
| 69 | |||
| 70 | ret = mobilesync_recv(client, &array); | ||
| 71 | |||
| 72 | plist_t contact_node; | ||
| 73 | plist_t switch_node; | ||
| 74 | |||
| 75 | contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); | ||
| 76 | switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); | ||
| 77 | |||
| 78 | while (NULL == switch_node) { | ||
| 79 | |||
| 80 | plist_free(array); | ||
| 81 | array = NULL; | ||
| 82 | |||
| 83 | array = plist_new_array(); | ||
| 84 | plist_add_sub_string_el(array, "SDMessageAcknowledgeChangesFromDevice"); | ||
| 85 | plist_add_sub_string_el(array, "com.apple.Contacts"); | ||
| 86 | |||
| 87 | ret = mobilesync_send(client, array); | ||
| 88 | plist_free(array); | ||
| 89 | array = NULL; | ||
| 90 | |||
| 91 | ret = mobilesync_recv(client, &array); | ||
| 92 | |||
| 93 | contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); | ||
| 94 | switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); | ||
| 95 | } | ||
| 96 | |||
| 97 | array = plist_new_array(); | ||
| 98 | plist_add_sub_string_el(array, "DLMessagePing"); | ||
| 99 | plist_add_sub_string_el(array, "Preparing to get changes for device"); | ||
| 100 | |||
| 101 | ret = mobilesync_send(client, array); | ||
| 102 | plist_free(array); | ||
| 103 | array = NULL; | ||
| 104 | |||
| 105 | array = plist_new_array(); | ||
| 106 | plist_add_sub_string_el(array, "SDMessageProcessChanges"); | ||
| 107 | plist_add_sub_string_el(array, "com.apple.Contacts"); | ||
| 108 | plist_add_sub_node(array, plist_new_dict()); | ||
| 109 | plist_add_sub_bool_el(array, 0); | ||
| 110 | plist_t dict = plist_new_dict(); | ||
| 111 | plist_add_sub_node(array, dict); | ||
| 112 | plist_add_sub_key_el(dict, "SyncDeviceLinkEntityNamesKey"); | ||
| 113 | plist_t array2 = plist_new_array(); | ||
| 114 | plist_add_sub_string_el(array2, "com.apple.contacts.Contact"); | ||
| 115 | plist_add_sub_string_el(array2, "com.apple.contacts.Group"); | ||
| 116 | plist_add_sub_key_el(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey"); | ||
| 117 | plist_add_sub_bool_el(dict, 0); | ||
| 118 | |||
| 119 | ret = mobilesync_send(client, array); | ||
| 120 | plist_free(array); | ||
| 121 | array = NULL; | ||
| 122 | |||
| 123 | ret = mobilesync_recv(client, &array); | ||
| 124 | plist_free(array); | ||
| 125 | array = NULL; | ||
| 126 | |||
| 127 | |||
| 128 | return ret; | ||
| 129 | } | ||
| 29 | 130 | ||
| 30 | int main(int argc, char *argv[]) | 131 | int main(int argc, char *argv[]) |
| 31 | { | 132 | { |
| @@ -50,11 +151,11 @@ int main(int argc, char *argv[]) | |||
| 50 | lockdownd_start_service(client, "com.apple.mobilesync", &port); | 151 | lockdownd_start_service(client, "com.apple.mobilesync", &port); |
| 51 | 152 | ||
| 52 | if (port) { | 153 | if (port) { |
| 53 | iphone_msync_client_t msync = NULL; | 154 | mobilesync_client_t msync = NULL; |
| 54 | iphone_msync_new_client(phone, port, &msync); | 155 | mobilesync_new_client(phone, port, &msync); |
| 55 | if (msync) { | 156 | if (msync) { |
| 56 | iphone_msync_get_all_contacts(msync); | 157 | mobilesync_get_all_contacts(msync); |
| 57 | iphone_msync_free_client(msync); | 158 | mobilesync_free_client(msync); |
| 58 | } | 159 | } |
| 59 | } else { | 160 | } else { |
| 60 | printf("Start service failure.\n"); | 161 | printf("Start service failure.\n"); |
