commit 771aa7e6cde4b57c5f562980c6f93815eaf1e017 Author: Christophe Fergeau <cferg...@mandriva.com> Date: Fri Mar 12 16:34:17 2010 +0100
add itdb_start/stop_sync functions This allows apps to have finer control over the display of the "sync in progress" screen on iPhoneOS devices. src/itdb.h | 2 + src/itdb_device.h | 3 ++ src/itdb_itunesdb.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 0 deletions(-) --- diff --git a/src/itdb.h b/src/itdb.h index a8ec8ba..840a637 100644 --- a/src/itdb.h +++ b/src/itdb.h @@ -1735,6 +1735,8 @@ gboolean itdb_write_file (Itdb_iTunesDB *itdb, const gchar *filename, gboolean itdb_shuffle_write (Itdb_iTunesDB *itdb, GError **error); gboolean itdb_shuffle_write_file (Itdb_iTunesDB *itdb, const gchar *filename, GError **error); +gboolean itdb_start_sync (Itdb_iTunesDB *itdb); +gboolean itdb_stop_sync (Itdb_iTunesDB *itdb); Itdb_iTunesDB *itdb_new (void); void itdb_free (Itdb_iTunesDB *itdb); Itdb_iTunesDB *itdb_duplicate (Itdb_iTunesDB *itdb); /* not implemented */ diff --git a/src/itdb_device.h b/src/itdb_device.h index 31cdef1..4c86041 100644 --- a/src/itdb_device.h +++ b/src/itdb_device.h @@ -95,6 +95,8 @@ enum _ItdbChecksumType { * otherwise. (see itdb_set_sysinfo()) * @timezone_shift: The difference in seconds between the current timezone * and UTC + * @iphone_sync_context:Private data passed as is to libimobiledevice by + * itdb_start/stop_sync * * Structure representing an iPod device * @@ -109,6 +111,7 @@ struct _Itdb_Device SysInfoIpodProperties *sysinfo_extended; gboolean sysinfo_changed; gint timezone_shift; + void *iphone_sync_context; }; /** diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index cec83c2..d776369 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -5891,6 +5891,64 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error) return result; } +/** + * itdb_start_sync: + * @itdb: the #Itdb_iTunesDB that is being sync'ed + * + * Hints libgpod that a series of file copies/database saves/... is about + * to start. On regular iPods, this does nothing (but is safe to be used), + * but on iPhones and iPod Touch this makes sure the "Sync in progress" screen + * is shown for the whole duration of the writing process. + * + * Returns: TRUE on success, FALSE on error + */ +gboolean itdb_start_sync (Itdb_iTunesDB *itdb) +{ + g_return_val_if_fail (itdb != NULL, FALSE); + g_return_val_if_fail (itdb->device != NULL, FALSE); + +#ifdef HAVE_LIBIMOBILEDEVICE + g_return_val_if_fail (itdb->device->iphone_sync_context == NULL, FALSE); + if (itdb_device_is_iphone_family (itdb->device)) { + int sync_status; + sync_status = itdb_iphone_start_sync (itdb->device, + &itdb->device->iphone_sync_context); + if (sync_status == 0) { + return TRUE; + } else { + return FALSE; + } + } +#endif + + return TRUE; +} + +/** + * itdb_stop_sync: + * @itdb: the #Itdb_iTunesDB that is being sync'ed + * + * Hints libgpod that the series of file copies/database saves/... started + * with itdb_start_sync is finished. On regular iPods, this does nothing + * (but is safe to be used). On iPhones and iPod Touch this will hide the + * "Sync in progress" screen. + * + * Returns: TRUE on success, FALSE on error + */ +gboolean itdb_stop_sync (Itdb_iTunesDB *itdb) +{ +#ifdef HAVE_LIBIMOBILEDEVICE + if (itdb_device_is_iphone_family (itdb->device)) { + int sync_status; + sync_status = itdb_iphone_stop_sync (itdb->device->iphone_sync_context); + itdb->device->iphone_sync_context = NULL; + if (sync_status != 0) { + return FALSE; + } + } +#endif + return TRUE; +} /* from here on we have the functions for writing the iTunesDB */ /* -------------------------------------------------------------------- */ ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2