From 78238523bc5aff1d699a202e82dea1f02e780fb8 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 5 Apr 2013 18:46:12 +0200 Subject: Add compatibility for libimobiledevice API >= 1.1.5 --- configure.ac | 10 +++++++--- src/ideviceinstaller.c | 54 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 5d5a59e..11f24b4 100644 --- a/configure.ac +++ b/configure.ac @@ -16,18 +16,22 @@ AC_PROG_LIBTOOL # Checks for libraries. PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 0.9.7) -PKG_CHECK_MODULES(libimobiledevice10, libimobiledevice-1.0 >= 1.0.0, libimobiledevice_1_0=yes, libimobiledevice_1_0=no) +PKG_CHECK_MODULES(libimobiledevice100, libimobiledevice-1.0 >= 1.0.0, libimobiledevice_1_0=yes, libimobiledevice_1_0=no) if test x"$libimobiledevice_1_0" = xyes; then AC_DEFINE([HAVE_LIBIMOBILEDEVICE_1_0], 1, [Define if libimobiledevice is using 1.0.0 API]) fi -PKG_CHECK_MODULES(libimobiledevice11, libimobiledevice-1.0 >= 1.1.0, libimobiledevice_1_1=yes, libimobiledevice_1_1=no) +PKG_CHECK_MODULES(libimobiledevice110, libimobiledevice-1.0 >= 1.1.0, libimobiledevice_1_1=yes, libimobiledevice_1_1=no) if test x"$libimobiledevice_1_1" = xyes; then AC_DEFINE([HAVE_LIBIMOBILEDEVICE_1_1], 1, [Define if libimobiledevice is using 1.1.0 API]) fi -PKG_CHECK_MODULES(libimobiledevice12, libimobiledevice-1.0 >= 1.1.2, libimobiledevice_1_2=yes, libimobiledevice_1_2=no) +PKG_CHECK_MODULES(libimobiledevice112, libimobiledevice-1.0 >= 1.1.2, libimobiledevice_1_2=yes, libimobiledevice_1_2=no) if test x"$libimobiledevice_1_2" = xno; then PKG_CHECK_MODULES(libglib2, glib-2.0 >= 2.14.1) fi +PKG_CHECK_MODULES(libimobiledevice115, libimobiledevice-1.0 >= 1.1.5, libimobiledevice_1_1_5=yes, libimobiledevice_1_1_5=no) +if test x"$libimobiledevice_1_1_5" = xyes; then + AC_DEFINE([HAVE_LIBIMOBILEDEVICE_1_1_5], 1, [Define if libimobiledevice is using 1.1.5 API]) +fi PKG_CHECK_MODULES(libplist, libplist >= 0.15) PKG_CHECK_MODULES(libzip, libzip >= 0.8) diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index 7682536..51fbe7b 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c @@ -388,7 +388,11 @@ int main(int argc, char **argv) instproxy_client_t ipc = NULL; np_client_t np = NULL; afc_client_t afc = NULL; - uint16_t port = 0; +#ifdef HAVE_LIBIMOBILEDEVICE_1_1_5 + lockdownd_service_descriptor_t service = NULL; +#else + uint16_t service = 0; +#endif int res = 0; parse_opts(argc, argv); @@ -408,13 +412,13 @@ int main(int argc, char **argv) if ((lockdownd_start_service (client, "com.apple.mobile.notification_proxy", - &port) != LOCKDOWN_E_SUCCESS) || !port) { + &service) != LOCKDOWN_E_SUCCESS) || !service) { fprintf(stderr, "Could not start com.apple.mobile.notification_proxy!\n"); goto leave_cleanup; } - if (np_client_new(phone, port, &np) != NP_E_SUCCESS) { + if (np_client_new(phone, service, &np) != NP_E_SUCCESS) { fprintf(stderr, "Could not connect to notification_proxy!\n"); goto leave_cleanup; } @@ -430,16 +434,22 @@ int main(int argc, char **argv) np_observe_notifications(np, noties); run_again: - port = 0; - if ((lockdownd_start_service - (client, "com.apple.mobile.installation_proxy", - &port) != LOCKDOWN_E_SUCCESS) || !port) { +#ifdef HAVE_LIBIMOBILEDEVICE_1_1_5 + if (service) { + lockdownd_service_descriptor_free(service); + } + service = NULL; +#else + service = 0; +#endif + if ((lockdownd_start_service(client, "com.apple.mobile.installation_proxy", + &service) != LOCKDOWN_E_SUCCESS) || !service) { fprintf(stderr, "Could not start com.apple.mobile.installation_proxy!\n"); goto leave_cleanup; } - if (instproxy_client_new(phone, port, &ipc) != INSTPROXY_E_SUCCESS) { + if (instproxy_client_new(phone, service, &ipc) != INSTPROXY_E_SUCCESS) { fprintf(stderr, "Could not connect to installation_proxy!\n"); goto leave_cleanup; } @@ -554,9 +564,16 @@ run_again: uint64_t af = 0; char buf[8192]; - port = 0; - if ((lockdownd_start_service(client, "com.apple.afc", &port) != - LOCKDOWN_E_SUCCESS) || !port) { +#ifdef HAVE_LIBIMOBILEDEVICE_1_1_5 + if (service) { + lockdownd_service_descriptor_free(service); + } + service = NULL; +#else + service = 0; +#endif + if ((lockdownd_start_service(client, "com.apple.afc", &service) != + LOCKDOWN_E_SUCCESS) || !service) { fprintf(stderr, "Could not start com.apple.afc!\n"); goto leave_cleanup; } @@ -564,7 +581,7 @@ run_again: lockdownd_client_free(client); client = NULL; - if (afc_client_new(phone, port, &afc) != INSTPROXY_E_SUCCESS) { + if (afc_client_new(phone, service, &afc) != INSTPROXY_E_SUCCESS) { fprintf(stderr, "Could not connect to AFC!\n"); goto leave_cleanup; } @@ -1013,8 +1030,15 @@ run_again: goto leave_cleanup; } - port = 0; - if ((lockdownd_start_service(client, "com.apple.afc", &port) != LOCKDOWN_E_SUCCESS) || !port) { +#ifdef HAVE_LIBIMOBILEDEVICE_1_1_5 + if (service) { + lockdownd_service_descriptor_free(service); + } + service = NULL; +#else + service = 0; +#endif + if ((lockdownd_start_service(client, "com.apple.afc", &service) != LOCKDOWN_E_SUCCESS) || !service) { fprintf(stderr, "Could not start com.apple.afc!\n"); free(copy_path); goto leave_cleanup; @@ -1023,7 +1047,7 @@ run_again: lockdownd_client_free(client); client = NULL; - if (afc_client_new(phone, port, &afc) != INSTPROXY_E_SUCCESS) { + if (afc_client_new(phone, service, &afc) != INSTPROXY_E_SUCCESS) { fprintf(stderr, "Could not connect to AFC!\n"); goto leave_cleanup; } -- cgit v1.1-32-gdbae