Package phones ::
Module com_motov325m
|
|
1
2
3
4
5
6
7
8
9
10 """Communicate with Motorola phones using AT commands"""
11 import time
12
13 import common
14 import com_motov3mm as v3mm
15 import com_motov325 as v325
16 import prototypes
17 import p_motov325
18 import helpids
19
20 parentphone=v3mm.Phone
22 """ Talk to a Motorola V3mM phone"""
23 desc='Moto-V325M'
24 helpid=helpids.ID_PHONE_MOTOV325M
25 protocolclass=p_motov325
26 serialsname='motov325m'
27 MODEOBEX='modeobex'
28
29 builtinringtones=(
30 (0, ('Silent',)),
31 (5, ('Vibe Dot', 'Vibe Dash', 'Vibe Dot Dot', 'Vibe Dot Dash',
32 'Vibe Pulse')),
33 (11, ('Alert', 'Standard', 'Bells', 'Triads', 'Up and Down')),
34 (30, ('Moonlit Haze', 'Nightlife', 'Wind Chime', 'Random',
35 'Bit & Bytes', 'Door Bell', 'Ding', 'One Moment', 'Provincial',
36 'Harmonics', 'Interlude', 'Snaggle', 'Cosmic')),
37 )
38
41 """Return a list of media being deleted and being added"""
42 _index=fundamentals.get(index_key, {})
43 _media=fundamentals.get(media_key, {})
44 _index_file_list=[_entry['name'] for _entry in _index.values() \
45 if _entry.has_key('filename') and \
46 _entry['filename'].startswith(self.protocolclass.MOTO_SHARED_PATH) and \
47 _entry.get('origin', None) in origins ]
48 _bp_file_list=[_entry['name'] for _entry in _media.values() \
49 if _entry.get('origin', None) in origins ]
50 if merge:
51
52 _del_list=[]
53 _new_list=_bp_file_list
54 else:
55
56 _del_list=[x for x in _index_file_list if x not in _bp_file_list]
57 _new_list=_bp_file_list
58 return _del_list, _new_list
59
60 - def _add_files(self, index_key, media_key, media_path,
61 new_list, fundamentals):
62 """Add new file using OBEX"""
63 _index=fundamentals.get(index_key, {})
64 _media=fundamentals.get(media_key, {})
65 _adding_ringtones=index_key=='ringtone-index'
66 for _file in new_list:
67 _data=self._item_from_index(_file, 'data', _media)
68 if not _data:
69 self.log('Failed to write file %s due to no data'%_file)
70 continue
71 if self._item_from_index(_file, None, _index) is None:
72
73 _name=_file
74 if _adding_ringtones and \
75 common.getext(_name).lower()=='mp3':
76
77
78 _name='%s.mid'%common.stripext(_name)
79 _file_name='%(pathname)s/%(filename)s'% \
80 { 'pathname': media_path,
81 'filename': _name }
82 try:
83 self.obex.writefile(_file_name, _data)
84 except:
85 self.log('Failed to write OBEX file '+_file_name)
86 if __debug__:
87 raise
88
90 """Retrieve wallpaper data"""
91
92
93 self.log('Waiting for the phone to switch back to mode modem')
94 time.sleep(2)
95 self.setmode(self.MODEPHONEBOOK)
96 return parentphone.getwallpapers(self, fundamentals)
97
132
134 """Save ringtones to the phone"""
135 self.log('Waiting for the phone to switch back to mode modem')
136 time.sleep(2)
137 parentphone.saveringtones(self, fundamentals, merge)
138 fundamentals['clearcomm']=True
139 return fundamentals
140
142 """Save wallpapers to the phone"""
143 self.log('Waiting for the phone to switch back to mode modem')
144 time.sleep(2)
145 self.log('Writing wallpapers to the phone')
146 self.setmode(self.MODEBREW)
147 try:
148 _del_list, _new_list=self._get_del_new_list('wallpaper-index',
149 'wallpapers',
150 merge,
151 fundamentals,
152 frozenset(['images']))
153
154 self._replace_files('wallpaper-index', 'wallpapers',
155 _new_list, fundamentals)
156 except:
157 if __debug__:
158 self.setmode(self.MODEMODEM)
159 raise
160 self.setmode(self.MODEMODEM)
161 return fundamentals
162
163
164
165 parentprofile=v325.Profile
167 serialsname=Phone.serialsname
168 phone_model='V325M'
169 generic_phone_model='Motorola V325M Phone'
170
171 _supportedsyncs=(
172 ('phonebook', 'read', None),
173 ('phonebook', 'write', 'OVERWRITE'),
174 ('calendar', 'read', None),
175 ('calendar', 'write', 'OVERWRITE'),
176 ('ringtone', 'read', None),
177 ('ringtone', 'read', 'EXCLUSIVE'),
178 ('ringtone', 'write', 'EXCLUSIVE'),
179 ('ringtone', 'write', None),
180 ('wallpaper', 'read', None),
181 ('wallpaper', 'write', 'OVERWRITE'),
182 ('sms', 'read', None),
183 )
184