PyXR

c:\projects\bitpim\src \ phones \ com_lgux5000.py



0001 ### BITPIM
0002 ###
0003 ### Copyright (C) 2003-2004 Roger Binns <rogerb@rogerbinns.com>
0004 ### Copyright (C) 2004 John O'Shaughnessy <oshinfo@comcast.net>
0005 ### Copyright (C) 2007 Fiz Stein <fzzz62@yahoo.com>
0006 ###
0007 ### This program is free software; you can redistribute it and/or modify
0008 ### it under the terms of the BitPim license as detailed in the LICENSE file.
0009 ###
0010 ### $Id: com_lgux5000.py 4096 2007-03-13 21:27:19Z djpham $
0011 
0012 """Communicate with the LG UX5000 cell phone
0013 
0014 The UX5000 is substantially similar to the VX4400 and VX6100.
0015 
0016 The code in this file mainly inherits from VX4400 and VX6100 code.
0017 
0018 """
0019 
0020 # standard modules
0021 import time
0022 import cStringIO
0023 import sha
0024 
0025 # my modules
0026 import common
0027 import commport
0028 import copy
0029 import p_brew
0030 import p_lgux5000
0031 import com_lgvx4400
0032 import com_brew
0033 import com_phone
0034 import com_lg
0035 import prototypes
0036 import call_history
0037 import helpids
0038 
0039 class Phone(com_lgvx4400.Phone):
0040     "Talk to the LG UX5000 cell phone"
0041 
0042     desc="LG-UX5000"
0043     helpid=helpids.ID_PHONE_LGUX5000
0044     protocolclass=p_lgux5000
0045     serialsname='lgux5000'
0046 
0047     # more UX5000 indices
0048     imagelocations=(
0049         # offset, index file, files location, type, maximumentries
0050         ( 16, "download/dloadindex/brewImageIndex.map", "brew/shared", "images", 60) ,
0051         ( 200, "download/dloadindex/mmsImageIndex.map", "brew/shared/mms", "mms", 30),
0052         ( 240, "download/dloadindex/mmsDrmImageIndex.map", "brew/shared/mms/d", "drm", 20), 
0053         ( 130, None, None, "camera", 60) # nb camera must be last
0054         )
0055 
0056     ringtonelocations=(
0057         # offset, index file, files location, type, maximumentries
0058         ( 50, "download/dloadindex/brewRingerIndex.map", "user/sound/ringer", "ringers", 60),
0059         ( 150, "download/dloadindex/mmsRingerIndex.map", "mms/sound", "mms", 20),
0060         ( 180, "download/dloadindex/mmsDrmRingerIndex.map", "mms/sound/drm", "drm", 20)
0061         )
0062 
0063     builtinimages= ('Sport', 'Butterfly', 'Cake', 'Niagara Falls', 'Rockefeller', 
0064                                 'Statue of Liberty', 'The Capital', 'Scenary','White Bear', 'Yacht' ) 
0065     
0066     builtinringtones= ('Ring 2', 'Ring 3', 'Ring 4', 'Ring 5', 'VZW Default Tone',
0067                        'Farewell', 'Arabesque',
0068                        'Piano Sonata', 'Latin', 'When The Saints', 'Bach Cello Suite',
0069                        'Speedy Way', 'Cancan', 'Sting', 'Toccata and Fugue',
0070                        'Mozart Symphony 40', 'Nutcracker March', 'Funiculi', 'Polka',        
0071                        'Hallelujah', 'Mozart Aria',
0072                        'Leichte', 'Spring', 'Slavonic', 'Fantasy', 'Chimes High',
0073                        'Chimes Low', 'Ding', 'Tada', 'Notify', 'Drum', 'Claps', 'Fanfare', 
0074                        'Chord High', 'Chord Low')
0075                        
0076     
0077     def __init__(self, logtarget, commport):
0078         com_lgvx4400.Phone.__init__(self,logtarget,commport)
0079         self.mode=self.MODENONE
0080         
0081     def makeentry(self, counter, entry, dict):
0082         e=com_lgvx4400.Phone.makeentry(self, counter, entry, dict)
0083         e.entrysize=0x202
0084         return e
0085 
0086     def getcameraindex(self):
0087         index={}
0088         try:
0089             buf=prototypes.buffer(self.getfilecontents("cam/pics.dat"))
0090             g=self.protocolclass.campicsdat()
0091             g.readfrombuffer(buf, logtitle="Read camera index")
0092             for i in g.items:
0093                 if len(i.name):
0094                     # index[i.index]={'name': i.name, 'date': i.taken, 'origin': 'camera' }
0095                     # we currently use the filesystem name rather than rename in camera
0096                     # since the latter doesn't include the file extension which then makes
0097                     # life less pleasant once the file ends up on the computer
0098                     index[i.index]={'name': "pic%02d.jpg"%(i.index,), 'date': i.taken, 'origin': 'camera' }
0099         except com_brew.BrewNoSuchFileException:
0100             # if the phone has no pictures it may not have a a cam/pics.dat file
0101             pass
0102         return index
0103 
0104     my_model='UX5000'
0105 
0106     def getphoneinfo(self, phone_info):
0107         self.log('Getting Phone Info')
0108         try:
0109             s=self.getfilecontents('brew/version.txt')
0110             if s[:6]=='UX5000':
0111                 phone_info.append('Model:', "UX5000")
0112                 req=p_brew.firmwarerequest()
0113                 res=self.sendbrewcommand(req, self.protocolclass.firmwareresponse)
0114                 phone_info.append('Firmware Version:', res.firmware)
0115                 s=self.getfilecontents("nvm/$SYS.ESN")[85:89]
0116                 txt='%02X%02X%02X%02X'%(ord(s[3]), ord(s[2]), ord(s[1]), ord(s[0]))
0117                 phone_info.append('ESN:', txt)
0118                 txt=self.getfilecontents("nvm/nvm/nvm_0000")[577:587]
0119                 phone_info.append('Phone Number:', txt)
0120         except:
0121             pass
0122         return
0123 
0124 parentprofile=com_lgvx4400.Profile
0125 class Profile(parentprofile):
0126     protocolclass=Phone.protocolclass
0127     serialsname=Phone.serialsname
0128     phone_manufacturer='LG Electronics Inc'
0129     phone_model='UX5000'
0130 
0131     WALLPAPER_WIDTH=132
0132     WALLPAPER_HEIGHT=148
0133     MAX_WALLPAPER_BASENAME_LENGTH=24
0134     WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ."
0135     WALLPAPER_CONVERT_FORMAT="jpg"
0136    
0137     MAX_RINGTONE_BASENAME_LENGTH=24
0138     RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ."
0139 
0140     ringtoneorigins=('ringers', 'mms', 'drm')
0141     excluded_ringtone_origins=('mms', 'drm')
0142 
0143     # nb we don't allow save to camera so it isn't listed here
0144     imageorigins={}
0145     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images"))
0146     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "mms"))
0147     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "drm"))
0148     def GetImageOrigins(self):
0149         return self.imageorigins
0150 
0151     # our targets are the same for all origins
0152     imagetargets={}
0153     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper",
0154                                       {'width': 132, 'height': 148, 'format': "JPEG"}))
0155     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "pictureid",
0156                                       {'width': 132, 'height': 148, 'format': "JPEG"}))
0157     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen",
0158                                       {'width': 128, 'height': 160, 'format': "JPEG"}))
0159     # can the outside lcd display images?
0160     #imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd",
0161     #                                  {'width': 96, 'height': 64, 'format': "JPEG"}))
0162     
0163     _supportedsyncs=(
0164         ('phonebook', 'read', None),  # all phonebook reading
0165         ('calendar', 'read', None),   # all calendar reading
0166         ('wallpaper', 'read', None),  # all wallpaper reading
0167         ('ringtone', 'read', None),   # all ringtone reading
0168         ('phonebook', 'write', 'OVERWRITE'),  # only overwriting phonebook
0169         ('call_history', 'read', None),# all call history list reading
0170         ('sms', 'read', None),         # all SMS list reading
0171         ('memo', 'read', None),        # all memo list reading
0172         ('calendar', 'write', 'OVERWRITE'),  # only overwriting calendar
0173         ('wallpaper', 'write', 'MERGE'),     # merge and overwrite wallpaper
0174         ('wallpaper', 'write', 'OVERWRITE'),
0175         ('ringtone', 'write', 'MERGE'),      # merge and overwrite ringtone
0176         ('ringtone', 'write', 'OVERWRITE'),
0177         ('sms', 'write', 'OVERWRITE'),       # all SMS list writing
0178         ('memo', 'write', 'OVERWRITE'),      # all memo list writing
0179         )
0180  
0181     def __init__(self):
0182         parentprofile.__init__(self)
0183 
0184 

Generated by PyXR 0.9.4