diff options
| author | 2011-03-27 15:29:53 +0200 | |
|---|---|---|
| committer | 2011-03-27 15:29:53 +0200 | |
| commit | 4910673fea64fc189e190e2039e869b9d6542e02 (patch) | |
| tree | 48846b2a9b66a44114f7bf72aef36a78f4c5edd1 /dev/msyncclient.c | |
| parent | 63fab95b502531f80ad087a16f9c40130fbe9559 (diff) | |
| download | libimobiledevice-4910673fea64fc189e190e2039e869b9d6542e02.tar.gz libimobiledevice-4910673fea64fc189e190e2039e869b9d6542e02.tar.bz2 | |
dev: Get rid of msyncclient as it does not use our new mobilesync API
Diffstat (limited to 'dev/msyncclient.c')
| -rw-r--r-- | dev/msyncclient.c | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/dev/msyncclient.c b/dev/msyncclient.c deleted file mode 100644 index b9e39e6..0000000 --- a/dev/msyncclient.c +++ /dev/null | |||
| @@ -1,180 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * msyncclient.c | ||
| 3 | * Rudimentary interface to the MobileSync service. | ||
| 4 | * | ||
| 5 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdio.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <errno.h> | ||
| 25 | |||
| 26 | #include <libimobiledevice/libimobiledevice.h> | ||
| 27 | #include <libimobiledevice/lockdown.h> | ||
| 28 | #include <libimobiledevice/mobilesync.h> | ||
| 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 | printf("%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 | |||
| 47 | static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) | ||
| 48 | { | ||
| 49 | if (!client) | ||
| 50 | return MOBILESYNC_E_INVALID_ARG; | ||
| 51 | |||
| 52 | mobilesync_error_t ret = MOBILESYNC_E_UNKNOWN_ERROR; | ||
| 53 | plist_t array = NULL; | ||
| 54 | |||
| 55 | array = plist_new_array(); | ||
| 56 | plist_array_append_item(array, plist_new_string("SDMessageSyncDataClassWithDevice")); | ||
| 57 | plist_array_append_item(array, plist_new_string("com.apple.Contacts")); | ||
| 58 | plist_array_append_item(array, plist_new_string("---")); | ||
| 59 | plist_array_append_item(array, plist_new_string("2009-01-09 18:03:58 +0100")); | ||
| 60 | plist_array_append_item(array, plist_new_uint(106)); | ||
| 61 | plist_array_append_item(array, plist_new_string("___EmptyParameterString___")); | ||
| 62 | |||
| 63 | ret = mobilesync_send(client, array); | ||
| 64 | plist_free(array); | ||
| 65 | array = NULL; | ||
| 66 | |||
| 67 | ret = mobilesync_receive(client, &array); | ||
| 68 | |||
| 69 | plist_free(array); | ||
| 70 | array = NULL; | ||
| 71 | |||
| 72 | array = plist_new_array(); | ||
| 73 | plist_array_append_item(array, plist_new_string("SDMessageGetAllRecordsFromDevice")); | ||
| 74 | plist_array_append_item(array, plist_new_string("com.apple.Contacts")); | ||
| 75 | |||
| 76 | ret = mobilesync_send(client, array); | ||
| 77 | plist_free(array); | ||
| 78 | array = NULL; | ||
| 79 | |||
| 80 | ret = mobilesync_receive(client, &array); | ||
| 81 | |||
| 82 | plist_t contact_node; | ||
| 83 | plist_t switch_node; | ||
| 84 | |||
| 85 | contact_node = plist_array_get_item(array, 0); | ||
| 86 | switch_node = plist_array_get_item(array, 0); | ||
| 87 | |||
| 88 | while (NULL == switch_node | ||
| 89 | && check_string(contact_node, "com.apple.Contacts") | ||
| 90 | && check_string(switch_node, "SDMessageDeviceReadyToReceiveChanges")) { | ||
| 91 | |||
| 92 | plist_free(array); | ||
| 93 | array = NULL; | ||
| 94 | |||
| 95 | array = plist_new_array(); | ||
| 96 | plist_array_append_item(array, plist_new_string("SDMessageAcknowledgeChangesFromDevice")); | ||
| 97 | plist_array_append_item(array, plist_new_string("com.apple.Contacts")); | ||
| 98 | |||
| 99 | ret = mobilesync_send(client, array); | ||
| 100 | plist_free(array); | ||
| 101 | array = NULL; | ||
| 102 | |||
| 103 | ret = mobilesync_receive(client, &array); | ||
| 104 | |||
| 105 | contact_node = plist_array_get_item(array, 0); | ||
| 106 | switch_node = plist_array_get_item(array, 0); | ||
| 107 | } | ||
| 108 | |||
| 109 | array = plist_new_array(); | ||
| 110 | plist_array_append_item(array, plist_new_string("DLMessagePing")); | ||
| 111 | plist_array_append_item(array, plist_new_string("Preparing to get changes for device")); | ||
| 112 | |||
| 113 | ret = mobilesync_send(client, array); | ||
| 114 | plist_free(array); | ||
| 115 | array = NULL; | ||
| 116 | |||
| 117 | array = plist_new_array(); | ||
| 118 | plist_array_append_item(array, plist_new_string("SDMessageProcessChanges")); | ||
| 119 | plist_array_append_item(array, plist_new_string("com.apple.Contacts")); | ||
| 120 | plist_array_append_item(array, plist_new_dict()); | ||
| 121 | plist_array_append_item(array, plist_new_bool(0)); | ||
| 122 | |||
| 123 | plist_t dict = plist_new_dict(); | ||
| 124 | plist_array_append_item(array, dict); | ||
| 125 | plist_t array2 = plist_new_array(); | ||
| 126 | plist_dict_insert_item(dict, "SyncDeviceLinkEntityNamesKey", array2); | ||
| 127 | plist_array_append_item(array2, plist_new_string("com.apple.contacts.Contact")); | ||
| 128 | plist_array_append_item(array2, plist_new_string("com.apple.contacts.Group")); | ||
| 129 | plist_dict_insert_item(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0)); | ||
| 130 | |||
| 131 | ret = mobilesync_send(client, array); | ||
| 132 | plist_free(array); | ||
| 133 | array = NULL; | ||
| 134 | |||
| 135 | ret = mobilesync_receive(client, &array); | ||
| 136 | plist_free(array); | ||
| 137 | array = NULL; | ||
| 138 | |||
| 139 | return ret; | ||
| 140 | } | ||
| 141 | |||
| 142 | int main(int argc, char *argv[]) | ||
| 143 | { | ||
| 144 | uint16_t port = 0; | ||
| 145 | lockdownd_client_t client = NULL; | ||
| 146 | idevice_t phone = NULL; | ||
| 147 | |||
| 148 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) | ||
| 149 | idevice_set_debug_level(1); | ||
| 150 | |||
| 151 | if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) { | ||
| 152 | printf("No device found, is it plugged in?\n"); | ||
| 153 | return -1; | ||
| 154 | } | ||
| 155 | |||
| 156 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "msyncclient")) { | ||
| 157 | idevice_free(phone); | ||
| 158 | return -1; | ||
| 159 | } | ||
| 160 | |||
| 161 | lockdownd_start_service(client, "com.apple.mobilesync", &port); | ||
| 162 | |||
| 163 | if (port) { | ||
| 164 | mobilesync_client_t msync = NULL; | ||
| 165 | mobilesync_client_new(phone, port, &msync); | ||
| 166 | if (msync) { | ||
| 167 | mobilesync_get_all_contacts(msync); | ||
| 168 | mobilesync_client_free(msync); | ||
| 169 | } | ||
| 170 | } else { | ||
| 171 | printf("Start service failure.\n"); | ||
| 172 | } | ||
| 173 | |||
| 174 | printf("All done.\n"); | ||
| 175 | |||
| 176 | lockdownd_client_free(client); | ||
| 177 | idevice_free(phone); | ||
| 178 | |||
| 179 | return 0; | ||
| 180 | } | ||
