From e3f2d6070de7125058c343ef63961c27bc991bb6 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 7 Jun 2025 12:09:24 +0200 Subject: Add new idevice_get_device_version() to interface This allows getting a numerical representation of the device's ProductVersion string for easier version range checks --- src/idevice.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/idevice.c') diff --git a/src/idevice.c b/src/idevice.c index e9c909f..1cdfef2 100644 --- a/src/idevice.c +++ b/src/idevice.c @@ -946,6 +946,20 @@ idevice_error_t idevice_get_udid(idevice_t device, char **udid) return IDEVICE_E_SUCCESS; } +unsigned int idevice_get_device_version(idevice_t device) +{ + if (!device) { + return 0; + } + if (!device->version) { + lockdownd_client_t lockdown = NULL; + lockdownd_client_new(device, &lockdown, NULL); + // we don't handle any errors here. We should have the product version cached now. + lockdownd_client_free(lockdown); + } + return device->version; +} + #if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS) typedef ssize_t ssl_cb_ret_type_t; #elif defined(HAVE_MBEDTLS) @@ -1229,7 +1243,7 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) #if OPENSSL_VERSION_NUMBER < 0x10100002L || \ (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2060000fL)) /* force use of TLSv1 for older devices */ - if (connection->device->version < DEVICE_VERSION(10,0,0)) { + if (connection->device->version < IDEVICE_DEVICE_VERSION(10,0,0)) { #ifdef SSL_OP_NO_TLSv1_1 SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_1); #endif -- cgit v1.1-32-gdbae