0001 ### BITPIM 0002 ### 0003 ### Copyright (C) 2007 Joe Pham <djpham@bitpim.org> 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_samsungsphm300pim.py 4473 2007-11-29 22:36:56Z djpham $ 0009 0010 """Communicate with the Samsung SPH-M300 through the modem port (PIM)""" 0011 0012 import sha 0013 0014 import com_samsung_packet 0015 import helpids 0016 import p_samsungsphm300 0017 0018 parentphone=com_samsung_packet.Phone 0019 class Phone(parentphone): 0020 "Talk to a Samsung SPH-M300 (PIM) phone" 0021 0022 desc="SPH-M300" 0023 helpid=helpids.ID_PHONE_SAMSUNGSPHM300 0024 protocolclass=p_samsungsphm300 0025 serialsname='sphm300' 0026 0027 builtinringtones=tuple(['Ring %d'%x for x in range(1, 11)])+\ 0028 ('After The Summer', 'Focus on It', 'Get Happy', 0029 'Here It Comes', 'In a Circle', 'Look Back', 0030 'Right Here', 'Secret Life', 'Shadow of Your Smile', 0031 'Sunday Morning', 'Default') 0032 0033 builtinimages=tuple(['People %d'%x for x in range(1, 11)])+\ 0034 tuple(['Animal %d'%x for x in range(1, 11)])+\ 0035 ('No Image',) 0036 numbertypetab=('cell', 'home', 'office', 'pager', 'fax') 0037 0038 def __init__(self, logtarget, commport): 0039 parentphone.__init__(self, logtarget, commport) 0040 self.mode=self.MODENONE 0041 0042 def _setmodephonebooktobrew(self): 0043 raise NotImplementedError('BREW mode not available') 0044 def _setmodemodemtobrew(self): 0045 raise NotImplementedError('BREW mode not available') 0046 0047 def _get_ringtone_index(self): 0048 """Return the ringtone""" 0049 _res={} 0050 for _idx,_name in enumerate(self.builtinringtones): 0051 _res[_idx]={ 'name': _name, 0052 'origin': 'builtin' } 0053 return _res 0054 def _get_wallpaper_index(self): 0055 """Return the wallpaper index""" 0056 _res={} 0057 for _idx, _name in enumerate(self.builtinimages): 0058 _res[_idx]={ 'name': _name, 0059 'origin': 'builtin' } 0060 return _res 0061 0062 def getfundamentals(self, results): 0063 """Gets information fundamental to interopating with the phone and UI.""" 0064 0065 # use a hash of ESN and other stuff (being paranoid) 0066 self.log("Retrieving fundamental phone information") 0067 self.log("Phone serial number") 0068 self.setmode(self.MODEMODEM) 0069 results['uniqueserial']=sha.new(self.get_esn()).hexdigest() 0070 0071 self.log("Reading group information") 0072 results['groups']=self.read_groups() 0073 results['ringtone-index']=self._get_ringtone_index() 0074 results['wallpaper-index']=self._get_wallpaper_index() 0075 self.log("Fundamentals retrieved") 0076 return results 0077 0078 def _extractphonebook_numbers(self, entry, fundamentals, res): 0079 """Extract and build phone numbers""" 0080 res['numbers']=[] 0081 speeddialtype=entry.speeddial 0082 # This phone supports neither secret nor speed dial 0083 for numberindex,type in enumerate(self.numbertypetab): 0084 if len(entry.numbers[numberindex].number): 0085 numhash={'number': entry.numbers[numberindex].number, 'type': type } 0086 if speeddialtype==numberindex: 0087 # this is the main number 0088 res['numbers'].insert(0, numhash) 0089 else: 0090 res['numbers'].append(numhash) 0091 0092 def _extractphonebook_ringtone(self, entry, fundamentals, res): 0093 """Extract ringtone info""" 0094 try: 0095 res['ringtones']=[{'ringtone': fundamentals['ringtone-index'][entry.ringtone]['name'], 0096 'use': 'call'}] 0097 except KeyError: 0098 pass 0099 def _extractphonebook_wallpaper(self, entry, fundamentals, res): 0100 """Extract wallpaper info""" 0101 try: 0102 res['wallpapers']=[{'wallpaper': fundamentals['wallpaper-index'][entry.wallpaper]['name'], 0103 'use': 'call'}] 0104 except KeyError: 0105 pass 0106 0107 def makeentry(self, entry, fundamentals): 0108 e=parentphone.makeentry(self, entry, fundamentals) 0109 e.writeflg=True 0110 # this model can only set built-in ringtones and images, 0111 # everything else would be set to default 0112 try: 0113 e.ringtone=list(self.builtinringtones).index(entry['ringtone']) 0114 except ValueError: 0115 pass 0116 try: 0117 e.wallpaper=list(self.builtinimages).index(entry['wallpaper']) 0118 except ValueError: 0119 pass 0120 return e 0121 0122 def getsms(self, results): 0123 """retrieve SMS data""" 0124 # It's not working for now, used for data recording/collection from 0125 # users to determine the return format 0126 self.log('Reading SMS data') 0127 _req=self.protocolclass.smsinrequest() 0128 for _cnt in range(self.protocolclass.NUMSMSINENTRIES): 0129 self.progress(_cnt, self.protocolclass.NUMSMSINENTRIES, 0130 'Reading SMS entry %d'%_cnt) 0131 _req.slot=_cnt 0132 _resp=self.sendpbcommand(_req, self.protocolclass.smsinresponse) 0133 results['canned_msg']=[] 0134 results['sms']={} 0135 return results 0136 0137 getwallpapers=NotImplemented 0138 getringtones=NotImplemented 0139 getcallhistory=NotImplemented 0140 getplaylist=NotImplemented 0141 gett9db=NotImplemented 0142 0143 parentprofile=com_samsung_packet.Profile 0144 class Profile(parentprofile): 0145 protocolclass=Phone.protocolclass 0146 serialsname=Phone.serialsname 0147 0148 MAX_RINGTONE_BASENAME_LENGTH=19 0149 RINGTONE_FILENAME_CHARS="abcdefghijklmnopqrstuvwxyz0123456789_ ." 0150 RINGTONE_LIMITS= { 0151 'MAXSIZE': 250000 0152 } 0153 phone_manufacturer='SAMSUNG' 0154 phone_model='SPH-A620/152' 0155 numbertypetab=Phone.numbertypetab 0156 0157 imageorigins={} 0158 imagetargets={} 0159 0160 _supportedsyncs=( 0161 ('phonebook', 'read', None), # all phonebook reading 0162 ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook 0163 ('calendar', 'read', None), # all calendar reading 0164 ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar 0165 ('todo', 'read', None), # all todo list reading 0166 ('todo', 'write', 'OVERWRITE'), # all todo list writing 0167 ('memo', 'read', None), # all memo list reading 0168 ('memo', 'write', 'OVERWRITE'), # all memo list writing 0169 ('sms', 'read', None), # all SMS list reading 0170 ) 0171 0172 __audio_ext={ 'MIDI': 'mid', 'PMD': 'pmd', 'QCP': 'qcp' } 0173 def QueryAudio(self, origin, currentextension, afi): 0174 # we don't modify any of these 0175 print "afi.format=",afi.format 0176 if afi.format in ("MIDI", "PMD", "QCP"): 0177 for k,n in self.RINGTONE_LIMITS.items(): 0178 setattr(afi, k, n) 0179 return currentextension, afi 0180 d=self.RINGTONE_LIMITS.copy() 0181 d['format']='QCP' 0182 return ('qcp', fileinfo.AudioFileInfo(afi, **d)) 0183 0184 field_color_data={ 0185 'phonebook': { 0186 'name': { 0187 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 0188 'nickname': 0, 'details': 1 }, 0189 'number': { 0190 'type': 5, 'speeddial': 0, 'number': 5, 'details': 5 }, 0191 'email': 1, 0192 'address': { 0193 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 0194 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 0195 'details': 0 }, 0196 'url': 1, 0197 'memo': 0, 0198 'category': 1, 0199 'wallpaper': 1, 0200 'ringtone': 1, 0201 'storage': 0, 0202 }, 0203 'calendar': { 0204 'description': True, 'location': False, 'allday': False, 0205 'start': True, 'end': True, 'priority': True, 0206 'alarm': True, 'vibrate': False, 0207 'repeat': False, 0208 'memo': False, 0209 'category': False, 0210 'wallpaper': False, 0211 'ringtone': False, 0212 }, 0213 'memo': { 0214 'subject': False, 0215 'date': False, 0216 'secret': False, 0217 'category': False, 0218 'memo': True, 0219 }, 0220 'todo': { 0221 'summary': True, 0222 'status': False, 0223 'due_date': True, 0224 'percent_complete': False, 0225 'completion_date': False, 0226 'private': False, 0227 'priority': True, 0228 'category': False, 0229 'memo': False, 0230 }, 0231 } 0232
Generated by PyXR 0.9.4