PyXR

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



0001 ### BITPIM
0002 ###
0003 ### Copyright (C) 2003-2004 Roger Binns <rogerb@rogerbinns.com>
0004 ### Copyright (C) 2005 Simon Capper <skyjunky@sbcglobal.net>
0005 ### Copyright (C) 2008 Joe Siegrist <joesigrist@gmail.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 
0011 """Communicate with the LG LX260 cell phone
0012 
0013 The LX260 is like other LG phones, I got this to import and export phonebook data 
0014 which is all I care about at the moment, extending should be straightforward
0015 
0016 
0017 """
0018 
0019 # standard modules
0020 import time
0021 import cStringIO
0022 import sha
0023 
0024 # my modules
0025 import common
0026 import copy
0027 import p_brew
0028 import p_lglx260
0029 import com_lgvx4400
0030 import com_brew
0031 import com_phone
0032 import com_lg
0033 import prototypes
0034 
0035 class Phone(com_lgvx4400.Phone):
0036     "Talk to the LG LX260 cell phone"
0037 
0038     desc="LG-LX260"
0039     helpid=None
0040     protocolclass=p_lglx260
0041     serialsname='lglx260'
0042 
0043     # more LX260 indices
0044     imagelocations=(
0045         # offset, index file, files location, type, maximumentries
0046         ( 10, "download/dloadindex/brewImageIndex.map", "brew/shared", "images", 30) ,
0047         ( 0xc8, "download/dloadindex/mmsImageIndex.map", "brew/shared/mms", "mms", 20),
0048         ( 0xdc, "download/dloadindex/mmsDrmImageIndex.map", "brew/shared/mms/d", "drm", 20), 
0049         ( 0x82, None, None, "camera", 20) # nb camera must be last
0050         )
0051 
0052     ringtonelocations=(
0053         # offset, index file, files location, type, maximumentries
0054         ( 50, "download/dloadindex/brewRingerIndex.map", "user/sound/ringer", "ringers", 30),
0055         ( 150, "download/dloadindex/mmsRingerIndex.map", "mms/sound", "mms", 20),
0056         ( 180, "download/dloadindex/mmsDrmRingerIndex.map", "mms/sound/drm", "drm", 20)
0057         )
0058 
0059     builtinimages= ('Beach Ball', 'Towerbridge', 'Sunflower', 'Beach', 'Fish', 
0060                     'Sea', 'Snowman')
0061 
0062     builtinringtones= ('Ring 1', 'Ring 2', 'Ring 3', 'Ring 4', 'Ring 5', 'Ring 6',
0063                        'Annen Polka', 'Beethoven Symphony No. 9', 'Pachelbel Canon', 
0064                        'Hallelujah', 'La Traviata', 'Leichte Kavallerie Overture', 
0065                        'Mozart Symphony No.40', 'Bach Minuet', 'Farewell', 
0066                        'Mozart Piano Sonata', 'Sting', 'Trout', 'O solemio', 
0067                        'Pizzicata Polka', 'Stars and Stripes Forever', 
0068                        'Pineapple Rag', 'When the Saints Go Marching In', 'Latin', 
0069                        'Carol 1', 'Carol 2') 
0070                        
0071     
0072     def __init__(self, logtarget, commport):
0073         com_lgvx4400.Phone.__init__(self,logtarget,commport)
0074         self.mode=self.MODENONE
0075 
0076     def getcameraindex(self):
0077         index={}
0078         return index
0079 
0080     # this phone lacks groups
0081     def getgroups(self, results):
0082         g=self.protocolclass.pbgroups()
0083         groups={}
0084         #for i in range(len(g.groups)):
0085             #if len(g.groups[i].name): # sometimes have zero length names
0086                 #groups[i]={ 'icon': g.groups[i].icon, 'name': g.groups[i].name }
0087                 #self.log('Getting group: ' +i)
0088         results['groups']=groups
0089         return groups
0090 
0091     def getphoneinfo(self, phone_info):
0092         self.log('Getting Phone Info')
0093         phone_info.model=self.my_model
0094         phone_info.manufacturer=Profile.phone_manufacturer
0095         phone_info.append('ESN:', self.get_brew_esn())
0096         req=p_brew.firmwarerequest()
0097         res=self.sendbrewcommand(req, p_lglx260.firmwareresponse)
0098         phone_info.append('Firmware Version:', res.firmware)
0099         s=self.getfilecontents('pim/MyInformation.dat')
0100         phone_info.append('Phone Number:', s[363:373])
0101         try:
0102             dirlisting=self.getfilesystem('', 1)
0103             keys = dirlisting.keys()
0104             keys.sort()
0105             #dirlisting=self.getfilesystem('nvm/')
0106             for i in keys:
0107               self.log('file: '+ i)
0108               #s=self.getfilecontents(i)
0109         except com_brew.BrewNoSuchDirectoryException:
0110             self.log('no such directory pim/')
0111         #self.log(self.getfilecontents('pim/sp_num.dat'))
0112 
0113     def eval_detect_data(self, res):
0114         found=False
0115         try:
0116             s=self.getfilecontents('brew/version.txt')
0117             if s[:5]==self.my_model:
0118                 found=True
0119                 res['model']=self.my_model
0120                 res['manufacturer']='LG Electronics Inc'
0121                 res['esn'] = self.get_brew_esn()
0122         except:
0123             pass
0124         return
0125 
0126     my_model='LX260'
0127 
0128 parentprofile=com_lgvx4400.Profile
0129 class Profile(parentprofile):
0130     protocolclass=Phone.protocolclass
0131     serialsname=Phone.serialsname
0132     phone_manufacturer='LG Electronics Inc'
0133     phone_model='LX260'
0134 
0135     WALLPAPER_WIDTH=120
0136     WALLPAPER_HEIGHT=131
0137     MAX_WALLPAPER_BASENAME_LENGTH=32
0138     WALLPAPER_FILENAME_CHARS="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ."
0139     WALLPAPER_CONVERT_FORMAT="bmp"
0140    
0141     MAX_RINGTONE_BASENAME_LENGTH=32
0142     RINGTONE_FILENAME_CHARS="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ."
0143 
0144     # nb we don't allow save to camera so it isn't listed here
0145     imageorigins={}
0146     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images"))
0147     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "mms"))
0148     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "drm"))
0149     def GetImageOrigins(self):
0150         return self.imageorigins
0151 
0152     ringtoneorigins=('ringers', 'mms', 'drm')
0153     excluded_ringtone_origins=('mms', 'drm')
0154     excluded_wallpaper_origins=('mms', 'drm')
0155 
0156     # our targets are the same for all origins
0157     imagetargets={}
0158     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper",
0159                                       {'width': 120, 'height': 131, 'format': "BMP"}))
0160 
0161     def GetTargetsForImageOrigin(self, origin):
0162         return self.imagetargets
0163     
0164     _supportedsyncs=(
0165         ('sms', 'read', None),
0166         ('sms', 'write', 'OVERWRITE'),
0167         ('phonebook', 'read', None),  # all phonebook reading
0168         ('phonebook', 'write', 'OVERWRITE'),  # only overwriting phonebook
0169         ('calendar', 'write', 'OVERWRITE'),   # only overwriting calendar
0170         ('calendar', 'read', None),   # all calendar reading
0171         ('wallpaper', 'read', None),  # all wallpaper reading
0172         ('wallpaper', 'write', 'MERGE'),      # merge and overwrite wallpaper
0173         ('wallpaper', 'write', 'OVERWRITE'),
0174         ('ringtone', 'read', None),   # all ringtone reading
0175         ('ringtone', 'write', 'MERGE'),      # merge and overwrite ringtone
0176         ('ringtone', 'write', 'OVERWRITE'),
0177         ('memo', 'read', None),     # all memo list reading DJP
0178         ('memo', 'write', 'OVERWRITE'),  # all memo list writing DJP
0179         ('call_history', 'read', None),
0180        )
0181  
0182     def __init__(self):
0183         parentprofile.__init__(self)
0184 
0185 

Generated by PyXR 0.9.4