[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'
description = _('Communicate with the Sanda Bambook eBook reader.')
author = _('Li Fanxi')
supported_platforms = ['windows', 'linux']
supported_platforms = ['windows', 'linux', 'osx']
log_packets = False
booklist_class = BookList

View File

@ -8,19 +8,35 @@ __docformat__ = 'restructuredtext en'
Sanda library wrapper
'''
import ctypes, uuid, hashlib
import ctypes, uuid, hashlib, os, sys
from threading import Event, Lock
from calibre.constants import iswindows, islinux
from calibre.constants import iswindows, islinux, isosx
from calibre import load_library
try:
_lib_name = 'libBambookCore'
cdll = ctypes.cdll
if iswindows:
text_encoding = 'mbcs'
lib_handle = ctypes.cdll.BambookCore
elif islinux:
text_encoding = 'utf-8'
lib_handle = ctypes.CDLL('libBambookCore.so')
_lib_name = 'BambookCore'
cdll = ctypes.windll
else:
if hasattr(sys, 'frozen') and iswindows:
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:
lib_handle = None
if iswindows:
text_encoding = 'mbcs'
elif islinux:
text_encoding = 'utf-8'
elif isosx:
text_encoding = 'utf-8'
# Constant
DEFAULT_BAMBOOK_IP = '192.168.250.2'