diff options
| author | 2009-05-18 22:29:39 +0200 | |
|---|---|---|
| committer | 2009-05-18 18:47:20 -0700 | |
| commit | 8eaac0513bfb238edec22d46320669f5c9c76542 (patch) | |
| tree | 2db842339bf525d67017525bcbd3f4d35181e5ca /dev | |
| 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 'dev')
| -rw-r--r-- | dev/Makefile.am | 4 | ||||
| -rw-r--r-- | dev/afccheck.c | 2 | ||||
| -rw-r--r-- | dev/iphoneinfo.c | 6 | ||||
| -rw-r--r-- | dev/main.c | 15 | ||||
| -rw-r--r-- | dev/msyncclient.c | 2 | ||||
| -rw-r--r-- | dev/syslog_relay.c | 25 |
6 files changed, 30 insertions, 24 deletions
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 @@ | |||
| 1 | INCLUDES = -I$(top_srcdir)/include | 1 | INCLUDES = -I$(top_srcdir)/include |
| 2 | 2 | ||
| 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) | 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) |
| 4 | AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) |
| 5 | 5 | ||
| 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneinfo iphonesyslog | 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneinfo iphonesyslog |
| 7 | 7 | ||
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[]) | |||
| 106 | return 1; | 106 | return 1; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | iphone_afc_new_client(phone, 3432, port, &afc); | 109 | iphone_afc_new_client(phone, port, &afc); |
| 110 | 110 | ||
| 111 | //makes sure thread environment is available | 111 | //makes sure thread environment is available |
| 112 | if (!g_thread_supported()) | 112 | 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[]) | |||
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | if (bus_n != -1) { | 65 | /* if (bus_n != -1) { |
| 66 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); | 66 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); |
| 67 | if (ret != IPHONE_E_SUCCESS) { | 67 | if (ret != IPHONE_E_SUCCESS) { |
| 68 | printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); | 68 | 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[]) | |||
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | else | 72 | else |
| 73 | { | 73 | {*/ |
| 74 | ret = iphone_get_device(&phone); | 74 | ret = iphone_get_device(&phone); |
| 75 | if (ret != IPHONE_E_SUCCESS) { | 75 | if (ret != IPHONE_E_SUCCESS) { |
| 76 | printf("No device found, is it plugged in?\n"); | 76 | printf("No device found, is it plugged in?\n"); |
| 77 | return -1; | 77 | return -1; |
| 78 | } | 78 | } |
| 79 | } | 79 | /* }*/ |
| 80 | 80 | ||
| 81 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | 81 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { |
| 82 | iphone_free_device(phone); | 82 | iphone_free_device(phone); |
| @@ -42,7 +42,7 @@ void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, c | |||
| 42 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | 42 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); |
| 43 | if (nport) { | 43 | if (nport) { |
| 44 | printf("::::::::::::::: np was started ::::::::::::\n"); | 44 | printf("::::::::::::::: np was started ::::::::::::\n"); |
| 45 | iphone_np_new_client(phone, 3555, nport, &np); | 45 | iphone_np_new_client(phone, nport, &np); |
| 46 | if (np) { | 46 | if (np) { |
| 47 | printf("::::::::: PostNotification %s\n", notification); | 47 | printf("::::::::: PostNotification %s\n", notification); |
| 48 | iphone_np_post_notification(np, notification); | 48 | iphone_np_post_notification(np, notification); |
| @@ -98,12 +98,12 @@ int main(int argc, char *argv[]) | |||
| 98 | 98 | ||
| 99 | if (port) { | 99 | if (port) { |
| 100 | iphone_afc_client_t afc = NULL; | 100 | iphone_afc_client_t afc = NULL; |
| 101 | iphone_afc_new_client(phone, 3432, port, &afc); | 101 | iphone_afc_new_client(phone, port, &afc); |
| 102 | if (afc) { | 102 | if (afc) { |
| 103 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); | 103 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); |
| 104 | if (npp) { | 104 | if (npp) { |
| 105 | printf("Notification Proxy started.\n"); | 105 | printf("Notification Proxy started.\n"); |
| 106 | iphone_np_new_client(phone, 3756, npp, &gnp); | 106 | iphone_np_new_client(phone, npp, &gnp); |
| 107 | } else { | 107 | } else { |
| 108 | printf("ERROR: Notification proxy could not be started.\n"); | 108 | printf("ERROR: Notification proxy could not be started.\n"); |
| 109 | } | 109 | } |
| @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) | |||
| 115 | NULL | 115 | NULL |
| 116 | }; | 116 | }; |
| 117 | iphone_np_observe_notifications(gnp, nspec); | 117 | iphone_np_observe_notifications(gnp, nspec); |
| 118 | //iphone_np_set_notify_callback(gnp, notifier); | 118 | iphone_np_set_notify_callback(gnp, notifier); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | perform_notification(phone, control, NP_SYNC_WILL_START); | 121 | perform_notification(phone, control, NP_SYNC_WILL_START); |
| @@ -209,15 +209,16 @@ int main(int argc, char *argv[]) | |||
| 209 | if (gnp && lockfile) { | 209 | if (gnp && lockfile) { |
| 210 | char *noti; | 210 | char *noti; |
| 211 | 211 | ||
| 212 | /* | ||
| 212 | noti = NULL; | 213 | noti = NULL; |
| 213 | iphone_np_get_notification(gnp, ¬i); | 214 | iphone_np_get_notification(gnp, ¬i); |
| 214 | if (noti) { | 215 | if (noti) { |
| 215 | printf("------> received notification '%s'\n", noti); | 216 | printf("------> received notification '%s'\n", noti); |
| 216 | free(noti); | 217 | free(noti); |
| 217 | } | 218 | }*/ |
| 218 | 219 | ||
| 219 | printf("XXX sleeping\n"); | 220 | printf("XXX sleeping\n"); |
| 220 | for (i = 0; i < 5; i++) { | 221 | /*for (i = 0; i < 5; i++) { |
| 221 | noti = NULL; | 222 | noti = NULL; |
| 222 | printf("--- getting notification\n"); | 223 | printf("--- getting notification\n"); |
| 223 | iphone_np_get_notification(gnp, ¬i); | 224 | iphone_np_get_notification(gnp, ¬i); |
| @@ -229,6 +230,8 @@ int main(int argc, char *argv[]) | |||
| 229 | } | 230 | } |
| 230 | sleep(1); | 231 | sleep(1); |
| 231 | } | 232 | } |
| 233 | */ | ||
| 234 | sleep(5); | ||
| 232 | 235 | ||
| 233 | //perform_notification(phone, control, NP_SYNC_DID_FINISH); | 236 | //perform_notification(phone, control, NP_SYNC_DID_FINISH); |
| 234 | 237 | ||
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[]) | |||
| 51 | 51 | ||
| 52 | if (port) { | 52 | if (port) { |
| 53 | iphone_msync_client_t msync = NULL; | 53 | iphone_msync_client_t msync = NULL; |
| 54 | iphone_msync_new_client(phone, 3432, port, &msync); | 54 | iphone_msync_new_client(phone, port, &msync); |
| 55 | if (msync) { | 55 | if (msync) { |
| 56 | iphone_msync_get_all_contacts(msync); | 56 | iphone_msync_get_all_contacts(msync); |
| 57 | iphone_msync_free_client(msync); | 57 | 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 @@ | |||
| 27 | #include <usb.h> | 27 | #include <usb.h> |
| 28 | 28 | ||
| 29 | #include <libiphone/libiphone.h> | 29 | #include <libiphone/libiphone.h> |
| 30 | #include <usbmuxd.h> | ||
| 30 | 31 | ||
| 31 | static int quit_flag = 0; | 32 | static int quit_flag = 0; |
| 32 | 33 | ||
| @@ -78,7 +79,7 @@ int main(int argc, char *argv[]) | |||
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | if (bus_n != -1) { | 82 | /* if (bus_n != -1) { |
| 82 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); | 83 | ret = iphone_get_specific_device(bus_n, dev_n, &phone); |
| 83 | if (ret != IPHONE_E_SUCCESS) { | 84 | if (ret != IPHONE_E_SUCCESS) { |
| 84 | printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); | 85 | 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[]) | |||
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | else | 89 | else |
| 89 | { | 90 | {*/ |
| 90 | ret = iphone_get_device(&phone); | 91 | ret = iphone_get_device(&phone); |
| 91 | if (ret != IPHONE_E_SUCCESS) { | 92 | if (ret != IPHONE_E_SUCCESS) { |
| 92 | printf("No device found, is it plugged in?\n"); | 93 | printf("No device found, is it plugged in?\n"); |
| 93 | return -1; | 94 | return -1; |
| 94 | } | 95 | } |
| 95 | } | 96 | /* }*/ |
| 96 | 97 | ||
| 97 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | 98 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { |
| 98 | iphone_free_device(phone); | 99 | iphone_free_device(phone); |
| @@ -103,15 +104,19 @@ int main(int argc, char *argv[]) | |||
| 103 | ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); | 104 | ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); |
| 104 | if ((ret == IPHONE_E_SUCCESS) && port) { | 105 | if ((ret == IPHONE_E_SUCCESS) && port) { |
| 105 | /* connect to socket relay messages */ | 106 | /* connect to socket relay messages */ |
| 106 | iphone_umux_client_t syslog_client = NULL; | 107 | //iphone_umux_client_t syslog_client = NULL; |
| 107 | 108 | ||
| 108 | ret = iphone_mux_new_client(phone, 514, port, &syslog_client); | 109 | //ret = iphone_mux_new_client(phone, 514, port, &syslog_client); |
| 109 | if (ret == IPHONE_E_SUCCESS) { | 110 | int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); |
| 111 | //if (ret == IPHONE_E_SUCCESS) { | ||
| 112 | if (sfd < 0) { | ||
| 113 | printf("ERROR: Could not open usbmux connection.\n"); | ||
| 114 | } else { | ||
| 110 | while (!quit_flag) { | 115 | while (!quit_flag) { |
| 111 | char *receive = NULL; | 116 | char *receive = NULL; |
| 112 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; | 117 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; |
| 113 | 118 | ||
| 114 | ret = iphone_mux_recv(syslog_client, (char *) &datalen, sizeof(datalen), &bytes); | 119 | ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); |
| 115 | datalen = ntohl(datalen); | 120 | datalen = ntohl(datalen); |
| 116 | 121 | ||
| 117 | if (datalen == 0) | 122 | if (datalen == 0) |
| @@ -121,7 +126,7 @@ int main(int argc, char *argv[]) | |||
| 121 | receive = (char *) malloc(sizeof(char) * datalen); | 126 | receive = (char *) malloc(sizeof(char) * datalen); |
| 122 | 127 | ||
| 123 | while (!quit_flag && (recv_bytes <= datalen)) { | 128 | while (!quit_flag && (recv_bytes <= datalen)) { |
| 124 | ret = iphone_mux_recv(syslog_client, receive, datalen, &bytes); | 129 | ret = usbmuxd_recv(sfd, receive, datalen, &bytes); |
| 125 | 130 | ||
| 126 | if (bytes == 0) | 131 | if (bytes == 0) |
| 127 | break; | 132 | break; |
| @@ -133,10 +138,8 @@ int main(int argc, char *argv[]) | |||
| 133 | 138 | ||
| 134 | free(receive); | 139 | free(receive); |
| 135 | } | 140 | } |
| 136 | } else { | ||
| 137 | printf("ERROR: Could not open usbmux connection.\n"); | ||
| 138 | } | 141 | } |
| 139 | iphone_mux_free_client(syslog_client); | 142 | usbmuxd_disconnect(sfd); //iphone_mux_free_client(syslog_client); |
| 140 | } else { | 143 | } else { |
| 141 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); | 144 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); |
| 142 | } | 145 | } |
