PyXR

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



0001 ### BITPIM
0002 ###
0003 ### Copyright (C) 2005 Simon Capper <skyjunky@sbcglobal.net>
0004 ###
0005 ### This program is free software; you can redistribute it and/or modify
0006 ### it under the terms of the BitPim license as detailed in the LICENSE file.
0007 ###
0008 
0009 """Communicate with the LG VX8300 cell phone
0010 
0011 
0012 The code in this file mainly inherits from VX8100 code and then extends where
0013 the 8300 has different functionality
0014 
0015 """
0016 
0017 # standard modules
0018 import time
0019 import cStringIO
0020 import sha
0021 
0022 # my modules
0023 import common
0024 import commport
0025 import copy
0026 import com_lgvx4400
0027 import p_brew
0028 import p_lgvx8300
0029 import com_lgvx8100
0030 import com_brew
0031 import com_phone
0032 import com_lg
0033 import prototypes
0034 import bpcalendar
0035 import call_history
0036 import sms
0037 import memo
0038 import fileinfo
0039 import helpids
0040 
0041 class Phone(com_lg.LGUncountedIndexedMedia, com_lgvx8100.Phone):
0042     "Talk to the LG VX8300 cell phone"
0043 
0044     desc="LG-VX8300"
0045     helpid=helpids.ID_PHONE_LGVX8300
0046     protocolclass=p_lgvx8300
0047     serialsname='lgvx8300'
0048 
0049     external_storage_root='mmc1/'
0050 
0051     builtinringtones= ('Low Beep Once', 'Low Beeps', 'Loud Beep Once', 'Loud Beeps', 'VZW Default Ringtone') + \
0052                       tuple(['Ringtone '+`n` for n in range(1,11)]) + \
0053                       ('No Ring',)
0054 
0055     ringtonelocations= (
0056         #  type          index file            default dir        external dir    max  type Index
0057         ( 'ringers',    'dload/myringtone.dat','brew/16452/lk/mr','mmc1/ringers', 100, 0x01, None),
0058         ( 'sounds',     'dload/mysound.dat',   'brew/16452/ms',   '',             100, 0x02, None),
0059         ( 'mp3',        'dload/my_mp3.dat',    'mmc1/my_mp3',     '',             100, 0x15, None),
0060        #( 'music',      'dload/sd_music.dat',  'mmc1/my_music',   '',             100, 0x14, None), # .wma files
0061         )
0062 
0063     calendarlocation="sch/schedule.dat"
0064     calendarexceptionlocation="sch/schexception.dat"
0065     calenderrequiresreboot=1
0066     memolocation="sch/memo.dat"
0067 
0068     builtinwallpapers = () # none
0069 
0070     wallpaperlocations= (
0071         #  type          index file            default dir     external dir  max  type Index
0072         ( 'images',     'dload/image.dat',    'brew/16452/mp', '',           100, 0x00, None),
0073         ( 'images(sd)', 'dload/sd_image.dat', 'mmc1/my_pix',   '',           100, 0x10, None),
0074         ( 'video',      'dload/video.dat',    'brew/16452/mf', '',           100, 0x03, None),
0075         ( 'video(sd)',  'dload/sd_video.dat', 'mmc1/my_flix',  '',           100, 0x13, None),
0076         )
0077 
0078     def __init__(self, logtarget, commport):
0079         com_lgvx8100.Phone.__init__(self, logtarget, commport)
0080         p_brew.PHONE_ENCODING=self.protocolclass.PHONE_ENCODING
0081         self.mode=self.MODENONE
0082 
0083     def get_esn(self, data=None):
0084         # return the ESN of this phone
0085         return self.get_brew_esn()
0086 
0087     def setDMversion(self):
0088         _fw_version=self.get_firmware_version()[-1]
0089         # T83VZV04 uses DMv5
0090         self._DMv5=self.my_model=='VX8300' and _fw_version>'3'
0091         if self._DMv5:
0092             # assume that it takes about 30 seconds for T83VZV04 to kick out of DM
0093             self._timeout = 30
0094 
0095     def get_detect_data(self, res):
0096         com_lgvx8100.Phone.get_detect_data(self, res)
0097         res[self.esn_file_key]=self.get_esn()
0098 
0099     my_model='VX8300'
0100 
0101     # Fundamentals:
0102     #  - get_esn             - Brew
0103     #  - getgroups           - same as LG VX-8100
0104     #  - getwallpaperindices - LGUncountedIndexedMedia
0105     #  - getringtoneindices  - LGUncountedIndexedMedia
0106     #  - DM Version          - 4 to access brew/16452/lk/mr on newer firmwares
0107 
0108 parentprofile=com_lgvx8100.Profile
0109 class Profile(parentprofile):
0110     protocolclass=Phone.protocolclass
0111     serialsname=Phone.serialsname
0112 
0113     BP_Calendar_Version=3
0114     phone_manufacturer='LG Electronics Inc'
0115     phone_model='VX8300'
0116 
0117     WALLPAPER_WIDTH=275
0118     WALLPAPER_HEIGHT=175
0119     MAX_WALLPAPER_BASENAME_LENGTH=32
0120     WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ."
0121     WALLPAPER_CONVERT_FORMAT="jpg"
0122 
0123     # the 8300 uses "W" for wait in the dialstring, it does not support "T"
0124     DIALSTRING_CHARS="[^0-9PW#*]"
0125 
0126     MAX_RINGTONE_BASENAME_LENGTH=32
0127     RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ."
0128 
0129     imageorigins={}
0130     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images"))
0131     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video"))
0132     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images(sd)"))
0133     imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video(sd)"))
0134     def GetImageOrigins(self):
0135         return self.imageorigins
0136 
0137     ringtoneorigins=('ringers', 'sounds', 'mp3')
0138     excluded_ringtone_origins=('sounds', 'mp3')
0139 
0140     # our targets are the same for all origins
0141     imagetargets={}
0142     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper",
0143                                       {'width': 176, 'height': 184, 'format': "JPEG"}))
0144     imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd",
0145                                       {'width': 96, 'height': 81, 'format': "JPEG"}))
0146 
0147     def GetTargetsForImageOrigin(self, origin):
0148         return self.imagetargets
0149 
0150     def QueryAudio(self, origin, currentextension, afi):
0151         # we don't modify any of these
0152         if afi.format in ("MIDI", "QCP", "PMD", "WMA"):
0153             return currentextension, afi
0154         # examine mp3
0155         if afi.format=="MP3":
0156             if afi.channels==1 and 8<=afi.bitrate<=64 and 16000<=afi.samplerate<=22050:
0157                 return currentextension, afi
0158         # convert it
0159         return ("mp3", fileinfo.AudioFileInfo(afi, **{'format': 'MP3', 'channels': 1, 'bitrate': 32, 'samplerate': 22050}))
0160 
0161     def __init__(self):
0162         parentprofile.__init__(self)
0163 
0164     _supportedsyncs=(
0165         ('phonebook', 'read', None),  # all phonebook reading
0166         ('calendar', 'read', None),   # all calendar reading
0167         ('wallpaper', 'read', None),  # all wallpaper reading
0168         ('ringtone', 'read', None),   # all ringtone reading
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         ('phonebook', 'write', 'OVERWRITE'),  # only overwriting phonebook
0173         ('calendar', 'write', 'OVERWRITE'),   # only overwriting calendar
0174         ('wallpaper', 'write', 'MERGE'),      # merge and overwrite wallpaper
0175         ('wallpaper', 'write', 'OVERWRITE'),
0176         ('ringtone', 'write', 'MERGE'),      # merge and overwrite ringtone
0177         ('ringtone', 'write', 'OVERWRITE'),
0178         ('sms', 'write', 'OVERWRITE'),        # all SMS list writing
0179         ('memo', 'write', 'OVERWRITE'),       # all memo list writing
0180         )
0181 
0182     field_color_data={
0183         'phonebook': {
0184             'name': {
0185                 'first': 1, 'middle': 1, 'last': 1, 'full': 1,
0186                 'nickname': 0, 'details': 1 },
0187             'number': {
0188                 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 },
0189             'email': 2,
0190             'address': {
0191                 'type': 0, 'company': 0, 'street': 0, 'street2': 0,
0192                 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0,
0193                 'details': 0 },
0194             'url': 0,
0195             'memo': 0,
0196             'category': 1,
0197             'wallpaper': 0,
0198             'ringtone': 2,
0199             'storage': 0,
0200             },
0201         'calendar': {
0202             'description': True, 'location': False, 'allday': False,
0203             'start': True, 'end': True, 'priority': False,
0204             'alarm': True, 'vibrate': True,
0205             'repeat': True,
0206             'memo': False,
0207             'category': False,
0208             'wallpaper': False,
0209             'ringtone': True,
0210             },
0211         'memo': {
0212             'subject': True,
0213             'date': True,
0214             'secret': False,
0215             'category': False,
0216             'memo': True,
0217             },
0218         'todo': {
0219             'summary': False,
0220             'status': False,
0221             'due_date': False,
0222             'percent_complete': False,
0223             'completion_date': False,
0224             'private': False,
0225             'priority': False,
0226             'category': False,
0227             'memo': False,
0228             },
0229         }
0230 

Generated by PyXR 0.9.4