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

Source Code for Module phones.com_motov3m_sprint

  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_motov3m.py 4537 2007-12-30 03:32:13Z djpham $ 
  9   
 10  """Communicate with Motorola phones using AT commands""" 
 11   
 12  import common 
 13  import com_motov3m as v3m 
 14  import com_moto 
 15  import helpids 
 16  import fileinfo 
 17  import p_motov3m_sprint 
 18  import prototypes 
 19   
 20  parentphone=v3m.Phone 
21 -class Phone(parentphone):
22 desc='Moto-V3m' 23 helpid=helpids.ID_PHONE_MOTOV3M 24 protocolclass=p_motov3m_sprint 25 serialsname='motov3m' 26 builtinringtones=( 27 (0, ('Silent',)), 28 (5, ('Vibe Dot', 'Vibe Dash', 'Vibe Dot Dot', 'Vibe Dot Dash', 29 'Vibe Pulse')), 30 ) 31
32 - def __init__(self, logtarget, commport):
33 parentphone.__init__(self, logtarget, commport)
34
35 - def _ensure_speeddials(self, fundamentals):
36 """Make sure that each and every number/email/mail list has a 37 speed dial, which is being used as the slot/index number 38 """ 39 _pb_book=fundamentals.get('phonebook', {}) 40 _sd_slots=[False]*(self.protocolclass.PB_TOTAL_ENTRIES+1) 41 _sd_slots[0:self.protocolclass.PB_FIRST_ENTRY]=[True]*self.protocolclass.PB_FIRST_ENTRY 42 # go through the first round and mark the slots being used 43 for _key,_pb_entry in _pb_book.items(): 44 self._mark_used_slots(_pb_entry.get('numbers', []), _sd_slots, 45 'number') 46 self._mark_used_slots(_pb_entry.get('emails', []), _sd_slots, 47 'email') 48 self._mark_used_slots(_pb_entry.get('maillist', []), _sd_slots, 49 'entry') 50 # go through the 2nd time and populate unknown speed dials 51 for _key, _pb_entry in _pb_book.items(): 52 self._get_sd_slot(_pb_entry.get('numbers', []), _sd_slots, 53 'number') 54 self._get_sd_slot(_pb_entry.get('emails', []), _sd_slots, 55 'email') 56 self._get_sd_slot(_pb_entry.get('maillist', []), _sd_slots, 57 'entry') 58 return _sd_slots
59
60 - def getphonebook(self, result):
61 """Reads the phonebook data. The L{getfundamentals} information will 62 already be in result.""" 63 self.log('Getting phonebook') 64 self.setmode(self.MODEPHONEBOOK) 65 # pick the main phonebook 66 self.select_phonebook() 67 # setting up 68 pb_book={} 69 result['pb_list']=[] 70 result['sd_dict']={} 71 # loop through and read 10 entries at a timer 72 _total_entries=self.protocolclass.PB_TOTAL_ENTRIES 73 _first_entry=self.protocolclass.PB_FIRST_ENTRY 74 _req=self.protocolclass.read_pb_req() 75 for _start_idx in range(_first_entry, _total_entries+1, 10): 76 _end_idx=min(_start_idx+9, _total_entries) 77 _req.start_index=_start_idx 78 _req.end_index=_end_idx 79 for _retry_cnt in range(2): 80 try: 81 self.progress(_end_idx, _total_entries, 82 'Reading contact entry %d to %d'%(_start_idx, _end_idx)) 83 _res=self.sendATcommand(_req, self.protocolclass.read_pb_resp) 84 for _entry in _res: 85 self._build_pb_entry(_entry, pb_book, result) 86 break 87 except: 88 if _retry_cnt: 89 self.log('Failed to read phonebook data') 90 else: 91 self.log('Failed to read phonebook data, retrying...') 92 self._update_mail_list(pb_book, result) 93 self.setmode(self.MODEMODEM) 94 del result['pb_list'], result['sd_dict'] 95 _keys=result['groups'].keys() 96 result['categories']=[x['name'] for _,x in result['groups'].items()] 97 result['phonebook']=pb_book 98 return pb_book
99
100 - def savephonebook(self, result):
101 result=com_moto.Phone.savephonebook(self,result) 102 result['rebootphone']=True 103 return result
104
105 - def _populate_pb_entry(self, pb_entry, entry, fundamentals):
106 """Populate a BitPim phonebook entry with one from the phone 107 """ 108 # extract the number, email, or mailing list 109 _num_type=entry.number_type 110 if _num_type in self.protocolclass.NUMBER_TYPE: 111 self._populate_pb_number(pb_entry, entry, fundamentals) 112 elif _num_type in self.protocolclass.EMAIL_TYPE: 113 self._populate_pb_email(pb_entry, entry, fundamentals) 114 elif _num_type in self.protocolclass.WWW_TYPE: 115 self._populate_pb_www(pb_entry, entry, fundamentals) 116 elif _num_type in self.protocolclass.MEMO_TYPE: 117 self._populate_pb_memo(pb_entry, entry, fundamentals)
118 # this is a mail list, which is not currently supported 119 ## else: 120 ## self._populate_pb_maillist(pb_entry, entry, fundamentals) 121
122 - def _populate_pb_www(self, pb_entry, entry, fundamentals):
123 """Extract the www component""" 124 _www={ 'url': entry.number } 125 self._populate_pb_misc(pb_entry, _www, 'urls', entry, 126 fundamentals) 127 # and mark it 128 fundamentals['sd_dict'][entry.index]=entry.number
129
130 - def _populate_pb_memo(self, pb_entry, entry, fundamentals):
131 """Extract the memo component""" 132 _www={ 'memo': entry.number } 133 self._populate_pb_misc(pb_entry, _www, 'memos', entry, 134 fundamentals) 135 # and mark it 136 fundamentals['sd_dict'][entry.index]=entry.number
137 138 139 #------------------------------------------------------------------------------- 140 parentprofile=v3m.Profile
141 -class Profile(parentprofile):
142 serialsname=Phone.serialsname 143 144 usbids=( ( 0x22B8, 0x2A64, 0),) 145 deviceclasses=("serial") 146 147 # use for auto-detection 148 phone_manufacturer='Motorola' 149 phone_model='+GMM: Motorola V3m-Sprint Phone' 150 common_model_name='V3m' 151 generic_phone_model='Motorola CDMA V3m Phone' 152 153 # fill in the list of ringtone/sound origins on your phone 154 ringtoneorigins=('ringers',) 155 156 # our targets are the same for all origins 157 imagetargets={} 158 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", 159 {'width': 176, 'height': 184, 'format': "JPEG"})) 160 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", 161 {'width': 96, 'height': 72, 'format': "JPEG"})) 162 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", 163 {'width': 176, 'height': 220, 'format': "JPEG"})) 164 165 _supportedsyncs=( 166 ('phonebook', 'read', None), # all phonebook reading 167 ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook 168 ('calendar', 'read', None), # all calendar reading 169 ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar 170 ('wallpaper', 'read', None), # all wallpaper reading 171 ('wallpaper', 'write', 'OVERWRITE'), 172 ('sms', 'read', None), # all SMS list reading DJP 173 )
174