Package phones ::
Module com_motov3m_sprint
|
|
1
2
3
4
5
6
7
8
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
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):
34
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
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
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
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
66 self.select_phonebook()
67
68 pb_book={}
69 result['pb_list']=[]
70 result['sd_dict']={}
71
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
104
105 - def _populate_pb_entry(self, pb_entry, entry, fundamentals):
106 """Populate a BitPim phonebook entry with one from the phone
107 """
108
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
119
120
121
123 """Extract the www component"""
124 _www={ 'url': entry.number }
125 self._populate_pb_misc(pb_entry, _www, 'urls', entry,
126 fundamentals)
127
128 fundamentals['sd_dict'][entry.index]=entry.number
129
131 """Extract the memo component"""
132 _www={ 'memo': entry.number }
133 self._populate_pb_misc(pb_entry, _www, 'memos', entry,
134 fundamentals)
135
136 fundamentals['sd_dict'][entry.index]=entry.number
137
138
139
140 parentprofile=v3m.Profile
142 serialsname=Phone.serialsname
143
144 usbids=( ( 0x22B8, 0x2A64, 0),)
145 deviceclasses=("serial")
146
147
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
154 ringtoneorigins=('ringers',)
155
156
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),
167 ('phonebook', 'write', 'OVERWRITE'),
168 ('calendar', 'read', None),
169 ('calendar', 'write', 'OVERWRITE'),
170 ('wallpaper', 'read', None),
171 ('wallpaper', 'write', 'OVERWRITE'),
172 ('sms', 'read', None),
173 )
174