Discussion:
[BitPim-devel] bug in com_lglx5450.py
Brent Roettger
2005-12-07 04:54:48 UTC
Permalink
### BITPIM
###
### Copyright (C) 2003-2004 Roger Binns <***@rogerbinns.com>
### Copyright (C) 2005 Simon Capper <***@sbcglobal.net>
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of the BitPim license as detailed in the LICENSE
file.
###
### $Id: com_lglx5450.py,v 1.1 2005/11/15 07:20:14 skyjunky Exp $

"""Communicate with the LG LX5450 cell phone

The LX5450 is substantially similar to the VX4400 except that it supports
more
image formats, has wallpapers in no less than 4 locations and puts things in
slightly different directories. It is almost identical to the vx6000.

The code in this file mainly inherits from VX4400 code and then extends
where
the 5450 has extra functionality

"""

# standard modules
import time
import cStringIO
import sha

# my modules
import common
import copy
import p_lglx5450
import com_lgvx4400
import com_brew
import com_phone
import com_lg
import prototypes

class Phone(com_lgvx4400.Phone):
"Talk to the LG LX5450 cell phone"

desc="LG-LX5450"

protocolclass=p_lglx5450
serialsname='lglx5450'

# more LX5450 indices
imagelocations=(
# offset, index file, files location, type, maximumentries
( 10, "download/dloadindex/brewImageIndex.map", "brew/shared",
"images", 30) ,
( 0xc8, "download/dloadindex/mmsImageIndex.map", "brew/shared/mms",
"mms", 20),
( 0xdc, "download/dloadindex/mmsDrmImageIndex.map",
"brew/shared/mms/d", "drm", 20),
( 0x82, None, None, "camera", 20) # nb camera must be last
)

ringtonelocations=(
# offset, index file, files location, type, maximumentries
( 50, "download/dloadindex/brewRingerIndex.map",
"user/sound/ringer", "ringers", 30),
( 150, "download/dloadindex/mmsRingerIndex.map", "mms/sound", "mms",
20),
( 180, "download/dloadindex/mmsDrmRingerIndex.map", "mms/sound/drm",
"drm", 20)
)

builtinimages= ('Beach Ball', 'Towerbridge', 'Sunflower', 'Beach',
'Fish',
'Sea', 'Snowman')

builtinringtones= ('Ring 1', 'Ring 2', 'Ring 3', 'Ring 4', 'Ring 5',
'Ring 6',
'Annen Polka', 'Beethoven Symphony No. 9', 'Pachelbel
Canon',
'Hallelujah', 'La Traviata', 'Leichte Kavallerie
Overture',
'Mozart Symphony No.40', 'Bach Minuet', 'Farewell',
'Mozart Piano Sonata', 'Sting', 'Trout', 'O solemio',
'Pizzicata Polka', 'Stars and Stripes Forever',
'Pineapple Rag', 'When the Saints Go Marching In',
'Latin',
'Carol 1', 'Carol 2')


def __init__(self, logtarget, commport):
com_lgvx4400.Phone.__init__(self,logtarget,commport)
self.mode=self.MODENONE

def getcameraindex(self):
buf=prototypes.buffer(self.getfilecontents("cam/pics.dat"))
index={}
g=self.protocolclass.campicsdat()
g.readfrombuffer(buf)
for i in g.items:
if len(i.name):
# index[i.index]={'name': i.name, 'date': i.taken, 'origin':
'camera' }
# we currently use the filesystem name rather than rename in
camera
# since the latter doesn't include the file extension which
then makes
# life less pleasant once the file ends up on the computer
index[i.index]={'name': "pic%02d.jpg"%(i.index,), 'date':
i.taken, 'origin': 'camera' }
return index

def eval_detect_data(self, res):
found = False
if res.get(self.brew_version_txt_key, None) is not None:

found=res[self.brew_version_txt_key][:len(self.my_version_txt)]==self.my_version_txt
if found:
res['model']=self.my_model
res['manufacturer']='LG Electronics Inc'
s=res.get(self.esn_file_key, None)
if s:
res['esn']=self.get_esn(s)


my_version_txt='AX545V'
my_model='LX5450'

parentprofile=com_lgvx4400.Profile
class Profile(parentprofile):
protocolclass=Phone.protocolclass
serialsname=Phone.serialsname
phone_manufacturer='LG Electronics Inc'
phone_model='LX5450'

WALLPAPER_WIDTH=120
WALLPAPER_HEIGHT=131
MAX_WALLPAPER_BASENAME_LENGTH=32

WALLPAPER_FILENAME_CHARS="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
."
WALLPAPER_CONVERT_FORMAT="bmp"

MAX_RINGTONE_BASENAME_LENGTH=32

RINGTONE_FILENAME_CHARS="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
."

