Package phones :: Module com_samsungsphm300pim
[hide private]
[frames] | no frames]

Source Code for Module phones.com_samsungsphm300pim

  1  ### BITPIM 
  2  ### 
  3  ### Copyright (C) 2007 Joe Pham <djpham@bitpim.org> 
  4  ### 
  5  ### This program is free software; you can redistribute it and/or modify 
  6  ### it under the terms of the BitPim license as detailed in the LICENSE file. 
  7  ### 
  8  ### $Id: com_samsungsphm300pim.py 4473 2007-11-29 22:36:56Z djpham $ 
  9   
 10  """Communicate with the Samsung SPH-M300 through the modem port (PIM)""" 
 11   
 12  import sha 
 13   
 14  import com_samsung_packet 
 15  import helpids 
 16  import p_samsungsphm300 
 17   
 18  parentphone=com_samsung_packet.Phone 
19 -class Phone(parentphone):
20 "Talk to a Samsung SPH-M300 (PIM) phone" 21 22 desc="SPH-M300" 23 helpid=helpids.ID_PHONE_SAMSUNGSPHM300 24 protocolclass=p_samsungsphm300 25 serialsname='sphm300' 26 27 builtinringtones=tuple(['Ring %d'%x for x in range(1, 11)])+\ 28 ('After The Summer', 'Focus on It', 'Get Happy', 29 'Here It Comes', 'In a Circle', 'Look Back', 30 'Right Here', 'Secret Life', 'Shadow of Your Smile', 31 'Sunday Morning', 'Default') 32 33 builtinimages=tuple(['People %d'%x for x in range(1, 11)])+\ 34 tuple(['Animal %d'%x for x in range(1, 11)])+\ 35 ('No Image',) 36 numbertypetab=('cell', 'home', 'office', 'pager', 'fax') 37
38 - def __init__(self, logtarget, commport):
39 parentphone.__init__(self, logtarget, commport) 40 self.mode=self.MODENONE
41
42 - def _setmodephonebooktobrew(self):
43 raise NotImplementedError('BREW mode not available')
44 - def _setmodemodemtobrew(self):
45 raise NotImplementedError('BREW mode not available')
46
47 - def _get_ringtone_index(self):
48 """Return the ringtone""" 49 _res={} 50 for _idx,_name in enumerate(self.builtinringtones): 51 _res[_idx]={ 'name': _name, 52 'origin': 'builtin' } 53 return _res
54 - def _get_wallpaper_index(self):
55 """Return the wallpaper index""" 56 _res={} 57 for _idx, _name in enumerate(self.builtinimages): 58 _res[_idx]={ 'name': _name, 59 'origin': 'builtin' } 60 return _res
61
62 - def getfundamentals(self, results):
63 """Gets information fundamental to interopating with the phone and UI.""" 64 65 # use a hash of ESN and other stuff (being paranoid) 66 self.log("Retrieving fundamental phone information") 67 self.log("Phone serial number") 68 self.setmode(self.MODEMODEM) 69 results['uniqueserial']=sha.new(self.get_esn()).hexdigest() 70 71 self.log("Reading group information") 72 results['groups']=self.read_groups() 73 results['ringtone-index']=self._get_ringtone_index() 74 results['wallpaper-index']=self._get_wallpaper_index() 75 self.log("Fundamentals retrieved") 76 return results
77
78 - def _extractphonebook_numbers(self, entry, fundamentals, res):
79 """Extract and build phone numbers""" 80 res['numbers']=[] 81 speeddialtype=entry.speeddial 82 # This phone supports neither secret nor speed dial 83 for numberindex,type in enumerate(self.numbertypetab): 84 if len(entry.numbers[numberindex].number): 85 numhash={'number': entry.numbers[numberindex].number, 'type': type } 86 if speeddialtype==numberindex: 87 # this is the main number 88 res['numbers'].insert(0, numhash) 89 else: 90 res['numbers'].append(numhash)
91
92 - def _extractphonebook_ringtone(self, entry, fundamentals, res):
93 """Extract ringtone info""" 94 try: 95 res['ringtones']=[{'ringtone': fundamentals['ringtone-index'][entry.ringtone]['name'], 96 'use': 'call'}] 97 except KeyError: 98 pass
99 - def _extractphonebook_wallpaper(self, entry, fundamentals, res):
100 """Extract wallpaper info""" 101 try: 102 res['wallpapers']=[{'wallpaper': fundamentals['wallpaper-index'][entry.wallpaper]['name'], 103 'use': 'call'}] 104 except KeyError: 105 pass
106
107 - def makeentry(self, entry, fundamentals):
108 e=parentphone.makeentry(self, entry, fundamentals) 109 e.writeflg=True 110 # this model can only set built-in ringtones and images, 111 # everything else would be set to default 112 try: 113 e.ringtone=list(self.builtinringtones).index(entry['ringtone']) 114 except ValueError: 115 pass 116 try: 117 e.wallpaper=list(self.builtinimages).index(entry['wallpaper']) 118 except ValueError: 119 pass 120 return e
121
122 - def getsms(self, results):
123 """retrieve SMS data""" 124 # It's not working for now, used for data recording/collection from 125 # users to determine the return format 126 self.log('Reading SMS data') 127 _req=self.protocolclass.smsinrequest() 128 for _cnt in range(self.protocolclass.NUMSMSINENTRIES): 129 self.progress(_cnt, self.protocolclass.NUMSMSINENTRIES, 130 'Reading SMS entry %d'%_cnt) 131 _req.slot=_cnt 132 _resp=self.sendpbcommand(_req, self.protocolclass.smsinresponse) 133 results['canned_msg']=[] 134 results['sms']={} 135 return results
136 137 getwallpapers=NotImplemented 138 getringtones=NotImplemented 139 getcallhistory=NotImplemented 140 getplaylist=NotImplemented 141 gett9db=NotImplemented
142 143 parentprofile=com_samsung_packet.Profile
144 -class Profile(parentprofile):
145 protocolclass=Phone.protocolclass 146 serialsname=Phone.serialsname 147 148 MAX_RINGTONE_BASENAME_LENGTH=19 149 RINGTONE_FILENAME_CHARS="abcdefghijklmnopqrstuvwxyz0123456789_ ." 150 RINGTONE_LIMITS= { 151 'MAXSIZE': 250000 152 } 153 phone_manufacturer='SAMSUNG' 154 phone_model='SPH-A620/152' 155 numbertypetab=Phone.numbertypetab 156 157 imageorigins={} 158 imagetargets={} 159 160 _supportedsyncs=( 161 ('phonebook', 'read', None), # all phonebook reading 162 ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook 163 ('calendar', 'read', None), # all calendar reading 164 ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar 165 ('todo', 'read', None), # all todo list reading 166 ('todo', 'write', 'OVERWRITE'), # all todo list writing 167 ('memo', 'read', None), # all memo list reading 168 ('memo', 'write', 'OVERWRITE'), # all memo list writing 169 ('sms', 'read', None), # all SMS list reading 170 ) 171 172 __audio_ext={ 'MIDI': 'mid', 'PMD': 'pmd', 'QCP': 'qcp' }
173 - def QueryAudio(self, origin, currentextension, afi):
174 # we don't modify any of these 175 print "afi.format=",afi.format 176 if afi.format in ("MIDI", "PMD", "QCP"): 177 for k,n in self.RINGTONE_LIMITS.items(): 178 setattr(afi, k, n) 179 return currentextension, afi 180 d=self.RINGTONE_LIMITS.copy() 181 d['format']='QCP' 182 return ('qcp', fileinfo.AudioFileInfo(afi, **d))
183 184 field_color_data={ 185 'phonebook': { 186 'name': { 187 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 188 'nickname': 0, 'details': 1 }, 189 'number': { 190 'type': 5, 'speeddial': 0, 'number': 5, 'details': 5 }, 191 'email': 1, 192 'address': { 193 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 194 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 195 'details': 0 }, 196 'url': 1, 197 'memo': 0, 198 'category': 1, 199 'wallpaper': 1, 200 'ringtone': 1, 201 'storage': 0, 202 }, 203 'calendar': { 204 'description': True, 'location': False, 'allday': False, 205 'start': True, 'end': True, 'priority': True, 206 'alarm': True, 'vibrate': False, 207 'repeat': False, 208 'memo': False, 209 'category': False, 210 'wallpaper': False, 211 'ringtone': False, 212 }, 213 'memo': { 214 'subject': False, 215 'date': False, 216 'secret': False, 217 'category': False, 218 'memo': True, 219 }, 220 'todo': { 221 'summary': True, 222 'status': False, 223 'due_date': True, 224 'percent_complete': False, 225 'completion_date': False, 226 'private': False, 227 'priority': True, 228 'category': False, 229 'memo': False, 230 }, 231 }
232