0001 ### BITPIM 0002 ### 0003 ### Copyright (C) 2005 Stephen Wood <sawecw@users.sf.net> 0004 ### 0005 ### This program is free software; you can redistribute it and/or modify 0006 ### it under the terms of the BitPim license as detailed in the LICENSE file. 0007 ### 0008 ### $Id: com_sanyo3100.py 4528 2007-12-26 05:51:17Z sawecw $ 0009 0010 """Talk to the Sanyo SCP-3100 cell phone""" 0011 # standard modules 0012 import re 0013 import time 0014 import sha 0015 0016 # my modules 0017 import common 0018 import com_sanyo8300 0019 import p_brew 0020 import p_sanyo8300 0021 import p_sanyo3100 0022 import commport 0023 import com_brew 0024 import com_phone 0025 import com_sanyo 0026 import com_sanyomedia 0027 import com_sanyonewer 0028 import prototypes 0029 import bpcalendar 0030 0031 numbertypetab=( 'cell', 'home', 'office', 'pager', 0032 'fax', 'data', 'none' ) 0033 0034 class Phone(com_sanyo8300.Phone): 0035 "Talk to the Sanyo PM3100 cell phone" 0036 0037 desc="SCP3100" 0038 # WOrking directories 1,2,4 0039 FIRST_MEDIA_DIRECTORY=1 0040 LAST_MEDIA_DIRECTORY=2 0041 0042 imagelocations=( 0043 # offset, directory #, indexflag, type, maximumentries 0044 ) 0045 0046 protocolclass=p_sanyo3100 0047 serialsname='scp3100' 0048 0049 builtinringtones=( 'None', 'Vibrate', '', '', '', '', '', '', '', 0050 'Tone 1', 'Tone 2', 'Tone 3', 'Tone 4', 'Tone 5', 0051 'Tone 6', 'Tone 7', 'Tone 8', 0052 '', '', '', '', '', 0053 '', '', '', 0054 '', '', '', '', 0055 'Hungarian Dance No.5', 'Asian Jingle', 0056 'Ska Big Band', 'Habanera', 'Clair de Lune', 0057 'Nocturne', 'Techno Beat', 'Jazz Melody','','','','','','','','','','','','','','','','','','','Ringer & Voice') 0058 0059 calendar_defaultringtone=4 0060 calendar_defaultcaringtone=4 0061 0062 def __init__(self, logtarget, commport): 0063 com_sanyo8300.Phone.__init__(self, logtarget, commport) 0064 self.mode=self.MODENONE 0065 self.numbertypetab=numbertypetab 0066 0067 # Phone Detection----------------------------------------------------------- 0068 def is_mode_brew(self): 0069 # Borrowed from the VX4400 0070 req=self.protocolclass.firmwarerequest() 0071 respc=p_brew.testing0cresponse 0072 for baud in 0, 38400, 115200: 0073 if baud: 0074 if not self.comm.setbaudrate(baud): 0075 continue 0076 try: 0077 self.sendbrewcommand(req, respc, callsetmode=False) 0078 return True 0079 except com_phone.modeignoreerrortypes: 0080 pass 0081 return False 0082 def check_my_phone(self, res): 0083 # check if this is an 6600 0084 try: 0085 _req=self.protocolclass.sanyofirmwarerequest() 0086 _resp=self.sendbrewcommand(_req, self.protocolclass.sanyofirmwareresponse) 0087 if _resp.phonemodel[:len(self.detected_model)]==self.detected_model: 0088 # yup, this's it! 0089 res['model']=self.my_model 0090 res['manufacturer']=self.my_manufacturer 0091 res['esn']=self.get_esn() 0092 except: 0093 if __debug__: 0094 raise 0095 0096 @classmethod 0097 def detectphone(_, coms, likely_ports, res, _module, _log): 0098 if not likely_ports: 0099 # cannot detect any likely ports 0100 return None 0101 for port in likely_ports: 0102 if not res.has_key(port): 0103 res[port]={ 'mode_modem': None, 'mode_brew': None, 0104 'manufacturer': None, 'model': None, 0105 'firmware_version': None, 'esn': None, 0106 'firmwareresponse': None } 0107 try: 0108 if res[port]['mode_brew']==False or \ 0109 res[port]['model']: 0110 # either phone is not in BREW, or a model has already 0111 # been found, not much we can do now 0112 continue 0113 p=_module.Phone(_log, commport.CommConnection(_log, port, timeout=1)) 0114 if res[port]['mode_brew'] is None: 0115 res[port]['mode_brew']=p.is_mode_brew() 0116 if res[port]['mode_brew']: 0117 p.check_my_phone(res[port]) 0118 p.comm.close() 0119 except com_brew.BrewBadBrewCommandException: 0120 pass 0121 except: 0122 if __debug__: 0123 raise 0124 0125 my_model='SCP3100' 0126 detected_model='SCP-3100/US' 0127 my_manufacturer='SANYO' 0128 0129 parentprofile=com_sanyo8300.Profile 0130 class Profile(parentprofile): 0131 0132 protocolclass=Phone.protocolclass 0133 serialsname=Phone.serialsname 0134 phone_manufacturer=Phone.my_manufacturer 0135 phone_model=Phone.my_model 0136 0137 _supportedsyncs=( 0138 ('phonebook', 'read', None), # all phonebook reading 0139 ('calendar', 'read', None), # all calendar reading 0140 ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook 0141 ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar 0142 ('wallpaper', 'read', None), # all wallpaper reading 0143 ('ringtone', 'read', None), # all ringtone reading 0144 ('call_history', 'read', None),# all call history list reading 0145 ('sms', 'read', None), # Read sms messages 0146 ('todo', 'read', None), # Read todos 0147 ) 0148 0149 # which usb ids correspond to us 0150 usbids=( ( 0x0474, 0x071F, 1),) # VID=Sanyo, 0151 deviceclasses=("serial",) 0152 0153 def __init__(self): 0154 parentprofile.__init__(self) 0155 com_sanyonewer.Profile.__init__(self) 0156 self.numbertypetab=numbertypetab 0157 0158
Generated by PyXR 0.9.4