This commit is contained in:
Kovid Goyal 2012-12-06 22:56:10 +05:30
commit cac9d648fa
2 changed files with 36 additions and 26 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -214,9 +214,9 @@ class ITUNES(DriverBase):
"Cannot copy books directly from iDevice. " "Cannot copy books directly from iDevice. "
"Drag from iTunes Library to desktop, then add to calibre's Library window.") "Drag from iTunes Library to desktop, then add to calibre's Library window.")
UNSUPPORTED_DIRECT_CONNECT_MODE_MESSAGE = _( UNSUPPORTED_DIRECT_CONNECT_MODE_MESSAGE = _(
"Unsupported direct connect mode. " "*** Unsupported direct connect mode. "
"See http://www.mobileread.com/forums/showthread.php?t=118559 " "See http://www.mobileread.com/forums/showthread.php?t=118559 "
"for instructions on using 'Connect to iTunes'") "for instructions on using 'Connect to iTunes' ***")
ITUNES_SANDBOX_LOCKOUT_MESSAGE = _( ITUNES_SANDBOX_LOCKOUT_MESSAGE = _(
'<p>Unable to communicate with iTunes.</p>' '<p>Unable to communicate with iTunes.</p>'
'<p>Refer to this ' '<p>Refer to this '
@ -818,7 +818,7 @@ class ITUNES(DriverBase):
if DEBUG: if DEBUG:
logger().info("%s.get_device_information()" % self.__class__.__name__) logger().info("%s.get_device_information()" % self.__class__.__name__)
return (self.sources['iPod'], 'hw v1.0', 'sw v1.0', 'mime type normally goes here') return (self.sources['iPod'], 'hw v1.0', 'sw v1.0', 'unknown mime type')
def get_file(self, path, outfile, end_session=True): def get_file(self, path, outfile, end_session=True):
''' '''
@ -871,13 +871,14 @@ class ITUNES(DriverBase):
product_id product_id
)) ))
# Display a dialog recommending using 'Connect to iTunes' if user hasn't if False:
# previously disabled the dialog # Display a dialog recommending using 'Connect to iTunes' if user hasn't
if dynamic.get(confirm_config_name(self.DISPLAY_DISABLE_DIALOG), True): # previously disabled the dialog
raise AppleOpenFeedback(self) if dynamic.get(confirm_config_name(self.DISPLAY_DISABLE_DIALOG), True):
else: raise AppleOpenFeedback(self)
if DEBUG: else:
logger().error(" %s" % self.UNSUPPORTED_DIRECT_CONNECT_MODE_MESSAGE) if DEBUG:
logger().info(" %s" % self.UNSUPPORTED_DIRECT_CONNECT_MODE_MESSAGE)
# Log supported DEVICE_IDs and BCDs # Log supported DEVICE_IDs and BCDs
logger().info(" BCD: %s" % ['0x%x' % x for x in sorted(self.BCD)]) logger().info(" BCD: %s" % ['0x%x' % x for x in sorted(self.BCD)])
@ -1027,6 +1028,10 @@ class ITUNES(DriverBase):
self.plugboards = plugboards self.plugboards = plugboards
self.plugboard_func = pb_func self.plugboard_func = pb_func
def shutdown(self):
if DEBUG:
logger().info("%s.shutdown()\n" % self.__class__.__name__)
def sync_booklists(self, booklists, end_session=True): def sync_booklists(self, booklists, end_session=True):
''' '''
Update metadata on device. Update metadata on device.
@ -2336,6 +2341,7 @@ class ITUNES(DriverBase):
except: except:
if DEBUG: if DEBUG:
logger().info(" no books in library") logger().info(" no books in library")
self.library_orphans = library_orphans self.library_orphans = library_orphans
return library_books return library_books
@ -2547,16 +2553,16 @@ class ITUNES(DriverBase):
''' '''
PURGE_ORPHANS = False PURGE_ORPHANS = False
if PURGE_ORPHANS: if DEBUG:
if DEBUG: logger().info(" %s._purge_orphans()" % self.__class__.__name__)
logger().info(" %s._purge_orphans()" % self.__class__.__name__) #self._dump_library_books(library_books)
#self._dump_library_books(library_books) #logger().info(" cached_books:\n %s" % "\n ".join(cached_books.keys()))
#logger().info(" cached_books:\n %s" % "\n ".join(cached_books.keys()))
for book in library_books: for book in library_books:
if isosx: if isosx:
if book not in cached_books and \ if book not in cached_books and \
str(library_books[book].description()).startswith(self.description_prefix): str(library_books[book].description()).startswith(self.description_prefix):
if PURGE_ORPHANS:
if DEBUG: if DEBUG:
logger().info(" '%s' not found on iDevice, removing from iTunes" % book) logger().info(" '%s' not found on iDevice, removing from iTunes" % book)
btr = { btr = {
@ -2564,9 +2570,14 @@ class ITUNES(DriverBase):
'author': library_books[book].artist(), 'author': library_books[book].artist(),
'lib_book': library_books[book]} 'lib_book': library_books[book]}
self._remove_from_iTunes(btr) self._remove_from_iTunes(btr)
elif iswindows: else:
if book not in cached_books and \ if DEBUG:
library_books[book].Description.startswith(self.description_prefix): logger().info(" '%s' found in iTunes, but not on iDevice" % (book))
elif iswindows:
if book not in cached_books and \
library_books[book].Description.startswith(self.description_prefix):
if PURGE_ORPHANS:
if DEBUG: if DEBUG:
logger().info(" '%s' not found on iDevice, removing from iTunes" % book) logger().info(" '%s' not found on iDevice, removing from iTunes" % book)
btr = { btr = {
@ -2574,9 +2585,9 @@ class ITUNES(DriverBase):
'author': library_books[book].Artist, 'author': library_books[book].Artist,
'lib_book': library_books[book]} 'lib_book': library_books[book]}
self._remove_from_iTunes(btr) self._remove_from_iTunes(btr)
else: else:
if DEBUG: if DEBUG:
logger().info(" %s._purge_orphans(disabled)" % self.__class__.__name__) logger().info(" '%s' found in iTunes, but not on iDevice" % (book))
def _remove_existing_copy(self, path, metadata): def _remove_existing_copy(self, path, metadata):
''' '''
@ -3111,7 +3122,6 @@ class ITUNES(DriverBase):
''' '''
if DEBUG: if DEBUG:
logger().info(" %s._wait_for_writable_metadata()" % self.__class__.__name__) logger().info(" %s._wait_for_writable_metadata()" % self.__class__.__name__)
logger().warning(" %s" % self.UNSUPPORTED_DIRECT_CONNECT_MODE_MESSAGE)
attempts = 9 attempts = 9
while attempts: while attempts: