From 8eaac0513bfb238edec22d46320669f5c9c76542 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 18 May 2009 22:29:39 +0200 Subject: Make use of usbmuxd and remove libusb dependencies Signed-off-by: Matt Colyer --- dev/Makefile.am | 4 ++-- dev/afccheck.c | 2 +- dev/iphoneinfo.c | 6 +++--- dev/main.c | 15 +++++++++------ dev/msyncclient.c | 2 +- dev/syslog_relay.c | 25 ++++++++++++++----------- 6 files changed, 30 insertions(+), 24 deletions(-) (limited to 'dev') diff --git a/dev/Makefile.am b/dev/Makefile.am index 8afe2f9..3fa8f8c 100644 --- a/dev/Makefile.am +++ b/dev/Makefile.am @@ -1,7 +1,7 @@ INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) -AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) +AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) +AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneinfo iphonesyslog diff --git a/dev/afccheck.c b/dev/afccheck.c index 152a8df..2f7d92c 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) return 1; } - iphone_afc_new_client(phone, 3432, port, &afc); + iphone_afc_new_client(phone, port, &afc); //makes sure thread environment is available if (!g_thread_supported()) diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 4995b9b..409ad2d 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) } } - if (bus_n != -1) { +/* if (bus_n != -1) { ret = iphone_get_specific_device(bus_n, dev_n, &phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); @@ -70,13 +70,13 @@ int main(int argc, char *argv[]) } } else - { + {*/ ret = iphone_get_device(&phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found, is it plugged in?\n"); return -1; } - } +/* }*/ if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { iphone_free_device(phone); diff --git a/dev/main.c b/dev/main.c index 510c75f..5c9a5a7 100644 --- a/dev/main.c +++ b/dev/main.c @@ -42,7 +42,7 @@ void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, c iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); if (nport) { printf("::::::::::::::: np was started ::::::::::::\n"); - iphone_np_new_client(phone, 3555, nport, &np); + iphone_np_new_client(phone, nport, &np); if (np) { printf("::::::::: PostNotification %s\n", notification); iphone_np_post_notification(np, notification); @@ -98,12 +98,12 @@ int main(int argc, char *argv[]) if (port) { iphone_afc_client_t afc = NULL; - iphone_afc_new_client(phone, 3432, port, &afc); + iphone_afc_new_client(phone, port, &afc); if (afc) { iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); if (npp) { printf("Notification Proxy started.\n"); - iphone_np_new_client(phone, 3756, npp, &gnp); + iphone_np_new_client(phone, npp, &gnp); } else { printf("ERROR: Notification proxy could not be started.\n"); } @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) NULL }; iphone_np_observe_notifications(gnp, nspec); - //iphone_np_set_notify_callback(gnp, notifier); + iphone_np_set_notify_callback(gnp, notifier); } perform_notification(phone, control, NP_SYNC_WILL_START); @@ -209,15 +209,16 @@ int main(int argc, char *argv[]) if (gnp && lockfile) { char *noti; + /* noti = NULL; iphone_np_get_notification(gnp, ¬i); if (noti) { printf("------> received notification '%s'\n", noti); free(noti); - } + }*/ printf("XXX sleeping\n"); - for (i = 0; i < 5; i++) { + /*for (i = 0; i < 5; i++) { noti = NULL; printf("--- getting notification\n"); iphone_np_get_notification(gnp, ¬i); @@ -229,6 +230,8 @@ int main(int argc, char *argv[]) } sleep(1); } + */ + sleep(5); //perform_notification(phone, control, NP_SYNC_DID_FINISH); diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 804e1ed..e3bb0c2 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) if (port) { iphone_msync_client_t msync = NULL; - iphone_msync_new_client(phone, 3432, port, &msync); + iphone_msync_new_client(phone, port, &msync); if (msync) { iphone_msync_get_all_contacts(msync); iphone_msync_free_client(msync); diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 56cf56c..35c684a 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -27,6 +27,7 @@ #include #include +#include static int quit_flag = 0; @@ -78,7 +79,7 @@ int main(int argc, char *argv[]) } } - if (bus_n != -1) { +/* if (bus_n != -1) { ret = iphone_get_specific_device(bus_n, dev_n, &phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); @@ -86,13 +87,13 @@ int main(int argc, char *argv[]) } } else - { + {*/ ret = iphone_get_device(&phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found, is it plugged in?\n"); return -1; } - } +/* }*/ if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { iphone_free_device(phone); @@ -103,15 +104,19 @@ int main(int argc, char *argv[]) ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); if ((ret == IPHONE_E_SUCCESS) && port) { /* connect to socket relay messages */ - iphone_umux_client_t syslog_client = NULL; + //iphone_umux_client_t syslog_client = NULL; - ret = iphone_mux_new_client(phone, 514, port, &syslog_client); - if (ret == IPHONE_E_SUCCESS) { + //ret = iphone_mux_new_client(phone, 514, port, &syslog_client); + int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); + //if (ret == IPHONE_E_SUCCESS) { + if (sfd < 0) { + printf("ERROR: Could not open usbmux connection.\n"); + } else { while (!quit_flag) { char *receive = NULL; uint32_t datalen = 0, bytes = 0, recv_bytes = 0; - ret = iphone_mux_recv(syslog_client, (char *) &datalen, sizeof(datalen), &bytes); + ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); datalen = ntohl(datalen); if (datalen == 0) @@ -121,7 +126,7 @@ int main(int argc, char *argv[]) receive = (char *) malloc(sizeof(char) * datalen); while (!quit_flag && (recv_bytes <= datalen)) { - ret = iphone_mux_recv(syslog_client, receive, datalen, &bytes); + ret = usbmuxd_recv(sfd, receive, datalen, &bytes); if (bytes == 0) break; @@ -133,10 +138,8 @@ int main(int argc, char *argv[]) free(receive); } - } else { - printf("ERROR: Could not open usbmux connection.\n"); } - iphone_mux_free_client(syslog_client); + usbmuxd_disconnect(sfd); //iphone_mux_free_client(syslog_client); } else { printf("ERROR: Could not start service com.apple.syslog_relay.\n"); } -- cgit v1.1-32-gdbae