summaryrefslogtreecommitdiffstats
authorMartin Szulecki2010-05-11 10:39:42 (GMT)
committer Martin Szulecki2010-05-11 10:39:42 (GMT)
commit7716f26c6ae788d846252be20695abca19c7bca9 (patch) (side-by-side diff)
tree70b9e3533fde38f72283e87422c8d648263271e8
parent9a8b4994c0ff5023890c3deeacb48ee3a2227506 (diff)
downloadpython-idevicesync-master.tar.gz
python-idevicesync-master.tar.bz2
Report version of each data storage to device instead of a global versionHEADmaster
Each data class sync request has a version field. We know that it is different for each data class to be synced. Most likely it defines the set of allowed data fields in the record entities. The device refuses sync if the version is lower than the version on the device for a data class.
-rw-r--r--iPhoneDataStorage.py8
-rw-r--r--iPhoneSyncAgent.py3
-rwxr-xr-xiphonesync.py4
3 files changed, 12 insertions, 3 deletions
diff --git a/iPhoneDataStorage.py b/iPhoneDataStorage.py
index 521be48..dfd6e29 100644
--- a/iPhoneDataStorage.py
+++ b/iPhoneDataStorage.py
@@ -56,6 +56,9 @@ class iPhoneDataStorage():
def get_name(self):
return self.name
+ def get_version(self):
+ return self.version
+
def get_children_of_record_by_type(self, record, entity_class):
"""
Returns a list of all the children of type entity class for the given
@@ -154,6 +157,7 @@ class iPhoneDataStorage():
class iPhoneContactsDataStorage(iPhoneDataStorage):
name = "com.apple.Contacts"
+ version = 106
supported_entities = [
'com.apple.contacts.Contact',
'com.apple.contacts.Group',
@@ -168,6 +172,7 @@ class iPhoneContactsDataStorage(iPhoneDataStorage):
class iPhoneBookmarksDataStorage(iPhoneDataStorage):
name = "com.apple.Bookmarks"
+ version = 102
supported_entities = [
'com.apple.bookmarks.Bookmark',
'com.apple.bookmarks.Folder'
@@ -175,6 +180,7 @@ class iPhoneBookmarksDataStorage(iPhoneDataStorage):
class iPhoneCalendarsDataStorage(iPhoneDataStorage):
name = "com.apple.Calendars"
+ version = 107
supported_entities = [
'com.apple.calendars.Calendar',
'com.apple.calendars.Event',
@@ -187,6 +193,7 @@ class iPhoneCalendarsDataStorage(iPhoneDataStorage):
class iPhoneMailAccountsDataStorage(iPhoneDataStorage):
name = "com.apple.MailAccounts"
+ version = 102
supported_entities = [
'com.apple.mail.Account'
]
@@ -196,6 +203,7 @@ class iPhoneMailAccountsDataStorage(iPhoneDataStorage):
class iPhoneNotesDataStorage(iPhoneDataStorage):
name = "com.apple.Notes"
+ version = 102
supported_entities = [
'com.apple.notes.Note'
]
diff --git a/iPhoneSyncAgent.py b/iPhoneSyncAgent.py
index 745f940..af17211 100644
--- a/iPhoneSyncAgent.py
+++ b/iPhoneSyncAgent.py
@@ -8,7 +8,6 @@ import sys, re, time, datetime
''' Synchronization Classes '''
class iPhoneSyncAgent():
- VERSION = 106
EMPTY_PARAM = "___EmptyParameterString___"
SYNC_TYPES = [
"SDSyncTypeFast",
@@ -112,7 +111,7 @@ class iPhoneSyncAgent():
start_sync_msg.append( String(device_anchor) )
start_sync_msg.append( String(host_anchor) )
- start_sync_msg.append( Integer(self.VERSION) )
+ start_sync_msg.append( Integer(self.sync_data_storage.get_version() ) )
start_sync_msg.append( String(self.EMPTY_PARAM) )
self._mobile_sync.send(start_sync_msg)
diff --git a/iphonesync.py b/iphonesync.py
index 2db7722..0c21562 100755
--- a/iphonesync.py
+++ b/iphonesync.py
@@ -93,10 +93,12 @@ class Application():
def print_usage(self):
print "Usage: %s [OPTION]... [TYPE]..." % (sys.argv[0])
print "Synchronize data TYPEs on an iPhone or iPod Touch with this computer."
+ print ""
print "Supported data storage TYPEs are:"
for data_storage in self.supported_data_storage_types:
- print " %s" % (data_storage.get_name())
+ print " %s (version %d)" % (data_storage.get_name(), data_storage.get_version())
print ""
+ print "Options:"
print " -o, --output FILE\tSave received records to FILE"
print "\t\t\tthe saved data will be saved as:"
print "\t\t\t vCard for contacts"