From 8036f3f227211fdff18cbbf85ab84f45a44c5add Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 21 May 2020 04:31:00 +0200 Subject: Ignore non-usbmux (i.e. wifi sync) devices in device event callback --- configure.ac | 21 +++++++++++++++++++-- src/idevicerestore.c | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 030a32b..3a5543c 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,9 @@ if test x$ac_cv_func_strsep != xyes; then fi fi +CACHED_CFLAGS="$CFLAGS" +CFLAGS+=" $libimobiledevice_CFLAGS" + # check if libimobiledevice has timeout errors AC_CACHE_CHECK(for IDEVICE_E_TIMEOUT in enum idevice_error_t, ac_cv_idevice_error_has_timeout, AC_TRY_COMPILE([ @@ -80,21 +83,35 @@ AC_CACHE_CHECK(for IDEVICE_E_TIMEOUT in enum idevice_error_t, ac_cv_idevice_erro ], [ return IDEVICE_E_TIMEOUT; ], ac_cv_idevice_error_has_timeout=yes, ac_cv_idevice_error_has_timeout=no)) - if test "$ac_cv_idevice_error_has_timeout" = "yes"; then AC_DEFINE(HAVE_IDEVICE_E_TIMEOUT, 1, [Define if enum idevice_error_t defines IDEVICE_E_TIMEOUT]) fi + AC_CACHE_CHECK(for RESTORE_E_RECEIVE_TIMEOUT in enum restored_error_t, ac_cv_restored_error_has_timeout, AC_TRY_COMPILE([ #include ], [ return RESTORE_E_RECEIVE_TIMEOUT; ], ac_cv_restored_error_has_timeout=yes, ac_cv_restored_error_has_timeout=no)) - if test "$ac_cv_restored_error_has_timeout" = "yes"; then AC_DEFINE(HAVE_RESTORE_E_RECEIVE_TIMEOUT, 1, [Define if enum restored_error_t defines RESTORE_E_RECEIVE_TIMEOUT]) fi +# check if libimobiledevice has enum idevice_connection_type +AC_CACHE_CHECK(for enum idevice_connection_type, ac_cv_enum_idevice_connection_type, + AC_TRY_COMPILE([ + #include + ], [ + enum idevice_connection_type conn_type = CONNECTION_USBMUXD; + ], ac_cv_enum_idevice_connection_type=yes, ac_cv_enum_idevice_connection_type=no)) + +if (test "$ac_cv_enum_idevice_connection_type" = "yes"); then + AC_DEFINE(HAVE_ENUM_IDEVICE_CONNECTION_TYPE, 1, [Define if enum idevice_connection_type is available]) +fi + +CFLAGS="$CACHED_CFLAGS" + + AC_SUBST(GLOBAL_CFLAGS) AC_SUBST(AC_LDFLAGS) AC_SUBST(AC_LDADD) diff --git a/src/idevicerestore.c b/src/idevicerestore.c index f1a7a56..2c5f88c 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -215,6 +215,12 @@ static int compare_versions(const char *s_ver1, const char *s_ver2) static void idevice_event_cb(const idevice_event_t *event, void *userdata) { struct idevicerestore_client_t *client = (struct idevicerestore_client_t*)userdata; +#ifdef HAVE_ENUM_IDEVICE_CONNECTION_TYPE + if (event->conn_type != CONNECTION_USBMUXD) { + // ignore everything but devices connected through USB + return; + } +#endif if (event->event == IDEVICE_DEVICE_ADD) { if (client->ignore_device_add_events) { return; -- cgit v1.1-32-gdbae