Package phones ::
Module com_lgvx4650
|
|
1
2
3
4
5
6
7
8
9
10 """Communicate with the LG VX4650 cell phone
11
12 The VX4600 is substantially similar to the VX4400.
13
14 """
15
16
17 from __future__ import with_statement
18 import contextlib
19 import datetime
20 import time
21 import cStringIO
22 import re
23 import sha
24
25
26 import bpcalendar
27 import call_history
28 import common
29 import conversions
30 import copy
31 import p_brew
32 import p_lgvx4650
33 import com_lgvx4400
34 import com_brew
35 import com_phone
36 import com_lg
37 import commport
38 import helpids
39 import memo
40 import prototypes
41 import sms
42
43 -class Phone(com_lgvx4400.Phone):
44 "Talk to the LG VX4650 cell phone"
45
46 desc="LG-VX4650"
47 helpid=helpids.ID_PHONE_LGVX4650
48 protocolclass=p_lgvx4650
49 serialsname='lgvx4650'
50
51
52 imagelocations=(
53
54 ( 30, "download/dloadindex/brewImageIndex.map", "dload/img", "images", 30),
55 )
56
57 ringtonelocations=(
58
59 ( 50, "download/dloadindex/brewRingerIndex.map", "user/sound/ringer", "ringers", 30),
60 )
61
62 builtinimages={ 80: ('Large Pic. 1', 'Large Pic. 2', 'Large Pic. 3',
63 'Large Pic. 4', 'Large Pic. 5', 'Large Pic. 6',
64 'Large Pic. 7', 'Large Pic. 8', 'Large Pic. 9',
65 'Large Pic. 10', 'Large Pic. 11', 'Large Pic. 12',
66 'Large Pic. 13', 'Large Pic. 14', 'Large Pic. 15',
67 'Large Pic. 16', 'Large Pic. 17', 'Large Pic. 18',
68 'Large Pic. 19', 'Large Pic. 20', 'Large Pic. 21',
69 'Large Pic. 22', 'Large Pic. 23', 'Large Pic. 24',
70 'Large Pic. 25', 'Large Pic. 26', 'Large Pic. 27',
71 'Large Pic. 28', 'Large Pic. 29', 'Large Pic. 30',
72 'Large Pic. 31', 'Large Pic. 32', 'Large Pic. 33' ) }
73
74 builtinringtones={ 1: ('Ring 1', 'Ring 2', 'Ring 3', 'Ring 4', 'Ring 5',
75 'VZW Default Tone', 'Arabesque', 'Piano Sonata',
76 'Latin', 'When the saints go', 'Bach Cello suite',
77 'Speedy Way', 'CanCan', 'Grand Waltz', 'Toccata and Fugue',
78 'Bumble Bee', 'March', 'Circus Band',
79 'Sky Garden', 'Carmen Habanera', 'Hallelujah',
80 'Sting', 'Farewell', 'Pachelbel Canon', 'Carol 1',
81 'Carol 2'),
82 100: ( 'Chimes high', 'Chimes low', 'Ding', 'TaDa',
83 'Notify', 'Drum', 'Claps', 'FanFare', 'Chord high',
84 'Chord low' )
85 }
86 VoiceMemoDir='VoiceDB/All/Memos'
87
88 - def __init__(self, logtarget, commport):
91
97
131
132
155
157 _new_ringtones=results.get('ringtone', {})
158 _rt_index=results.get('ringtone-index', {})
159
160 _voice_memo_l=[x['name'] for k,x in _rt_index.items() \
161 if x.get('origin', '')=='voicememo']
162
163 _del_keys=[k for k,x in _new_ringtones.items() \
164 if x.get('name', None) in _voice_memo_l]
165 for k in _del_keys:
166 del _new_ringtones[k]
167 results['ringtone']=_new_ringtones
168 return com_lgvx4400.Phone.saveringtones(self, results, merge)
169
170
172 "Saves out the phonebook"
173 res=com_lgvx4400.Phone.savephonebook(self, data)
174
175 pbook=res.get('phonebook', {})
176 wallpaper_index=res.get('wallpaper-index', {})
177 r1={}
178 for k,e in pbook.items():
179 r1[e['bitpimserial']['id']]={ 'wallpaper': \
180 self._findmediainindex(wallpaper_index,
181 e['wallpaper'],
182 e['name'],
183 'wallpaper'),
184 'group': e['group'] }
185 serialupdates=data.get("serialupdates", [])
186 r2={}
187 for bps, serials in serialupdates:
188 r2[serials['serial1']]=r1[bps['id']]
189 if self._update_wallpaper_index(r2):
190 data["rebootphone"]=True
191 return res
192
218
219
220
221
222
223
224
225
226 _call_history_info={
227 call_history.CallHistoryEntry.Folder_Incoming: protocolclass.incoming_call_file,
228 call_history.CallHistoryEntry.Folder_Outgoing: protocolclass.outgoing_call_file,
229 call_history.CallHistoryEntry.Folder_Missed: protocolclass.missed_call_file
230 }
231 - def getcallhistory(self, result):
232
233 res={}
234 for _folder, _file_name in Phone._call_history_info.items():
235 try:
236 buf=prototypes.buffer(self.getfilecontents(_file_name))
237 hist_file=self.protocolclass.callhistoryfile()
238 hist_file.readfrombuffer(buf, logtitle="Read call history")
239 for i in range(hist_file.itemcount):
240 hist_call=hist_file.items[i]
241 entry=call_history.CallHistoryEntry()
242 entry.folder=_folder
243 entry.datetime=hist_call.datetime
244 entry.number=hist_call.number
245 entry.name=hist_call.name
246 if _folder!=call_history.CallHistoryEntry.Folder_Missed:
247 entry.duration=hist_call.duration
248 res[entry.id]=entry
249 except com_brew.BrewNoSuchFileException:
250 pass
251 result['call_history']=res
252 return result
253
254
255 - def _setquicktext(self, result):
256 canned_file=Phone.SMSCannedFile()
257 canned_file.set_sms_canned_data(result.get('canned_msg', []))
258 buf=prototypes.buffer()
259 canned_file.writetobuffer(buf, logtitle="Updated "+self.protocolclass.sms_canned_file)
260 self.writefile(self.protocolclass.sms_canned_file, buf.getvalue())
261
262 - def _getquicktext(self):
263 try:
264 buf=prototypes.buffer(self.getfilecontents(
265 self.protocolclass.sms_canned_file))
266 canned_file=Phone.SMSCannedFile()
267 canned_file.readfrombuffer(buf, logtitle="Read SMS canned text")
268 return canned_file.get_sms_canned_data()
269 except:
270 if __debug__:
271 raise
272 return []
273
274 my_model='VX4650'
275
296
297
299
300 s=''
301 try:
302 buf=self.getfilecontents('nvm/nvm/nvm_0000')
303 ofs=0x240
304 if buf[ofs]=='\x01':
305 ofs+=1
306 while buf[ofs]!='\x01':
307 s+=buf[ofs]
308 ofs+=1
309 except:
310 if __debug__:
311 raise
312 return s
326
327
328 parentprofile=com_lgvx4400.Profile
330 protocolclass=Phone.protocolclass
331 serialsname=Phone.serialsname
332
333 WALLPAPER_WIDTH=128
334 WALLPAPER_HEIGHT=128
335 MAX_WALLPAPER_BASENAME_LENGTH=19
336 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ."
337 WALLPAPER_CONVERT_FORMAT="bmp"
338
339 MAX_RINGTONE_BASENAME_LENGTH=19
340 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ."
341
342 BP_Calendar_Version=3
343 phone_manufacturer='LG Electronics Inc'
344 phone_model='VX4650'
345
346 imageorigins={}
347 imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images"))
350
351
352 imagetargets={}
353 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper",
354 {'width': 128, 'height': 114, 'format': "JPEG"}))
355 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen",
356 {'width': 128, 'height': 128, 'format': "JPEG"}))
357
360
361 _supportedsyncs=(
362 ('phonebook', 'read', None),
363 ('calendar', 'read', None),
364 ('wallpaper', 'read', None),
365 ('ringtone', 'read', None),
366 ('phonebook', 'write', 'OVERWRITE'),
367 ('calendar', 'write', 'OVERWRITE'),
368 ('wallpaper', 'write', 'MERGE'),
369 ('wallpaper', 'write', 'OVERWRITE'),
370 ('ringtone', 'write', 'MERGE'),
371 ('ringtone', 'write', 'OVERWRITE'),
372 ('memo', 'read', None),
373 ('memo', 'write', 'OVERWRITE'),
374 ('call_history', 'read', None),
375 ('sms', 'read', None),
376 ('sms', 'write', 'OVERWRITE'),
377 )
378
381