commit 4cf25b0a8b85b85fa8d4adf6a7ed0b6feda9b6a7
Author: Hector Martin <[email protected]>
Date: Sun Sep 19 04:09:54 2010 +0200
Handle nested itdb_start/stop_sync calls
src/itdb_device.h | 3 +++
src/itdb_itunesdb.c | 23 +++++++++++++++++------
2 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/itdb_device.h b/src/itdb_device.h
index aa0282d..465d398 100644
--- a/src/itdb_device.h
+++ b/src/itdb_device.h
@@ -98,6 +98,8 @@ enum _ItdbChecksumType {
* and UTC
* @iphone_sync_context:Private data passed as is to libimobiledevice by
* itdb_start/stop_sync
+ * @iphone_sync_nest_level: Nesting count for itdb_start/stop_sync calls
+ * itdb_start/stop_sync
*
* Structure representing an iPod device
*
@@ -113,6 +115,7 @@ struct _Itdb_Device
gboolean sysinfo_changed;
gint timezone_shift;
void *iphone_sync_context;
+ int iphone_sync_nest_level;
};
/**
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 66e76b1..b4e3914 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -6107,6 +6107,9 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error)
* but on iPhones and iPod Touch this makes sure the "Sync in progress" screen
* is shown for the whole duration of the writing process.
*
+ * Calls to itdb_start_sync must be paired with calls to itdb_stop_sync.
Nesting
+ * is allowed.
+ *
* Returns: TRUE on success, FALSE on error
*/
gboolean itdb_start_sync (Itdb_iTunesDB *itdb)
@@ -6115,14 +6118,12 @@ gboolean itdb_start_sync (Itdb_iTunesDB *itdb)
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->iphone_sync_context != NULL) {
+ itdb->device->iphone_sync_nest_level++;
+ return TRUE;
+ }
if (itdb_device_is_iphone_family (itdb->device)) {
int sync_status;
-
- if (itdb->device->iphone_sync_context != NULL) {
- /* already locked */
- return TRUE;
- }
sync_status = itdb_iphone_start_sync (itdb->device,
&itdb->device->iphone_sync_context);
if (sync_status == 0) {
@@ -6145,11 +6146,21 @@ gboolean itdb_start_sync (Itdb_iTunesDB *itdb)
* (but is safe to be used). On iPhones and iPod Touch this will hide the
* "Sync in progress" screen.
*
+ * Calls to itdb_stop_sync must be paired with calls to itdb_start_sync.
Nesting
+ * is allowed, and only the final itdb_stop_sync will actually stop the sync.
+ *
* Returns: TRUE on success, FALSE on error
*/
gboolean itdb_stop_sync (Itdb_iTunesDB *itdb)
{
+ g_return_val_if_fail (itdb != NULL, FALSE);
+ g_return_val_if_fail (itdb->device != NULL, FALSE);
+
#ifdef HAVE_LIBIMOBILEDEVICE
+ if (itdb->device->iphone_sync_nest_level) {
+ itdb->device->iphone_sync_nest_level--;
+ return TRUE;
+ }
if (itdb_device_is_iphone_family (itdb->device)) {
int sync_status;
if (itdb->device->iphone_sync_context == NULL) {
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2