GwR revisions wip

This commit is contained in:
GRiker 2010-06-11 04:26:57 -06:00
parent 7a67294ae7
commit 5cf08b6b52

View File

@ -35,10 +35,39 @@ if iswindows:
class ITUNES(DevicePlugin):
'''
try:
pythoncom.CoInitialize()
finally:
pythoncom.CoUninitialize()
Calling sequences:
Initialization:
can_handle() or can_handle_windows()
reset()
open()
card_prefix()
can_handle()
set_progress_reporter()
get_device_information()
card_prefix()
free_space()
(Job 1 Get device information finishes)
can_handle()
set_progress_reporter()
books() (once for each storage point)
settings()
settings()
can_handle() (~1x per second OSX while idle)
Delete:
delete_books()
remove_books_from_metadata()
sync_booklists()
card_prefix()
free_space()
Upload:
settings()
set_progress_reporter()
upload_books()
add_books_to_metadata()
set_progress_reporter()
sync_booklists()
card_prefix()
free_space()
'''
name = 'Apple device interface'
@ -1778,16 +1807,26 @@ class ITUNES(DevicePlugin):
def _get_sources(self):
'''
Return a dict of sources
Check for >1 iPod device connected to iTunes
'''
if isosx:
names = [s.name() for s in self.iTunes.sources()]
kinds = [str(s.kind()).rpartition('.')[2] for s in self.iTunes.sources()]
return dict(zip(kinds,names))
elif iswindows:
# Assumes a pythoncom wrapper
it_sources = ['Unknown','Library','iPod','AudioCD','MP3CD','Device','RadioTuner','SharedLibrary']
names = [s.name for s in self.iTunes.sources]
kinds = [it_sources[s.kind] for s in self.iTunes.sources]
# If more than one connected iDevice, remove all from list to prevent driver initialization
if kinds.count('iPod') > 1:
if DEBUG:
self.log.error(" %d connected iPod devices detected, calibre supports a single connected iDevice" % kinds.count('iPod'))
while kinds.count('iPod'):
index = kinds.index('iPod')
kinds.pop(index)
names.pop(index)
return dict(zip(kinds,names))
def _is_alpha(self,char):
@ -1931,6 +1970,7 @@ class ITUNES(DevicePlugin):
self.log.info(" ITUNES._remove_from_iTunes():")
if isosx:
try:
storage_path = os.path.split(cached_book['lib_book'].location().path)
if cached_book['lib_book'].location().path.startswith(self.iTunes_media):
title_storage_path = storage_path[0]
@ -1959,6 +1999,8 @@ class ITUNES(DevicePlugin):
self.log.info(" '%s' stored external to iTunes, no files deleted" % cached_book['title'])
self.iTunes.delete(cached_book['lib_book'])
except:
self.log.warning(" error removing %s from iTunes" % cached_book['title'])
elif iswindows:
'''