diff options
author | Nikias Bassen | 2009-05-18 22:29:39 +0200 |
---|---|---|
committer | Matt Colyer | 2009-05-18 18:47:20 -0700 |
commit | 8eaac0513bfb238edec22d46320669f5c9c76542 (patch) | |
tree | 2db842339bf525d67017525bcbd3f4d35181e5ca /src/MobileSync.c | |
parent | dca1758c4f9602fc240c6a7c9ae45839e154d15f (diff) | |
download | libimobiledevice-8eaac0513bfb238edec22d46320669f5c9c76542.tar.gz libimobiledevice-8eaac0513bfb238edec22d46320669f5c9c76542.tar.bz2 |
Make use of usbmuxd and remove libusb dependencies
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/MobileSync.c')
-rw-r--r-- | src/MobileSync.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/MobileSync.c b/src/MobileSync.c index 58d0beb..7d6e947 100644 --- a/src/MobileSync.c +++ b/src/MobileSync.c @@ -22,29 +22,30 @@ #include "MobileSync.h" #include <plist/plist.h> #include <string.h> +#include <stdlib.h> #include <arpa/inet.h> #define MSYNC_VERSION_INT1 100 #define MSYNC_VERSION_INT2 100 -iphone_error_t iphone_msync_new_client(iphone_device_t device, int src_port, int dst_port, +iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port, iphone_msync_client_t * client) { - if (!device || src_port == 0 || dst_port == 0 || !client || *client) + if (!device || dst_port == 0 || !client || *client) return IPHONE_E_INVALID_ARG; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; - iphone_msync_client_t client_loc = (iphone_msync_client_t) malloc(sizeof(struct iphone_msync_client_int)); - // Attempt connection - client_loc->connection = NULL; - ret = iphone_mux_new_client(device, src_port, dst_port, &client_loc->connection); - if (IPHONE_E_SUCCESS != ret || !client_loc->connection) { - free(client_loc); + int sfd = usbmuxd_connect(device->handle, dst_port); + if (sfd < 0) { return ret; } + + iphone_msync_client_t client_loc = (iphone_msync_client_t) malloc(sizeof(struct iphone_msync_client_int)); + client_loc->sfd = sfd; + //perform handshake plist_t array = NULL; @@ -120,7 +121,7 @@ iphone_error_t iphone_msync_free_client(iphone_msync_client_t client) return IPHONE_E_INVALID_ARG; iphone_msync_stop_session(client); - return iphone_mux_free_client(client->connection); + return usbmuxd_disconnect(client->sfd); } /** Polls the iPhone for MobileSync data. @@ -138,14 +139,14 @@ iphone_error_t iphone_msync_recv(iphone_msync_client_t client, plist_t * plist) char *receive = NULL; uint32_t datalen = 0, bytes = 0, received_bytes = 0; - ret = iphone_mux_recv(client->connection, (char *) &datalen, sizeof(datalen), &bytes); + ret = usbmuxd_recv(client->sfd, (char *) &datalen, sizeof(datalen), &bytes); datalen = ntohl(datalen); receive = (char *) malloc(sizeof(char) * datalen); /* fill buffer and request more packets if needed */ while ((received_bytes < datalen) && (ret == IPHONE_E_SUCCESS)) { - ret = iphone_mux_recv(client->connection, receive + received_bytes, datalen - received_bytes, &bytes); + ret = usbmuxd_recv(client->sfd, receive + received_bytes, datalen - received_bytes, &bytes); received_bytes += bytes; } @@ -201,7 +202,7 @@ iphone_error_t iphone_msync_send(iphone_msync_client_t client, plist_t plist) memcpy(real_query, &length, sizeof(length)); memcpy(real_query + 4, content, ntohl(length)); - ret = iphone_mux_send(client->connection, real_query, ntohl(length) + sizeof(length), &bytes); + ret = usbmuxd_send(client->sfd, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); free(real_query); return ret; } |