commit e23d1c7f298433b210b1a3b9f2bdd067e874d18d Author: Nikias Bassen <nik...@gmx.li> Date: Tue Feb 2 11:36:22 2010 +0100
Update iphone related stuff to use libimobiledevice. configure.ac | 28 +++++++++------------ src/Makefile.am | 4 +- src/itdb_iphone.c | 40 +++++++++++++------------------ src/itdb_itunesdb.c | 6 ++-- src/itdb_private.h | 2 +- src/itdb_sqlite.c | 22 ++++++++-------- tools/Makefile.am | 12 ++++---- tools/ipod-lockdown.c | 54 ++++++++++++++++++------------------------ tools/read-sysinfoextended.c | 6 ++-- 9 files changed, 78 insertions(+), 96 deletions(-) --- diff --git a/configure.ac b/configure.ac index 846f549..7ce74e9 100644 --- a/configure.ac +++ b/configure.ac @@ -168,28 +168,24 @@ fi AM_CONDITIONAL(HAVE_HAL, test x"$enable_hal" = xyes) dnl *********************************************************************** -dnl * libiphone is optional, but is required for iPhone/iPod Touch support +dnl * libimobiledevice is optional, but is required for iPhone/iPod Touch support dnl *********************************************************************** -AC_ARG_WITH(libiphone, AC_HELP_STRING([--without-libiphone], +AC_ARG_WITH(libimobiledevice, AC_HELP_STRING([--without-libimobiledevice], [Disable iPhone/iPod Touch support])) -if test "x$with_libiphone" != "xno"; then - PKG_CHECK_MODULES(LIBIPHONE, libiphone-1.0 >= 0.9.1, enable_libiphone=yes, enable_libiphone=no) - if test "x$enable_libiphone" != "xyes" -a "x$with_libiphone" = "xyes"; then - AC_MSG_ERROR([iPhone/iPod Touch support explicitly requested but libiphone couldn't be found]) +if test "x$with_libimobiledevice" != "xno"; then + PKG_CHECK_MODULES(LIBIMOBILEDEVICE, libimobiledevice-1.0 >= 0.9.7, enable_libimobiledevice=yes, enable_libimobiledevice=no) + if test "x$enable_libimobiledevice" != "xyes" -a "x$with_libimobiledevice" = "xyes"; then + AC_MSG_ERROR([iPhone/iPod Touch support explicitly requested but libimobiledevice couldn't be found]) fi - if test "x$enable_libiphone" = "xyes"; then - AC_CHECK_LIB([iphone], [iphone_device_new], [libiphone_1_0=yes], [libiphone10=no]) - if test x"$libiphone_1_0" = xyes; then - AC_DEFINE([HAVE_LIBIPHONE_1_0], 1, [Define if libiphone is using its newer API]) - fi - AC_DEFINE(HAVE_LIBIPHONE, 1, [Define if you have libiphone support]) - AC_SUBST(LIBIPHONE_CFLAGS) - AC_SUBST(LIBIPHONE_LIBS) + if test "x$enable_libimobiledevice" = "xyes"; then + AC_DEFINE(HAVE_LIBIMOBILEDEVICE, 1, [Define if you have libimobiledevice support]) + AC_SUBST(LIBIMOBILEDEVICE_CFLAGS) + AC_SUBST(LIBIMOBILEDEVICE_LIBS) fi fi -AM_CONDITIONAL(HAVE_LIBIPHONE, test x"$enable_libiphone" = xyes) +AM_CONDITIONAL(HAVE_LIBIMOBILEDEVICE, test x"$enable_libimobiledevice" = xyes) dnl ************************************************** dnl * TagLib is only used by test-rebuild-db @@ -379,7 +375,7 @@ Configuration for $PACKAGE $VERSION : Artwork support ..........: $have_gdkpixbuf Python bindings ..........: $with_python PyGObject support ........: $have_pygobject - iPhone/iPod Touch support.: $enable_libiphone + iPhone/iPod Touch support.: $enable_libimobiledevice Now type 'make' to build $PACKAGE $VERSION, and then 'make install' for installation. diff --git a/src/Makefile.am b/src/Makefile.am index 72bc3d2..ce02831 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,8 +57,8 @@ noinst_HEADERS = \ INCLUDES=$(LIBGPOD_CFLAGS) LIBS=$(LIBGPOD_LIBS) $(Z_LIBS) -lm -if HAVE_LIBIPHONE -LIBS+=-liphone +if HAVE_LIBIMOBILEDEVICE +LIBS+=-limobiledevice endif uninstall-hook: diff --git a/src/itdb_iphone.c b/src/itdb_iphone.c index 2cd3963..f4b0682 100644 --- a/src/itdb_iphone.c +++ b/src/itdb_iphone.c @@ -22,14 +22,14 @@ #include <errno.h> #include <stdio.h> #include <unistd.h> -#ifdef HAVE_LIBIPHONE -#include <libiphone/libiphone.h> -#include <libiphone/lockdown.h> -#include <libiphone/afc.h> -#include <libiphone/notification_proxy.h> +#ifdef HAVE_LIBIMOBILEDEVICE +#include <libimobiledevice/libimobiledevice.h> +#include <libimobiledevice/lockdown.h> +#include <libimobiledevice/afc.h> +#include <libimobiledevice/notification_proxy.h> struct itdbprep_int { - iphone_device_t device; + idevice_t device; afc_client_t afc; uint64_t lockfile; }; @@ -39,14 +39,12 @@ typedef struct itdbprep_int *itdbprep_t; #define LOCK_WAIT 200000 -/* libiphone should probably be reworked so we don't have to reopen a connection - to notification_proxy for every notification... */ -static int itdb_iphone_post_notification(iphone_device_t device, +static int itdb_iphone_post_notification(idevice_t device, lockdownd_client_t client, const char *notification) { np_client_t np = NULL; - int nport = 0; + uint16_t nport = 0; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); if (!nport) { @@ -77,7 +75,7 @@ int itdb_iphone_start_sync(Itdb_Device *device, void **prepdata) itdbprep_t pdata_loc = NULL; const char *uuid; lockdownd_client_t client = NULL; - int afcport = 0; + uint16_t afcport = 0; int i; uuid = itdb_device_get_uuid (device); @@ -92,17 +90,13 @@ int itdb_iphone_start_sync(Itdb_Device *device, void **prepdata) *prepdata = NULL; pdata_loc = g_new0 (struct itdbprep_int, 1); -#ifdef HAVE_LIBIPHONE_1_0 - res = iphone_device_new(&pdata_loc->device, uuid); -#else - res = iphone_get_device_by_uuid(&pdata_loc->device, uuid); -#endif - if (IPHONE_E_SUCCESS != res) { + res = idevice_new(&pdata_loc->device, uuid); + if (IDEVICE_E_SUCCESS != res) { fprintf(stderr, "No iPhone found, is it plugged in?\n"); res = -ENODEV; goto leave_with_err; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(pdata_loc->device, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(pdata_loc->device, &client, "libgpod")) { fprintf(stderr, "Error: Could not establish lockdownd connection!\n"); res = -1; goto leave_with_err; @@ -196,7 +190,7 @@ leave_with_err: pdata_loc->afc = NULL; } if (pdata_loc->device) { - iphone_device_free(pdata_loc->device); + idevice_free(pdata_loc->device); pdata_loc->device = NULL; } g_free(pdata_loc); @@ -229,11 +223,11 @@ int itdb_iphone_stop_sync(void *sync_ctx) printf("%s called but prepdata->afc is NULL!\n", __func__); } else { /* remove .status-com.apple.itdbprep.command.runPostProcess */ - if (afc_remove_path(prepdata->afc, "/iTunes_Control/iTunes/iTunes Library.itlp/DBTemp/.status-com.apple.itdprep.command.runPostProcess") != IPHONE_E_SUCCESS) { + if (afc_remove_path(prepdata->afc, "/iTunes_Control/iTunes/iTunes Library.itlp/DBTemp/.status-com.apple.itdprep.command.runPostProcess") != IDEVICE_E_SUCCESS) { fprintf(stderr, "Could not delete '.status-com.apple.itdprep.command.runPostProcess'\n"); } /* remove ddd.itdbm */ - if (afc_remove_path(prepdata->afc, "/iTunes_Control/iTunes/iTunes Library.itlp/DBTemp/ddd.itdbm") != IPHONE_E_SUCCESS) { + if (afc_remove_path(prepdata->afc, "/iTunes_Control/iTunes/iTunes Library.itlp/DBTemp/ddd.itdbm") != IDEVICE_E_SUCCESS) { fprintf(stderr, "Could not delete 'ddd.itdbm'\n"); } if (prepdata->lockfile) { @@ -247,7 +241,7 @@ int itdb_iphone_stop_sync(void *sync_ctx) prepdata->afc = NULL; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(prepdata->device, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(prepdata->device, &client, "libgpod")) { fprintf(stderr, "Error: Could not establish lockdownd connection!\n"); goto leave; } @@ -260,7 +254,7 @@ int itdb_iphone_stop_sync(void *sync_ctx) lockdownd_client_free(client); leave: - iphone_device_free(prepdata->device); + idevice_free(prepdata->device); g_free(prepdata); diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index ce2b38a..a01f9df 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -5799,7 +5799,7 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error) { gchar *itunes_filename, *itunes_path; gboolean result = FALSE; -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE void *sync_ctx; int sync_status; #endif @@ -5829,7 +5829,7 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error) itunes_filename = g_build_filename (itunes_path, "iTunesDB", NULL); } -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE if (itdb_device_is_iphone_family (itdb->device)) { sync_status = itdb_iphone_start_sync (itdb->device, &sync_ctx); if (sync_status != 0) { @@ -5866,7 +5866,7 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error) disconnect as soon as gtkpod returns */ sync (); -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE if (itdb_device_is_iphone_family (itdb->device)) { sync_status = itdb_iphone_stop_sync (sync_ctx); if (sync_status != 0) { diff --git a/src/itdb_private.h b/src/itdb_private.h index ea5c1d4..c584f72 100644 --- a/src/itdb_private.h +++ b/src/itdb_private.h @@ -235,7 +235,7 @@ G_GNUC_INTERNAL gboolean itdb_hash58_write_hash (Itdb_Device *device, G_GNUC_INTERNAL gboolean itdb_hash72_compute_hash_for_sha1 (const Itdb_Device *device, const guchar sha1[20], guchar signature[46]); -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE G_GNUC_INTERNAL int itdb_iphone_start_sync(Itdb_Device *device, void **prepdata); G_GNUC_INTERNAL int itdb_iphone_stop_sync(void *sync_ctx); #endif diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c index 6b313c7..c89d729 100644 --- a/src/itdb_sqlite.c +++ b/src/itdb_sqlite.c @@ -34,9 +34,9 @@ #include <sqlite3.h> #include <plist/plist.h> -#ifdef HAVE_LIBIPHONE -#include <libiphone/libiphone.h> -#include <libiphone/lockdown.h> +#ifdef HAVE_LIBIMOBILEDEVICE +#include <libimobiledevice/libimobiledevice.h> +#include <libimobiledevice/lockdown.h> #endif #include "itdb.h" @@ -1479,29 +1479,29 @@ static void run_post_process_commands(Itdb_iTunesDB *itdb, const char *outpath, int res; sqlite3 *db = NULL; -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE if (itdb_device_is_iphone_family(itdb->device)) { /* get SQL post process commands via lockdown (iPhone/iPod Touch) */ lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; + idevice_t phone = NULL; + idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; lockdownd_error_t lockdownerr = LOCKDOWN_E_UNKNOWN_ERROR; - ret = iphone_device_new(&phone, uuid); - if (ret != IPHONE_E_SUCCESS) { + ret = idevice_new(&phone, uuid); + if (ret != IDEVICE_E_SUCCESS) { printf("[%s] ERROR: Could not find device with uuid %s, is it plugged in?\n", __func__, uuid); goto leave; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "libgpod")) { printf("[%s] ERROR: Could not connect to device's lockdownd!\n", __func__); - iphone_device_free(phone); + idevice_free(phone); goto leave; } lockdownerr = lockdownd_get_value(client, "com.apple.mobile.iTunes.SQLMusicLibraryPostProcessCommands", NULL, &plist_node); lockdownd_client_free(client); - iphone_device_free(phone); + idevice_free(phone); if (lockdownerr == LOCKDOWN_E_SUCCESS) { ppc_dict = plist_node; diff --git a/tools/Makefile.am b/tools/Makefile.am index 8d3876c..ad5c873 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -7,10 +7,10 @@ ipod_read_sysinfo_extended_SOURCES+=ipod-scsi.c ipod_read_sysinfo_extended_CFLAGS+=$(SGUTILS_CFLAGS) ipod_read_sysinfo_extended_LDADD+=$(SGUTILS_LIBS) endif -if HAVE_LIBIPHONE +if HAVE_LIBIMOBILEDEVICE ipod_read_sysinfo_extended_SOURCES+=ipod-lockdown.c -ipod_read_sysinfo_extended_CFLAGS+=$(LIBIPHONE_CFLAGS) -ipod_read_sysinfo_extended_LDADD+=$(LIBIPHONE_LIBS) +ipod_read_sysinfo_extended_CFLAGS+=$(LIBIMOBILEDEVICE_CFLAGS) +ipod_read_sysinfo_extended_LDADD+=$(LIBIMOBILEDEVICE_LIBS) endif if HAVE_LIBUSB ipod_read_sysinfo_extended_SOURCES+=ipod-usb.c @@ -37,11 +37,11 @@ libgpod_callout_LDADD = \ $(LIBGPOD_LIBS) \ $(HAL_LIBS) -if HAVE_LIBIPHONE +if HAVE_LIBIMOBILEDEVICE hal_PROGRAMS+=iphone-callout iphone_callout_SOURCES = iphone-callout.c ipod-lockdown.c -iphone_callout_CFLAGS = $(LIBIPHONE_CFLAGS) -iphone_callout_LDADD = $(LIBIPHONE_LIBS) +iphone_callout_CFLAGS = $(LIBIMOBILEDEVICE_CFLAGS) +iphone_callout_LDADD = $(LIBIMOBILEDEVICE_LIBS) endif fdidir = $(HALFDIDIR)/policy/20thirdparty diff --git a/tools/ipod-lockdown.c b/tools/ipod-lockdown.c index a03f8e8..a31c2d9 100644 --- a/tools/ipod-lockdown.c +++ b/tools/ipod-lockdown.c @@ -29,9 +29,9 @@ #include <glib.h> #include <libxml/xmlmemory.h> -#include <libiphone/afc.h> -#include <libiphone/libiphone.h> -#include <libiphone/lockdown.h> +#include <libimobiledevice/afc.h> +#include <libimobiledevice/libimobiledevice.h> +#include <libimobiledevice/lockdown.h> extern char *read_sysinfo_extended_by_uuid (const char *uuid); extern gboolean iphone_write_sysinfo_extended (const char *uuid, const char *xml); @@ -40,26 +40,22 @@ G_GNUC_INTERNAL char * read_sysinfo_extended_by_uuid (const char *uuid) { lockdownd_client_t client = NULL; - iphone_device_t device = NULL; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; + idevice_t device = NULL; + idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; char *xml = NULL; char *str = NULL; char *gxml; uint32_t xml_length = 0; plist_t value = NULL; plist_t global = NULL; plist_t ptr = NULL; -#ifdef HAVE_LIBIPHONE_1_0 - ret = iphone_device_new(&device, uuid); -#else - ret = iphone_get_device_by_uuid(&device, uuid); -#endif - if (ret != IPHONE_E_SUCCESS) { + ret = idevice_new(&device, uuid); + if (ret != IDEVICE_E_SUCCESS) { printf("No device found with uuid %s, is it plugged in?\n", uuid); return NULL; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client)) { - iphone_device_free(device); + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &client, "libgpod")) { + idevice_free(device); return NULL; } @@ -101,7 +97,7 @@ read_sysinfo_extended_by_uuid (const char *uuid) global = NULL; lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); /* Jump through hoops since libxml will say to free mem it allocated * with xmlFree while memory freed with g_free has to be allocated @@ -120,40 +116,36 @@ G_GNUC_INTERNAL gboolean iphone_write_sysinfo_extended (const char *uuid, const char *xml) { lockdownd_client_t client = NULL; - iphone_device_t device = NULL; + idevice_t device = NULL; afc_client_t afc = NULL; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; + idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; afc_error_t afc_ret; - int afcport = 0; + uint16_t afcport = 0; char *dest_filename; char *dest_directory; uint64_t handle; uint32_t bytes_written; -#ifdef HAVE_LIBIPHONE_1_0 - ret = iphone_device_new(&device, uuid); -#else - ret = iphone_get_device_by_uuid(&device, uuid); -#endif - if (IPHONE_E_SUCCESS != ret) { + ret = idevice_new(&device, uuid); + if (IDEVICE_E_SUCCESS != ret) { printf("No device found with uuid %s, is it plugged in?\n", uuid); return FALSE; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(device, &client)) { - iphone_device_free(device); + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &client, "libgpod")) { + idevice_free(device); return FALSE; } if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.afc", &afcport)) { lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return FALSE; } g_assert (afcport != 0); if (AFC_E_SUCCESS != afc_client_new(device, afcport, &afc)) { lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return FALSE; } dest_directory = g_build_filename("iTunes_Control", "Device", NULL); @@ -162,7 +154,7 @@ iphone_write_sysinfo_extended (const char *uuid, const char *xml) g_free (dest_directory); afc_client_free(afc); lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return FALSE; } dest_filename = g_build_filename(dest_directory, "SysInfoExtended", NULL); @@ -171,7 +163,7 @@ iphone_write_sysinfo_extended (const char *uuid, const char *xml) g_free (dest_filename); afc_client_free(afc); lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return FALSE; } g_free (dest_filename); @@ -180,14 +172,14 @@ iphone_write_sysinfo_extended (const char *uuid, const char *xml) afc_file_close(afc, handle); afc_client_free(afc); lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return FALSE; } afc_file_close(afc, handle); afc_client_free(afc); lockdownd_client_free(client); - iphone_device_free(device); + idevice_free(device); return TRUE; } diff --git a/tools/read-sysinfoextended.c b/tools/read-sysinfoextended.c index 0cf5042..563a302 100644 --- a/tools/read-sysinfoextended.c +++ b/tools/read-sysinfoextended.c @@ -31,7 +31,7 @@ #ifdef HAVE_SGUTILS extern char *read_sysinfo_extended (const char *device); #endif -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE extern char *read_sysinfo_extended_by_uuid (const char *uuid); #endif #ifdef HAVE_LIBUSB @@ -72,10 +72,10 @@ main (int argc, char **argv) #endif else { /* argument doesn't look like a filename, might be an UUID */ -#ifdef HAVE_LIBIPHONE +#ifdef HAVE_LIBIMOBILEDEVICE xml = read_sysinfo_extended_by_uuid (argv[1]); #else - g_warning ("Compiled without libiphone support, can't read SysInfoExtended from an iPhone UUID"); + g_warning ("Compiled without libimobiledevice support, can't read SysInfoExtended from an iPhone UUID"); #endif } ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2