[Device] Add Mac OS support

This commit is contained in:
Li Fanxi 2010-12-15 23:34:46 +08:00
parent 345cd48a5b
commit e87a34d32e
2 changed files with 25 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class BAMBOOK(DeviceConfig, DevicePlugin):
name = 'Bambook Device Interface' name = 'Bambook Device Interface'
description = _('Communicate with the Sanda Bambook eBook reader.') description = _('Communicate with the Sanda Bambook eBook reader.')
author = _('Li Fanxi') author = _('Li Fanxi')
supported_platforms = ['windows', 'linux'] supported_platforms = ['windows', 'linux', 'osx']
log_packets = False log_packets = False
booklist_class = BookList booklist_class = BookList

View File

@ -8,19 +8,35 @@ __docformat__ = 'restructuredtext en'
Sanda library wrapper Sanda library wrapper
''' '''
import ctypes, uuid, hashlib import ctypes, uuid, hashlib, os, sys
from threading import Event, Lock from threading import Event, Lock
from calibre.constants import iswindows, islinux from calibre.constants import iswindows, islinux, isosx
from calibre import load_library
try: try:
_lib_name = 'libBambookCore'
cdll = ctypes.cdll
if iswindows: if iswindows:
text_encoding = 'mbcs' _lib_name = 'BambookCore'
lib_handle = ctypes.cdll.BambookCore cdll = ctypes.windll
elif islinux: else:
text_encoding = 'utf-8' if hasattr(sys, 'frozen') and iswindows:
lib_handle = ctypes.CDLL('libBambookCore.so') lp = os.path.join(os.path.dirname(sys.executable), 'DLLs', 'BambookCore.dll')
lib_handle = cdll.LoadLibrary(lp)
elif hasattr(sys, 'frozen_path'):
lp = os.path.join(sys.frozen_path, 'lib', 'libBambookCore.so')
lib_handle = cdll.LoadLibrary(lp)
else:
lib_handle = load_library(_lib_name, cdll)
except: except:
lib_handle = None lib_handle = None
if iswindows:
text_encoding = 'mbcs'
elif islinux:
text_encoding = 'utf-8'
elif isosx:
text_encoding = 'utf-8'
# Constant # Constant
DEFAULT_BAMBOOK_IP = '192.168.250.2' DEFAULT_BAMBOOK_IP = '192.168.250.2'