diff options
| author | 2009-09-10 13:28:13 +0200 | |
|---|---|---|
| committer | 2009-09-12 11:41:38 +0200 | |
| commit | 1f6282ffddec7012df82fa929dfe72cfc74b063a (patch) | |
| tree | 452c927c07806855f360ee9803111a1f72e05d3c /src/MobileSync.c | |
| parent | 26ce10634d277df51c4e9c2bd61b409df3f5b060 (diff) | |
| download | libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.gz libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.bz2 | |
Public API rework, extension and adaption to latest libusbmuxd-1.0 API.
Diffstat (limited to 'src/MobileSync.c')
| -rw-r--r-- | src/MobileSync.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/MobileSync.c b/src/MobileSync.c index 4463251..8a7d724 100644 --- a/src/MobileSync.c +++ b/src/MobileSync.c | |||
| @@ -40,13 +40,13 @@ mobilesync_error_t mobilesync_client_new(iphone_device_t device, int dst_port, | |||
| 40 | mobilesync_error_t ret = MOBILESYNC_E_UNKNOWN_ERROR; | 40 | mobilesync_error_t ret = MOBILESYNC_E_UNKNOWN_ERROR; |
| 41 | 41 | ||
| 42 | /* Attempt connection */ | 42 | /* Attempt connection */ |
| 43 | int sfd = usbmuxd_connect(device->handle, dst_port); | 43 | iphone_connection_t connection = NULL; |
| 44 | if (sfd < 0) { | 44 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { |
| 45 | return ret; | 45 | return ret; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | mobilesync_client_t client_loc = (mobilesync_client_t) malloc(sizeof(struct mobilesync_client_int)); | 48 | mobilesync_client_t client_loc = (mobilesync_client_t) malloc(sizeof(struct mobilesync_client_int)); |
| 49 | client_loc->sfd = sfd; | 49 | client_loc->connection = connection; |
| 50 | 50 | ||
| 51 | /* perform handshake */ | 51 | /* perform handshake */ |
| 52 | plist_t array = NULL; | 52 | plist_t array = NULL; |
| @@ -126,7 +126,7 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client) | |||
| 126 | return IPHONE_E_INVALID_ARG; | 126 | return IPHONE_E_INVALID_ARG; |
| 127 | 127 | ||
| 128 | mobilesync_disconnect(client); | 128 | mobilesync_disconnect(client); |
| 129 | return (usbmuxd_disconnect(client->sfd) == 0 ? MOBILESYNC_E_SUCCESS: MOBILESYNC_E_MUX_ERROR); | 129 | return (iphone_device_disconnect(client->connection) == 0 ? MOBILESYNC_E_SUCCESS: MOBILESYNC_E_MUX_ERROR); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | /** Polls the iPhone for MobileSync data. | 132 | /** Polls the iPhone for MobileSync data. |
| @@ -144,14 +144,14 @@ mobilesync_error_t mobilesync_recv(mobilesync_client_t client, plist_t * plist) | |||
| 144 | char *receive = NULL; | 144 | char *receive = NULL; |
| 145 | uint32_t datalen = 0, bytes = 0, received_bytes = 0; | 145 | uint32_t datalen = 0, bytes = 0, received_bytes = 0; |
| 146 | 146 | ||
| 147 | ret = usbmuxd_recv(client->sfd, (char *) &datalen, sizeof(datalen), &bytes); | 147 | ret = iphone_device_recv(client->connection, (char *) &datalen, sizeof(datalen), &bytes); |
| 148 | datalen = ntohl(datalen); | 148 | datalen = ntohl(datalen); |
| 149 | 149 | ||
| 150 | receive = (char *) malloc(sizeof(char) * datalen); | 150 | receive = (char *) malloc(sizeof(char) * datalen); |
| 151 | 151 | ||
| 152 | /* fill buffer and request more packets if needed */ | 152 | /* fill buffer and request more packets if needed */ |
| 153 | while ((received_bytes < datalen) && (ret == MOBILESYNC_E_SUCCESS)) { | 153 | while ((received_bytes < datalen) && (ret == MOBILESYNC_E_SUCCESS)) { |
| 154 | ret = usbmuxd_recv(client->sfd, receive + received_bytes, datalen - received_bytes, &bytes); | 154 | ret = iphone_device_recv(client->connection, receive + received_bytes, datalen - received_bytes, &bytes); |
| 155 | received_bytes += bytes; | 155 | received_bytes += bytes; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| @@ -207,7 +207,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist) | |||
| 207 | memcpy(real_query, &length, sizeof(length)); | 207 | memcpy(real_query, &length, sizeof(length)); |
| 208 | memcpy(real_query + 4, content, ntohl(length)); | 208 | memcpy(real_query + 4, content, ntohl(length)); |
| 209 | 209 | ||
| 210 | ret = usbmuxd_send(client->sfd, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); | 210 | ret = iphone_device_send(client->connection, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); |
| 211 | free(real_query); | 211 | free(real_query); |
| 212 | return (ret == 0 ? MOBILESYNC_E_SUCCESS: MOBILESYNC_E_MUX_ERROR); | 212 | return (ret == 0 ? MOBILESYNC_E_SUCCESS: MOBILESYNC_E_MUX_ERROR); |
| 213 | } | 213 | } |