# nb we don't allow save to camera so it isn't listed here
imageorigins={}
imageorigins.update(common.getkv(parentprofile.stockimageorigins,
"images"))
imageorigins.update(common.getkv(parentprofile.stockimageorigins,
"mms"))
imageorigins.update(common.getkv(parentprofile.stockimageorigins,
"drm"))
def GetImageOrigins(self):
return self.imageorigins

# our targets are the same for all origins
imagetargets={}
imagetargets.update(common.getkv(parentprofile.stockimagetargets,
"wallpaper",
{'width': 120, 'height': 131,
'format': "BMP"}))

def GetTargetsForImageOrigin(self, origin):
return self.imagetargets

_supportedsyncs=(
('sms', 'read', None),
('sms', 'write', 'OVERWRITE'),
('phonebook', 'read', None), # all phonebook reading
('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook
('calendar', 'write', 'OVERWRITE'), # only overwriting calendar
('calendar', 'read', None), # all calendar reading
('wallpaper', 'read', None), # all wallpaper reading
('wallpaper', 'write', 'MERGE'), # merge and overwrite
wallpaper
('wallpaper', 'write', 'OVERWRITE'),
('ringtone', 'read', None), # all ringtone reading
('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone
('ringtone', 'write', 'OVERWRITE'),
('memo', 'read', None), # all memo list reading DJP
('memo', 'write', 'OVERWRITE'), # all memo list writing DJP
('call_history', 'read', None),
)

def __init__(self):
parentprofile.__init__(self)
Stephen Wood
2005-12-07 05:23:27 UTC
Permalink
Your fix looks fine. I'll let Simon check it in because it's his code.
...
This also brings up a good guestion. What is considered proper etiquette
when finding a bug in someone else's code in BitPim?
Just report the bug on one of the mailing lists, use bitpim-devel if you
have a suggested fix. The best way to submit a fix is to post a difference.

I also think I found out why the code I have submitted was having extra line
breaks. I am using Tortoise CVS and it has an option to "Use "Unix line
endings". It is not marked by default. How does this file look?
It still looks like long lines are broken. Try sending me (privately is
fine) your com_lgpm325.py file in a zip or tar file so we can figure out if
the line breaking is happening on your computer or in the emailing process.

Stephen
Roger Binns
2005-12-07 06:59:53 UTC
Permalink
What is considered proper etiquette when finding a bug in someone else's code in BitPim?
Everyone is egoless :-) The only criteria you should use is whether code you are
suggesting/adding improves BitPim. If it does then everyone will be happy for it.
(Bug fixes easily fit that criteria).
I am using Tortoise CVS
The CVS eol rules on Windows are simple. Either use entirely native Windows CVS
(Tortoise counts), Windows editor etc or use entirely UNIXy (cygwin & family)
versions of cvs and editors. If you mix and match then a line ending nightmare
happens in the repository and to all other people who check the code out.

Subversion fixes all these silly issues and SourceForge keep promising it real
soon now.

Roger
Simon C
2005-12-07 15:06:32 UTC
Permalink
Done, it should appear in the public CVS in a few hours.



Simon



_____

From: bitpim-devel-***@lists.sourceforge.net
[mailto:bitpim-devel-***@lists.sourceforge.net] On Behalf Of Stephen Wood
Sent: Tuesday, December 06, 2005 9:23 PM
To: bitpim-***@lists.sourceforge.net
Subject: Re: [BitPim-devel] bug in com_lglx5450.py



Your fix looks fine. I'll let Simon check it in because it's his code.




On 12/6/05, Brent Roettger <***@msn.com <mailto:***@msn.com> >
wrote:

...



This also brings up a good guestion. What is considered proper etiquette
when finding a bug in someone else's code in BitPim?


Just report the bug on one of the mailing lists, use bitpim-devel if you
have a suggested fix. The best way to submit a fix is to post a difference.




I also think I found out why the code I have submitted was having extra line
breaks. I am using Tortoise CVS and it has an option to "Use "Unix line
endings". It is not marked by default. How does this file look?

It still looks like long lines are broken. Try sending me (privately is
fine) your com_lgpm325.py file in a zip or tar file so we can figure out if
the line breaking is happening on your computer or in the emailing process.

Stephen
Simon C
2005-12-07 15:29:45 UTC
Permalink
What is considered proper etiquette when finding a bug in someone else's
code in BitPim?
Everyone is egoless :-) The only criteria you should use is whether code
you are
suggesting/adding improves BitPim. If it does then everyone will be happy
for it.
(Bug fixes easily fit that criteria).
Yup we don't have egos, only EGOs. :)
I am using Tortoise CVS
The CVS eol rules on Windows are simple. Either use entirely native
Windows CVS
(Tortoise counts), Windows editor etc or use entirely UNIXy (cygwin &
family)
versions of cvs and editors. If you mix and match then a line ending
nightmare
happens in the repository and to all other people who check the code out.
Subversion fixes all these silly issues and SourceForge keep promising it
real
soon now.
I had the same problem e-mail source. I use dos2unix (get cygwin, mingw or
similar) to convert source files before e-mailing.

Simon

Loading...