def __init__(self): parentprofile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('call_history', 'read', None), ('sms', 'read', None), ('memo', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'), ('wallpaper', 'write', 'MERGE'), ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), ('memo', 'write', 'OVERWRITE'), ('playlist', 'read', 'OVERWRITE'), ('playlist', 'write', 'OVERWRITE'), ) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 320, 'height': 230, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", {'width': 320, 'height': 198, 'format': "JPEG"}))
def __init__(self): parentprofile.__init__(self) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 128, 'height': 128, 'format': "BMP"}))
def GetTargetsForImageOrigin(self, origin): if origin=='images': return self.imagetargets def __init__(self): parent_profile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'read', None), ('calendar', 'write', 'OVERWRITE'), ('ringtone', 'read', None), ('ringtone', 'write', 'OVERWRITE'), ('wallpaper', 'read', None), ('wallpaper', 'write', 'OVERWRITE'), ('memo', 'read', None), ('memo', 'write', 'OVERWRITE'), ('sms', 'read', None), ('call_history', 'read', None), ) def convertphonebooktophone(self, helper, data): return data imageorigins.update(common.getkv(parent_profile.stockimageorigins, "images")) imagetargets.update(common.getkv(parent_profile.stockimagetargets, "wallpaper", {'width': 128, 'height': 128, 'format': "JPEG"}))
def GetTargetsForImageOrigin(self, origin): if False: targets={} targets.update(common.getkv(self.stockimagetargets, "wallpaper", {'width': 77, 'height': 177, 'format': "BMP"})) targets.update(common.getkv(self.stockimagetargets, "outsidelcd", {'width': 77, 'height': 77, 'format': "JPEG"})) return targets convert_format_map={'bmp': 'BMP', 'jpg': 'JPEG', 'png': 'PNG'} return common.getkv(self.stockimagetargets, "wallpaper", {'width': self.WALLPAPER_WIDTH, 'height': self.WALLPAPER_HEIGHT, 'format': convert_format_map[self.WALLPAPER_CONVERT_FORMAT]})
def GetTargetsForImageOrigin(self, origin): if origin=='images': return self.imagetargets if __debug__: _supportedsyncs+=(('sms', 'write', 'OVERWRITE'),) imageorigins.update(common.getkv(com_samsung.Profile.stockimageorigins, "images")) imagetargets.update(common.getkv(com_samsung.Profile.stockimagetargets, "wallpaper", {'width': 128, 'height': 128, 'format': "PNG"})) imagetargets.update(common.getkv(com_samsung.Profile.stockimagetargets, "fullscreen", {'width': 128, 'height': 160, 'format': "PNG"}))
def GetTargetsForImageOrigin(self, origin): if False: # this is how you should do it in your derived class. The update dictionary # fields must correspond to what fileinfo.ImgFileInfo uses. The information # is used to save the new file out. targets = {} targets.update( common.getkv(self.stockimagetargets, "wallpaper", {"width": 77, "height": 177, "format": "BMP"}) ) targets.update( common.getkv(self.stockimagetargets, "outsidelcd", {"width": 77, "height": 77, "format": "JPEG"}) ) return targets # this code is here to work with the old way we used to do things convert_format_map = {"bmp": "BMP", "jpg": "JPEG", "png": "PNG"} return common.getkv( self.stockimagetargets, "wallpaper", { "width": self.WALLPAPER_WIDTH, "height": self.WALLPAPER_HEIGHT, "format": convert_format_map[self.WALLPAPER_CONVERT_FORMAT], }, )
def getindex(self, indexfile): "Read an index file" index={} if re.search("ImageIndex", indexfile) is not None: ind=0 for ifile in 'wallpaper', 'poweron', 'poweroff': ifilefull="download/"+ifile+".bit" try: mediafiledata=self.mediacache.readfile(ifilefull) if len(mediafiledata)!=0: index[ind]=ifile ind = ind + 1 self.log("Index file "+indexfile+" entry added: "+ifile) except: pass else: try: buf=prototypes.buffer(self.getfilecontents(indexfile)) except com_brew.BrewNoSuchFileException: return index g=self.protocolclass.indexfile() g.readfrombuffer(buf) self.logdata("Index file %s read with %d entries" % (indexfile,g.numactiveitems), buf.getdata(), g) for i in g.items: if i.index!=0xffff: ifile=re.sub("\.mid|\.MID", "", i.name) self.log("Index file "+indexfile+" entry added: "+ifile) index[i.index]=ifile return index def getmedia(self, maps, result, key): """Returns the contents of media as a dict where the key is a name as returned by getindex, and the value is the contents of the media""" media={} type=None for offset,indexfile,location,type,maxentries in maps: index=self.getindex(indexfile) for i in index: if type=="images": mediafilename=index[i]+".bit" else: mediafilename=index[i]+".mid" try: media[index[i]]=self.mediacache.readfile(location+"/"+mediafilename) except com_brew.BrewNoSuchFileException: self.log("Missing index file: "+location+"/"+mediafilename) result[key]=media return result def savemedia(self, mediakey, mediaindexkey, maps, results, merge, reindexfunction): """Actually saves out the media @param mediakey: key of the media (eg 'wallpapers' or 'ringtone') @param mediaindexkey: index key (eg 'wallpaper-index') @param maps: list index files and locations @param results: results dict @param merge: are we merging or overwriting what is there? @param reindexfunction: the media is re-indexed at the end. this function is called to do it """ print results.keys() wp=results[mediakey].copy() wpi=results[mediaindexkey].copy() for k in wp.keys(): wp[k]['name']=re.sub("\....$", "", wp[k]['name']) for k in wpi.keys(): if wpi[k]['origin']=='builtin': del wpi[k] init={} for offset,indexfile,location,type,maxentries in maps: init[type]={} for k in wpi.keys(): if wpi[k]['origin']==type: index=k-offset name=wpi[k]['name'] data=None del wpi[k] for w in wp.keys(): if wp[w]['name']==name: data=wp[w]['data'] del wp[w] if not merge and data is None: continue init[type][index]={'name': name, 'data': data} print init.keys() for w in wp.keys(): o=wp[w].get("origin", "") if o is not None and len(o) and o in init: idx=-1 while idx in init[o]: idx-=1 init[o][idx]=wp[w] del wp[w] for offset,indexfile,location,type,maxentries in maps: if type=="camera": break index=init[type] try: dirlisting=self.getfilesystem(location) except com_brew.BrewNoSuchDirectoryException: self.mkdirs(location) dirlisting={} for i in dirlisting.keys(): dirlisting[i[len(location)+1:]]=dirlisting[i] del dirlisting[i] dellist=[] if not merge: wpi=results[mediaindexkey] for i in wpi: entry=wpi[i] if entry['origin']==type: delit=True for idx in index: if index[idx]['name']==entry['name']: delit=False break if delit: if type=="ringers": entryname=entry['name']+".mid" else: entryname=entry['name']+".bit" if entryname in dirlisting: dellist.append(entryname) else: self.log("%s in %s index but not filesystem" % (entryname, type)) print "deleting",dellist for f in dellist: self.mediacache.rmfile(location+"/"+f) if type=="images": losem=[] wpi=results[mediaindexkey] for idx in index: delit=True for i in wpi: entry=wpi[i] if entry['origin']==type: if index[idx]['name']==entry['name']: delit=False break if delit: self.log("Inhibited upload of illegit image (not originally on phone): "+index[idx]['name']) losem.append(idx) for idx in losem: del index[idx] while len(index)<maxentries and len(wp): idx=-1 while idx in index: idx-=1 k=wp.keys()[0] index[idx]=wp[k] del wp[k] index=self._normaliseindices(index) if len(index)>maxentries: keys=index.keys() keys.sort() for k in keys[maxentries:]: idx=-1 while idx in wp: idx-=1 wp[idx]=index[k] del index[k] for k in index.keys(): if type=="ringers": index[k]['name']=index[k]['name']+".mid" else: index[k]['name']=index[k]['name']+".bit" keys=index.keys() keys.sort() ifile=self.protocolclass.indexfile() ifile.numactiveitems=len(keys) for k in keys: entry=self.protocolclass.indexentry() entry.index=k entry.name=index[k]['name'] ifile.items.append(entry) while len(ifile.items)<maxentries: ifile.items.append(self.protocolclass.indexentry()) buffer=prototypes.buffer() ifile.writetobuffer(buffer) if type!="images": self.logdata("Updated index file "+indexfile, buffer.getvalue(), ifile) self.writefile(indexfile, buffer.getvalue()) for k in keys: entry=index[k] entryname=entry['name'] data=entry.get("data", None) if type=="images": if entryname!="wallpaper.bit" and entryname!="poweron.bit" and entryname!="poweroff.bit": self.log("The wallpaper files can only be wallpaper.bmp, poweron.bmp or poweroff.bmp. "+entry['name']+" does not conform - skipping upload.") continue if data is None: if entryname not in dirlisting: self.log("Index error. I have no data for "+entryname+" and it isn't already in the filesystem - skipping upload.") continue if type=="images" and data[0:2]=="BM": data=conversions.convertbmptolgbit(data) if data is None: self.log("The wallpaper BMP images must be 8BPP or 24BPP, "+entry['name']+", does not comply - skipping upload.") continue if type=="images" and (common.LSBUint16(data[0:2])!=128 or common.LSBUint16(data[2:4])!=128): self.log("The wallpaper must be 128x128, "+entry['name']+", does not comply - skipping upload.") continue if type!="images": if entryname in dirlisting and len(data)==dirlisting[entryname]['size']: self.log("Skipping writing %s/%s as there is already a file of the same length" % (location,entryname)) continue self.mediacache.writefile(location+"/"+entryname, data) self.log("Wrote media file: "+location+"/"+entryname) if len(wp): for k in wp: self.log("Unable to put %s on the phone as there weren't any spare index entries" % (wp[k]['name'],)) del results[mediakey] reindexfunction(results) return results my_model='AX3200' "Talk to the LG VX3200 cell phone" parentprofile=com_lgvx4400.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname phone_manufacturer='LG Electronics Inc' phone_model='VX3200' phone_manufacturer='LG Electronics Inc.' phone_model='VX3200 107' usbids=com_lgvx4400.Profile.usbids_usbtoserial def convertphonebooktophone(self, helper, data): """Converts the data to what will be used by the phone @param data: contains the dict returned by getfundamentals as well as where the results go""" results={} speeds={} self.normalisegroups(helper, data) for pbentry in data['phonebook']: if len(results)==self.protocolclass.NUMPHONEBOOKENTRIES: break e={} entry=data['phonebook'][pbentry] try: serial1=helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial1', 0) serial2=helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial2', serial1) e['serial1']=serial1 e['serial2']=serial2 for ss in entry["serials"]: if ss["sourcetype"]=="bitpim": e['bitpimserial']=ss assert e['bitpimserial'] e['name']=helper.getfullname(entry.get('names', []),1,1,22)[0] cat=helper.makeone(helper.getcategory(entry.get('categories', []),0,1,22), None) if cat is None: e['group']=0 else: key,value=self._getgroup(cat, data['groups']) if key is not None: if key>5: e['group']=0 print "Custom Groups in PB not supported - setting to No Group for "+e['name'] else: e['group']=key else: e['group']=0 emails=helper.getemails(entry.get('emails', []) ,0,self.protocolclass.NUMEMAILS,48) e['emails']=helper.filllist(emails, self.protocolclass.NUMEMAILS, "") e['url']=helper.makeone(helper.geturls(entry.get('urls', []), 0,1,48), "") e['memo']=helper.makeone(helper.getmemos(entry.get('memos', []), 0, 1, self.protocolclass.MEMOLENGTH-1), "") minnumbers=1 if len(emails): minnumbers=0 numbers=helper.getnumbers(entry.get('numbers', []),minnumbers,self.protocolclass.NUMPHONENUMBERS) e['numbertypes']=[] e['numbers']=[] for numindex in range(len(numbers)): num=numbers[numindex] b4=len(e['numbertypes']) type=num['type'] for i,t in enumerate(self.protocolclass.numbertypetab): if type==t: if i in e['numbertypes'] and t[-1]!='2': type+='2' continue e['numbertypes'].append(i) break if t=='none': e['numbertypes'].append(i) break if len(e['numbertypes'])==b4: continue number=self.phonize(num['number']) if len(number)==0: continue if len(number)>48: number=number[:48] e['numbers'].append(number) sd=num.get("speeddial", -1) if self.protocolclass.NUMSPEEDDIALS: if sd>=self.protocolclass.FIRSTSPEEDDIAL and sd<=self.protocolclass.LASTSPEEDDIAL: speeds[sd]=(e['bitpimserial'], numindex) e['numbertypes']=helper.filllist(e['numbertypes'], 5, 0) e['numbers']=helper.filllist(e['numbers'], 5, "") ecring=helper.getringtone(entry.get('ringtones', []), 'call', None) if ecring is not None: if ecring not in Phone.builtinringtones: print "Ringers past Carol 2 in PB not supported - setting to Default Ringer for "+e['name']+" id was: "+ecring ecring=None e['ringtone']=ecring emring=helper.getringtone(entry.get('ringtones', []), 'message', None) if emring is not None: if emring not in Phone.builtinringtones: print "Ringers past Carol 2 in PB not supported - setting to Default MsgRinger for "+e['name']+" id was: "+emring emring=None e['msgringtone']=emring ewall=helper.getwallpaper(entry.get('wallpapers', []), 'call', None) if ewall is not None: print "Custom Wallpapers in PB not supported - setting to Default Wallpaper for "+e['name'] e['wallpaper']=None e['secret']=helper.getflag(entry.get('flags',[]), 'secret', False) results[pbentry]=e except helper.ConversionFailed: continue if self.protocolclass.NUMSPEEDDIALS: data['speeddials']=speeds data['phonebook']=results return data _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'), ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), ('ringtone', 'write', 'OVERWRITE'), ('call_history', 'read', None), ('memo', 'read', None), ('memo', 'write', 'OVERWRITE'), ('sms', 'read', None), ('sms', 'write', 'OVERWRITE'), ) WALLPAPER_WIDTH=128 WALLPAPER_HEIGHT=128 MAX_WALLPAPER_BASENAME_LENGTH=19 WALLPAPER_FILENAME_CHARS="abcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT="bmp" MAX_RINGTONE_BASENAME_LENGTH=19 RINGTONE_FILENAME_CHARS="abcdefghijklmnopqrstuvxwyz0123456789 ." imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 128, 'height': 128, 'format': "BMP"})) def GetTargetsForImageOrigin(self, origin):
class Profile(parentprofile): serialsname = Phone.serialsname WALLPAPER_WIDTH = 176 WALLPAPER_HEIGHT = 220 MAX_WALLPAPER_BASENAME_LENGTH = 37 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" WALLPAPER_CONVERT_FORMAT = "jpg" # Motorola OEM USB Cable usbids = ((0x22B8, 0x2A22, 1), (0x22B8, 0x2A62, 1)) deviceclasses = ("modem", ) # use for auto-detection phone_manufacturer = 'Motorola' phone_model = 'V710 ' common_model_name = 'V710' generic_phone_model = 'Motorola CDMA v710 Phone' # all dumped in "images" imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 176, 'height': 200, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 176, 'height': 140, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 176, 'height': 220, 'format': "JPEG" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'read', None), # all calendar reading ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('ringtone', 'read', None), # all ringtone reading ('ringtone', 'write', 'OVERWRITE'), ('wallpaper', 'read', None), # all wallpaper reading ('wallpaper', 'write', 'OVERWRITE'), ('sms', 'read', None), # all SMS list reading DJP ) def convertphonebooktophone(self, helper, data): return data def QueryAudio(self, origin, currentextension, afi): # we don't modify any of these if afi.format in ("MIDI", "QCP", "PMD"): return currentextension, afi # examine mp3 if afi.format == "MP3": if afi.channels == 1 and 8 <= afi.bitrate <= 64 and 16000 <= afi.samplerate <= 22050: return currentextension, afi # convert it return ("mp3", fileinfo.AudioFileInfo( afi, **{ 'format': 'MP3', 'channels': 1, 'bitrate': 48, 'samplerate': 44100 })) field_color_data = { 'phonebook': { 'name': { 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { # not sure what the limit on these numbers 'type': True, 'speeddial': True, 'number': True, 'details': True, 'ringtone': True, 'wallpaper': True }, 'email': True, 'email_details': { 'emailspeeddial': True, 'emailringtone': True, 'emailwallpaper': True }, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 0, 'memo': 0, 'category': 1, 'wallpaper': 1, 'ringtone': 1, 'storage': 0, }, 'calendar': { 'description': True, 'location': True, 'allday': False, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': False, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': False, }, 'memo': { 'subject': False, 'date': False, 'secret': False, 'category': False, 'memo': False, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, }
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX8550' # inside screen resoluation WALLPAPER_WIDTH = 176 WALLPAPER_HEIGHT = 220 imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "images(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "video(sd)")) # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 238, 'height': 246, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 240, 'height': 274, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 120, 'height': 100, 'format': "JPEG" })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ('t9_udb', 'write', 'OVERWRITE'), ) if __debug__: _supportedsyncs += (('t9_udb', 'read', 'OVERWRITE'), ) def convertphonebooktophone(self, helper, data): """Converts the data to what will be used by the phone @param data: contains the dict returned by getfundamentals as well as where the results go""" results = {} self.normalisegroups(helper, data) for pbentry in data['phonebook']: if len(results) == self.protocolclass.NUMPHONEBOOKENTRIES: break e = {} # entry out entry = data['phonebook'][pbentry] # entry in try: # serials serial1 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial1', 0) serial2 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial2', serial1) e['serial1'] = serial1 e['serial2'] = serial2 for ss in entry["serials"]: if ss["sourcetype"] == "bitpim": e['bitpimserial'] = ss assert e['bitpimserial'] # name e['name'] = helper.getfullname(entry.get('names', []), 1, 1, 32)[0] # ice e['ice'] = entry.get('ice', None) # categories/groups cat = helper.makeone( helper.getcategory(entry.get('categories', []), 0, 1, 32), None) if cat is None: e['group'] = 0 else: key, value = self._getgroup(cat, data['groups']) if key is not None: e['group'] = key else: # sorry no space for this category e['group'] = 0 # email addresses emails = helper.getemails(entry.get('emails', []), 0, self.protocolclass.NUMEMAILS, 48) e['emails'] = helper.filllist(emails, self.protocolclass.NUMEMAILS, "") # phone numbers # there must be at least one email address or phonenumber minnumbers = 1 if len(emails): minnumbers = 0 numbers = helper.getnumbers(entry.get('numbers', []), minnumbers, self.protocolclass.NUMPHONENUMBERS) e['numbertypes'] = [] e['numbers'] = [] e['speeddials'] = [] for numindex in range(len(numbers)): num = numbers[numindex] # deal with type b4 = len(e['numbertypes']) type = num['type'] for i, t in enumerate(self.protocolclass.numbertypetab): if type == t: # some voodoo to ensure the second home becomes home2 if i in e['numbertypes'] and t[-1] != '2': type += '2' continue e['numbertypes'].append(i) break if t == 'none': # conveniently last entry e['numbertypes'].append(i) break if len(e['numbertypes']) == b4: # we couldn't find a type for the number helper.add_error_message( 'Number %s (%s/%s) not supported and ignored.' % (num['number'], e['name'], num['type'])) continue # deal with number number = self.phonize(num['number']) if len(number) == 0: # no actual digits in the number continue if len(number ) > 48: # get this number from somewhere sensible # ::TODO:: number is too long and we have to either truncate it or ignore it? number = number[:48] # truncate for moment e['numbers'].append(number) # deal with speed dial sd = num.get("speeddial", None) if sd is not None and \ sd>=self.protocolclass.FIRSTSPEEDDIAL and \ sd<=self.protocolclass.LASTSPEEDDIAL: e['speeddials'].append(sd) else: e['speeddials'].append(None) if len(e['numbers']) < minnumbers: # we couldn't find any numbers # for this entry, so skip it, entries with no numbers cause error helper.add_error_message( "Name: %s. No suitable numbers or emails found" % e['name']) continue e['numbertypes'] = helper.filllist( e['numbertypes'], self.protocolclass.NUMPHONENUMBERS, 0) e['numbers'] = helper.filllist( e['numbers'], self.protocolclass.NUMPHONENUMBERS, "") e['speeddials'] = helper.filllist( e['speeddials'], self.protocolclass.NUMPHONENUMBERS, None) # ringtones, wallpaper e['ringtone'] = helper.getringtone(entry.get('ringtones', []), 'call', None) e['wallpaper'] = helper.getwallpaper( entry.get('wallpapers', []), 'call', None) results[pbentry] = e except helper.ConversionFailed: continue data['phonebook'] = results return data
def _write_playlists(self, pl, all_songs): for _pl_item in pl: try: _pl_file=self.protocolclass.playlistfile() for _song in _pl_item.songs: _song_name=self.protocolclass.mp3_dir+'/'+_song if all_songs.has_key(_song_name): _entry=self.protocolclass.playlistentry() _entry.name=_song_name _pl_file.items.append(_entry) if len(_pl_file.items): _buf=prototypes.buffer() _pl_file.writetobuffer(_buf) _file_name=self.protocolclass.pl_dir+'/'+_pl_item.name+\ self.protocolclass.pl_extension self.writefile(_file_name, _buf.getvalue()) except: if __debug__: raise def saveplaylist(self, result, merge): if not self.exists(self.protocolclass.pl_dir): self.log('Playlist dir does not exist. Bail') return result _all_songs=self.listfiles(self.protocolclass.mp3_dir) _files=self.listfiles(self.protocolclass.pl_dir) for _f in _files: try: self.rmfile(_f) except: if __debug__: raise self._write_playlists(result.get(playlist.playlist_key, []), _all_songs) return result "Talk to the LG VX9800 cell phone" parentprofile=com_lgvx8100.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='VX9800' WALLPAPER_WIDTH=320 WALLPAPER_HEIGHT=256 MAX_WALLPAPER_BASENAME_LENGTH=32 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" WALLPAPER_CONVERT_FORMAT="jpg" DIALSTRING_CHARS="[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH=32 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" bluetooth_mfg_id="001256" imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 320, 'height': 230, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", {'width': 320, 'height': 198, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin):
def getringtones(self, result): self.setmode(self.MODEBREW) m=FileEntries(self, self.__ringtone_info) rt_info=RingtoneIndex(self).get_download_info() r=m.get_media(result, rt_info) self.setmode(self.MODEMODEM) return r def saveringtones(self, result, merge): self.setmode(self.MODEBREW) m=FileEntries(self, self.__ringtone_info) result['rebootphone']=1 r=m.save_media(result, RingtoneIndex(self).get_download_info()) self.setmode(self.MODEMODEM) return r def getwallpapers(self, result): self.setmode(self.MODEBREW) m=FileEntries(self, self.__wallpaper_info) img_info=ImageIndex(self).get_download_info() r=m.get_media(result, img_info) self.setmode(self.MODEMODEM) return r def savewallpapers(self, result, merge): self.setmode(self.MODEBREW) m=FileEntries(self, self.__wallpaper_info) r=m.save_media(result, ImageIndex(self).get_download_info()) result['rebootphone']=1 self.setmode(self.MODEMODEM) return r getmemo=parent_phone._getmemo savememo=parent_phone._savememo gettodo=parent_phone._gettodo savetodo=parent_phone._savetodo getsms=parent_phone._getsms savesms=parent_phone._savesms getphoneinfo=parent_phone._getphoneinfo getmedia=None detectphone=staticmethod(parent_phone._detectphone) "Talk to the Samsung SCH-A650 Cell Phone" class Profile (com_samsung.Profile) : serialsname='scha650' WALLPAPER_WIDTH=128 WALLPAPER_HEIGHT=160 MAX_WALLPAPER_BASENAME_LENGTH=17 WALLPAPER_FILENAME_CHARS="abcdefghijklmnopqrstuvwxyz0123456789_*[]=<>;|?:% ." WALLPAPER_CONVERT_FORMAT="png" MAX_RINGTONE_BASENAME_LENGTH=17 RINGTONE_FILENAME_CHARS="abcdefghijklmnopqrstuvwxyz0123456789_*[]=<>;|?:% ." RINGTONE_LIMITS= { 'MAXSIZE': 30000 } phone_manufacturer='SAMSUNG ELECTRONICS' phone_model='SCH-A650/163' def __init__(self): com_samsung.Profile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'read', None), ('calendar', 'write', 'OVERWRITE'), ('ringtone', 'read', None), ('ringtone', 'write', 'OVERWRITE'), ('wallpaper', 'read', None), ('wallpaper', 'write', 'OVERWRITE'), ('memo', 'read', None), ('memo', 'write', 'OVERWRITE'), ('todo', 'read', None), ('todo', 'write', 'OVERWRITE'), ('sms', 'read', None), ) if __debug__: _supportedsyncs+=(('sms', 'write', 'OVERWRITE'),) def convertphonebooktophone(self, helper, data): return data __audio_ext={ 'MIDI': 'mid', 'QCP': 'qcp', 'PMD': 'pmd' } def QueryAudio(self, origin, currentextension, afi): if afi.format in ("MIDI", "QCP", "PMD"): for k,n in self.RINGTONE_LIMITS.items(): setattr(afi, k, n) return currentextension, afi d=self.RINGTONE_LIMITS.copy() d['format']='QCP' return ('qcp', fileinfo.AudioFileInfo(afi, **d)) imageorigins={} imageorigins.update(common.getkv(com_samsung.Profile.stockimageorigins, "images")) imagetargets={} imagetargets.update(common.getkv(com_samsung.Profile.stockimagetargets, "wallpaper", {'width': 128, 'height': 128, 'format': "PNG"})) imagetargets.update(common.getkv(com_samsung.Profile.stockimagetargets, "fullscreen", {'width': 128, 'height': 160, 'format': "PNG"})) def GetImageOrigins(self):
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_manufacturer = 'LG Electronics Inc' phone_model = 'UX5000' WALLPAPER_WIDTH = 132 WALLPAPER_HEIGHT = 148 MAX_WALLPAPER_BASENAME_LENGTH = 24 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ." WALLPAPER_CONVERT_FORMAT = "jpg" MAX_RINGTONE_BASENAME_LENGTH = 24 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ." ringtoneorigins = ('ringers', 'mms', 'drm') excluded_ringtone_origins = ('mms', 'drm') # 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': 132, 'height': 148, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 132, 'height': 148, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 128, 'height': 160, 'format': "JPEG" })) # can the outside lcd display images? #imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", # {'width': 96, 'height': 64, 'format': "JPEG"})) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ) def __init__(self): parentprofile.__init__(self)
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX8700' # inside screen resoluation WALLPAPER_WIDTH = 240 WALLPAPER_HEIGHT = 320 imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "images(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "video(sd)")) # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 238, 'height': 246, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 240, 'height': 274, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 120, 'height': 100, 'format': "JPEG" })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ('t9_udb', 'write', 'OVERWRITE'), ) if __debug__: _supportedsyncs += (('t9_udb', 'read', 'OVERWRITE'), ) # new group file format requires a new normalization routine def normalisegroups(self, helper, data): self.normalizegroups(helper, data) def normalizegroups(self, helper, data): "Assigns groups based on category data" pad = [] keys = data['groups'].keys() keys.sort() for k in keys: if k: # ignore key 0 which is 'No Group' name = data['groups'][k]['name'] pad.append(name) groups = helper.getmostpopularcategories( self.protocolclass.MAX_PHONEBOOK_GROUPS, data['phonebook'], ["No Group"], 32, pad) # alpha sort groups.sort() # newgroups newgroups = {} # put in No group newgroups[0] = {'name': 'No Group', 'user_added': 0} # populate for name in groups: # existing entries remain unchanged if name == "No Group": continue key, value = self._getgroup(name, data['groups']) if key is not None and key != 0: newgroups[key] = value # new entries get whatever numbers are free for name in groups: key, value = self._getgroup(name, newgroups) if key is None: for key in range(1, 100000): if key not in newgroups: newgroups[key] = {'name': name, 'user_added': 1} break # yay, done if data['groups'] != newgroups: data['groups'] = newgroups data['rebootphone'] = True
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'lg6190' # from Bell Mobility brew_required = True RINGTONE_LIMITS = {'MAXSIZE': 250000} WALLPAPER_WIDTH = 160 WALLPAPER_HEIGHT = 120 MAX_WALLPAPER_BASENAME_LENGTH = 30 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789." WALLPAPER_CONVERT_FORMAT = "jpg" MAX_RINGTONE_BASENAME_LENGTH = 30 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789." DIALSTRING_CHARS = "[^0-9PT#*]" # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 128, 'height': 160, 'format': "JPEG" })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('memo', 'read', None), # all memo list reading ('sms', 'read', None), # all SMS list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('memo', 'write', 'OVERWRITE'), # all memo list writing ('sms', 'write', 'OVERWRITE'), # all SMS list writing ) field_color_data = { 'phonebook': { 'name': { 'first': 0, 'middle': 0, 'last': 0, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 }, 'email': 3, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 1, 'memo': 1, 'category': 1, 'wallpaper': 0, 'ringtone': 1, 'storage': 0, }, 'calendar': { 'description': True, 'location': False, 'allday': True, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': False, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': True, 'date': False, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, }
class Profile(parentprofile): protocolclass=Phone.protocolclass serialsname=Phone.serialsname BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='LG8100' WALLPAPER_WIDTH=176 WALLPAPER_HEIGHT=220 MAX_WALLPAPER_BASENAME_LENGTH=32 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()-_ ." WALLPAPER_CONVERT_FORMAT="jpg" # the 8100 uses "W" for wait in the dialstring, it does not support "T" DIALSTRING_CHARS="[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH=32 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()-_ ." # the 8100 doesn't have seperate origins - they are all dumped in "images" imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins # our targets are the same for all origins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", {'width': 128, 'height': 128, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 176, 'height': 220, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None),# all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ) field_color_data={ 'phonebook': { 'name': { 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 }, 'email': 2, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 0, 'memo': 1, 'category': 1, 'wallpaper': 1, 'ringtone': 2, 'storage': 0, }, 'calendar': { 'description': True, 'location': True, 'allday': True, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': True, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': True, 'date': True, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, }
phone_model='VX8000' WALLPAPER_WIDTH=176 WALLPAPER_HEIGHT=184 MAX_WALLPAPER_BASENAME_LENGTH=32 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT="jpg" MAX_RINGTONE_BASENAME_LENGTH=32 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 176, 'height': 184, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "pictureid", {'width': 176, 'height': 184, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "outsidelcd", {'width': 96, 'height': 80, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 176, 'height': 220, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs=(
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX7000' WALLPAPER_WIDTH = 176 WALLPAPER_HEIGHT = 184 MAX_WALLPAPER_BASENAME_LENGTH = 32 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT = "jpg" MAX_RINGTONE_BASENAME_LENGTH = 32 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." # the 7000 doesn't have seperate origins - they are all dumped in "images" imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 176, 'height': 184, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 176, 'height': 184, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 96, 'height': 80, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 176, 'height': 220, 'format': "JPEG" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing )
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX8500' WALLPAPER_WIDTH = 240 WALLPAPER_HEIGHT = 320 MAX_WALLPAPER_BASENAME_LENGTH = 32 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ." WALLPAPER_CONVERT_FORMAT = "jpg" # the 8300 uses "W" for wait in the dialstring, it does not support "T" DIALSTRING_CHARS = "[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH = 32 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ." RINGTONE_LIMITS = {'MAXSIZE': 200000} imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "images(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "video(sd)")) def GetImageOrigins(self): return self.imageorigins ringtoneorigins = ('ringers', 'sounds', 'sounds(sd)', ' music', 'music(sd)') excluded_ringtone_origins = ('sounds', 'sounds(sd)', 'music', 'music(sd)') # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 240, 'height': 275, 'format': "JPEG" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) def QueryAudio(self, origin, currentextension, afi): _max_size = self.RINGTONE_LIMITS['MAXSIZE'] setattr(afi, 'MAXSIZE', _max_size) # we don't modify any of these if afi.format in ("MIDI", "QCP", "PMD", "WMA"): return currentextension, afi # examine mp3 if afi.format == "MP3": if afi.channels == 1 and 8 <= afi.bitrate <= 64 and 16000 <= afi.samplerate <= 22050: return currentextension, afi # convert it return ("mp3", fileinfo.AudioFileInfo( afi, **{ 'format': 'MP3', 'channels': 2, 'bitrate': 48, 'samplerate': 44100, 'MAXSIZE': _max_size })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ('playlist', 'read', 'OVERWRITE'), ('playlist', 'write', 'OVERWRITE'), ('t9_udb', 'write', 'OVERWRITE'), ) if __debug__: _supportedsyncs += (('t9_udb', 'read', 'OVERWRITE'), ) field_color_data = { 'phonebook': { 'name': { 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 }, 'email': 2, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 0, 'memo': 0, 'category': 1, 'wallpaper': 1, 'ringtone': 2, 'storage': 0, }, 'calendar': { 'description': True, 'location': False, 'allday': False, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': True, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': True, 'date': True, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, }
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX11000' # inside screen resolution WALLPAPER_WIDTH = 800 WALLPAPER_HEIGHT = 480 ringtoneorigins = ('ringers', 'sounds', 'sounds(sd)', ' music', 'music(sd)') excluded_ringtone_origins = ('music', 'music(sd)') # wallpaper origins that are not available for the contact assignment excluded_wallpaper_origins = ('video', 'video(sd)') imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "images(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "video(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "picture ids")) # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 480, 'height': 800, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 800, 'height': 480, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 320, 'height': 240, 'format': "JPEG" })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ## ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ) if __debug__: _supportedsyncs += ( # ('t9_udb', 'read', None), # ('t9_udb', 'write', 'OVERWRITE'), # ('playlist', 'read', None), # ('playlist', 'write', 'OVERWRITE'), ) field_color_data = { 'phonebook': { 'name': { 'first': False, 'middle': False, 'last': False, 'full': 1, 'nickname': False, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'ringtone': False, 'wallpaper': False, 'details': 5 }, 'email': 2, 'email_details': { 'emailspeeddial': False, 'emailringtone': False, 'emailwallpaper': False }, 'address': { 'type': False, 'company': False, 'street': 1, 'street2': False, 'city': 1, 'state': 1, 'postalcode': 1, 'country': 1, 'details': 1 }, 'url': 0, 'memo': 0, 'category': 1, 'wallpaper': 1, 'group_wallpaper': 1, #'wallpaper_type': False, 'ringtone': 1, 'storage': False, 'secret': False, 'ICE': 1, 'Favorite': 1, }, 'calendar': { 'description': True, 'location': False, 'allday': False, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': True, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': False, 'date': True, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, } def convertphonebooktophone(self, helper, data): """Converts the data to what will be used by the phone @param data: contains the dict returned by getfundamentals as well as where the results go""" results = {} self.normalisegroups(helper, data) for pbentry in data['phonebook']: if len(results) == self.protocolclass.NUMPHONEBOOKENTRIES: break e = {} # entry out entry = data['phonebook'][pbentry] # entry in try: # serials serial1 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial1', 0) serial2 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial2', serial1) e['serial1'] = serial1 e['serial2'] = serial2 for ss in entry["serials"]: if ss["sourcetype"] == "bitpim": e['bitpimserial'] = ss assert e['bitpimserial'] # name e['name'] = helper.getfullname(entry.get('names', []), 1, 1, 32)[0] # ice e['ice'] = entry.get('ice', None) # favorites e['favorite'] = entry.get('favorite', None) # address e['addresses'] = entry.get('addresses', None) # im e['ims'] = entry.get('ims', None) # categories/groups cats = helper.getcategory(entry.get('categories', []), 0, self.protocolclass.NUMGROUPS, 32) groups = [] for cat in cats: key, value = self._getgroup(cat, data['groups']) if key is not None: groups.append(key) e['groups'] = helper.filllist(groups, self.protocolclass.NUMGROUPS, 0) # email addresses emails = helper.getemails(entry.get('emails', []), 0, self.protocolclass.NUMEMAILS, 48) e['emails'] = helper.filllist(emails, self.protocolclass.NUMEMAILS, "") # phone numbers # there must be at least one email address or phonenumber minnumbers = 1 if len(emails): minnumbers = 0 numbers = helper.getnumbers(entry.get('numbers', []), minnumbers, self.protocolclass.NUMPHONENUMBERS) e['numbertypes'] = [] e['numbers'] = [] e['speeddials'] = [] for numindex in range(len(numbers)): num = numbers[numindex] # deal with type b4 = len(e['numbertypes']) type = num['type'] for i, t in enumerate(self.protocolclass.numbertypetab): if type == t: # some voodoo to ensure the second home becomes home2 if i in e['numbertypes'] and t[-1] != '2': type += '2' continue e['numbertypes'].append(i) break if t == 'none': # conveniently last entry e['numbertypes'].append(i) break if len(e['numbertypes']) == b4: # we couldn't find a type for the number helper.add_error_message( 'Number %s (%s/%s) not supported and ignored.' % (num['number'], e['name'], num['type'])) continue # deal with number number = self.phonize(num['number']) if len(number) == 0: # no actual digits in the number continue if len(number ) > 48: # get this number from somewhere sensible # ::TODO:: number is too long and we have to either truncate it or ignore it? number = number[:48] # truncate for moment e['numbers'].append(number) # deal with speed dial sd = num.get("speeddial", None) if sd is not None and \ sd>=self.protocolclass.FIRSTSPEEDDIAL and \ sd<=self.protocolclass.LASTSPEEDDIAL: e['speeddials'].append(sd) else: e['speeddials'].append(None) if len(e['numbers']) < minnumbers: # we couldn't find any numbers # for this entry, so skip it, entries with no numbers cause error helper.add_error_message( "Name: %s. No suitable numbers or emails found" % e['name']) continue e['numbertypes'] = helper.filllist( e['numbertypes'], self.protocolclass.NUMPHONENUMBERS, 0) e['numbers'] = helper.filllist( e['numbers'], self.protocolclass.NUMPHONENUMBERS, "") e['speeddials'] = helper.filllist( e['speeddials'], self.protocolclass.NUMPHONENUMBERS, None) # ringtones, wallpaper e['ringtone'] = helper.getringtone(entry.get('ringtones', []), 'call', None) e['wallpaper'] = helper.getwallpaper( entry.get('wallpapers', []), 'call', None) results[pbentry] = e except helper.ConversionFailed: continue data['phonebook'] = results return data
class Profile(com_samsung.Profile): serialsname = 'scha670' WALLPAPER_WIDTH = 128 WALLPAPER_HEIGHT = 128 MAX_WALLPAPER_BASENAME_LENGTH = 19 WALLPAPER_FILENAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789_ ." ## WALLPAPER_CONVERT_FORMAT="bmp" WALLPAPER_CONVERT_FORMAT = "jpg" MAX_RINGTONE_BASENAME_LENGTH = 19 RINGTONE_FILENAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789_ ." RINGTONE_LIMITS = {'MAXSIZE': 30000} # use for auto-detection phone_manufacturer = 'SAMSUNG ELECTRONICS' phone_model = 'SCH-A670/164' def __init__(self): com_samsung.Profile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'read', None), # all calendar reading ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('ringtone', 'read', None), # all ringtone reading ('ringtone', 'write', 'OVERWRITE'), ('wallpaper', 'read', None), # all wallpaper reading ('wallpaper', 'write', 'OVERWRITE'), ('memo', 'read', None), # all memo list reading DJP ('memo', 'write', 'OVERWRITE'), # all memo list writing DJP ('todo', 'read', None), # all todo list reading DJP ('todo', 'write', 'OVERWRITE'), # all todo list writing DJP ('sms', 'read', None), # all SMS list reading DJP ) if __debug__: _supportedsyncs += (('sms', 'write', 'OVERWRITE'), ) def convertphonebooktophone(self, helper, data): return data __audio_ext = {'MIDI': 'mid', 'PMD': 'pmd', 'QCP': 'pmd'} def QueryAudio(self, origin, currentextension, afi): # we don't modify any of these if afi.format in ("MIDI", "PMD", "QCP"): for k, n in self.RINGTONE_LIMITS.items(): setattr(afi, k, n) return currentextension, afi d = self.RINGTONE_LIMITS.copy() d['format'] = 'QCP' return ('pmd', fileinfo.AudioFileInfo(afi, **d)) imageorigins = {} imageorigins.update( common.getkv(com_samsung.Profile.stockimageorigins, "images")) imagetargets = {} imagetargets.update( common.getkv(com_samsung.Profile.stockimagetargets, "wallpaper", { 'width': 128, 'height': 128, 'format': "PNG" })) imagetargets.update( common.getkv(com_samsung.Profile.stockimagetargets, "fullscreen", { 'width': 128, 'height': 160, 'format': "PNG" })) imagetargets.update( common.getkv(com_samsung.Profile.stockimagetargets, "pictureid", { 'width': 96, 'height': 96, 'format': "JPEG" })) def GetImageOrigins(self): # Note: only return origins that you can write back to the phone return self.imageorigins def GetTargetsForImageOrigin(self, origin): # right now, supporting just 'images' origin if origin == 'images': return self.imagetargets
class Profile(parentprofile): serialsname = Phone.serialsname # main LCD resolution, (external LCD is 96x96) WALLPAPER_WIDTH = 128 WALLPAPER_HEIGHT = 160 # For phone detection phone_manufacturer = Phone.my_manufacturer phone_model = Phone.my_model autodetect_delay = 5 # "Warning" media size limit RINGTONE_LIMITS = {'MAXSIZE': 290000} # fill in the list of ringtone/sound origins on your phone ringtoneorigins = ('ringers', 'sounds') # ringtone origins that are not available for the contact assignment excluded_ringtone_origins = () # all dumped in "images" imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 128, 'height': 128, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 96, 'height': 84, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 128, 'height': 160, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 96, 'height': 84, 'format': "JPEG" })) def __init__(self): parentprofile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'read', None), # all calendar reading ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('ringtone', 'read', None), # all ringtone reading ('ringtone', 'write', 'MERGE'), ('wallpaper', 'read', None), # all wallpaper reading ('wallpaper', 'write', 'MERGE'), ('memo', 'read', None), # all memo list reading DJP ('memo', 'write', 'OVERWRITE'), # all memo list writing DJP ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading DJP )
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_manufacturer = 'LG Electronics Inc' phone_model = 'LG-LX5400V' usbids_straight = ( (0x1004, 0x6000, 2), ) # VID=LG Electronics, PID=LG VX4400/VX6000 -internal USB diagnostics interface usbids_usbtoserial = ( (0x067b, 0x2303, None), # VID=Prolific, PID=USB to serial (0x0403, 0x6001, None), # VID=FTDI, PID=USB to serial (0x0731, 0x2003, None), # VID=Susteen, PID=Universal USB to serial (0x6547, 0x0232, None), # VID=ArkMicro, PID=USB to serial ) usbids = usbids_straight + usbids_usbtoserial 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 ringtoneorigins = ('ringers', 'mms', 'drm') excluded_ringtone_origins = ('mms', 'drm') excluded_wallpaper_origins = ('mms', 'drm') # 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)
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX9800' WALLPAPER_WIDTH = 320 WALLPAPER_HEIGHT = 256 MAX_WALLPAPER_BASENAME_LENGTH = 32 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" WALLPAPER_CONVERT_FORMAT = "jpg" # the 9800 uses "W" for wait in the dialstring, it does not support "T" DIALSTRING_CHARS = "[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH = 32 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" # there is an origin named 'aod' - no idea what it is for except maybe # 'all other downloads' # the vx8100 supports bluetooth for connectivity to the PC, define the "bluetooth_mgd_id" # to enable bluetooth discovery during phone detection # the bluetooth address starts with LG's the three-octet OUI, all LG phone # addresses start with this, it provides a way to identify LG bluetooth devices # during phone discovery # OUI=Organizationally Unique Identifier # see http://standards.ieee.org/regauth/oui/index.shtml for more info bluetooth_mfg_id = "001256" # the 8100 doesn't have seperate origins - they are all dumped in "images" imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) def GetImageOrigins(self): return self.imageorigins ringtoneorigins = ('ringers', 'sounds') excluded_ringtone_origins = ('sounds') excluded_wallpaper_origins = ('video') # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 320, 'height': 230, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 320, 'height': 198, 'format': "JPEG" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ('playlist', 'read', 'OVERWRITE'), ('playlist', 'write', 'OVERWRITE'), )
class Profile(parentprofile): serialsname = Phone.serialsname usbids = ((0x22B8, 0x2A64, 1), ) # fill in the list of ringtone/sound origins on your phone ringtoneorigins = ('ringers', 'sounds') # ringtone origins that are not available for the contact assignment excluded_ringtone_origins = () imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) excluded_wallpaper_origins = () # use for auto-detection phone_manufacturer = 'Motorola' phone_model = 'K1m' common_model_name = 'K1m' generic_phone_model = 'Motorola CDMA K1m phone' # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 176, 'height': 184, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 96, 'height': 67, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 176, 'height': 220, 'format': "JPEG" })) field_color_data = parentprofile.field_color_data field_color_data.update({ 'phonebook': { 'name': { 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5, 'ringtone': 5, 'wallpaper': 5 }, 'email': 2, 'email_details': { 'emailspeeddial': 2, 'emailringtone': 2, 'emailwallpaper': 2 }, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 0, 'memo': 0, 'category': 1, 'wallpaper': 1, 'ringtone': 1, 'storage': 0, } })
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX3200' # use for auto-detection phone_manufacturer = 'LG Electronics Inc.' phone_model = 'VX3200 107' # no direct usb interface usbids = com_lgvx4400.Profile.usbids_usbtoserial def convertphonebooktophone(self, helper, data): """Converts the data to what will be used by the phone @param data: contains the dict returned by getfundamentals as well as where the results go""" results = {} speeds = {} self.normalisegroups(helper, data) for pbentry in data['phonebook']: if len(results) == self.protocolclass.NUMPHONEBOOKENTRIES: break e = {} # entry out entry = data['phonebook'][pbentry] # entry in try: # serials serial1 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial1', 0) serial2 = helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial2', serial1) e['serial1'] = serial1 e['serial2'] = serial2 for ss in entry["serials"]: if ss["sourcetype"] == "bitpim": e['bitpimserial'] = ss assert e['bitpimserial'] # name e['name'] = helper.getfullname(entry.get('names', []), 1, 1, 22)[0] # categories/groups cat = helper.makeone( helper.getcategory(entry.get('categories', []), 0, 1, 22), None) if cat is None: e['group'] = 0 else: key, value = self._getgroup(cat, data['groups']) if key is not None: # lgvx3200 fix if key > 5: e['group'] = 0 #self.log("Custom Groups in PB not supported - setting to No Group for "+e['name']) print "Custom Groups in PB not supported - setting to No Group for " + e[ 'name'] else: e['group'] = key else: # sorry no space for this category e['group'] = 0 # email addresses emails = helper.getemails(entry.get('emails', []), 0, self.protocolclass.NUMEMAILS, 48) e['emails'] = helper.filllist(emails, self.protocolclass.NUMEMAILS, "") # url e['url'] = helper.makeone( helper.geturls(entry.get('urls', []), 0, 1, 48), "") # memo (-1 is to leave space for null terminator - not all software puts it in, but we do) e['memo'] = helper.makeone( helper.getmemos(entry.get('memos', []), 0, 1, self.protocolclass.MEMOLENGTH - 1), "") # phone numbers # there must be at least one email address or phonenumber minnumbers = 1 if len(emails): minnumbers = 0 numbers = helper.getnumbers(entry.get('numbers', []), minnumbers, self.protocolclass.NUMPHONENUMBERS) e['numbertypes'] = [] e['numbers'] = [] for numindex in range(len(numbers)): num = numbers[numindex] # deal with type b4 = len(e['numbertypes']) type = num['type'] for i, t in enumerate(self.protocolclass.numbertypetab): if type == t: # some voodoo to ensure the second home becomes home2 if i in e['numbertypes'] and t[-1] != '2': type += '2' continue e['numbertypes'].append(i) break if t == 'none': # conveniently last entry e['numbertypes'].append(i) break if len(e['numbertypes']) == b4: # we couldn't find a type for the number continue # deal with number number = self.phonize(num['number']) if len(number) == 0: # no actual digits in the number continue if len(number ) > 48: # get this number from somewhere sensible # ::TODO:: number is too long and we have to either truncate it or ignore it? number = number[:48] # truncate for moment e['numbers'].append(number) # deal with speed dial sd = num.get("speeddial", -1) if self.protocolclass.NUMSPEEDDIALS: if sd >= self.protocolclass.FIRSTSPEEDDIAL and sd <= self.protocolclass.LASTSPEEDDIAL: speeds[sd] = (e['bitpimserial'], numindex) e['numbertypes'] = helper.filllist(e['numbertypes'], 5, 0) e['numbers'] = helper.filllist(e['numbers'], 5, "") # ringtones, wallpaper # LG VX3200 only supports writing the first 26 builtin ringers in pb ecring = helper.getringtone(entry.get('ringtones', []), 'call', None) if ecring is not None: if ecring not in Phone.builtinringtones: #self.log("Ringers past Carol 2 in PB not supported - setting to Default Ringer for "+e['name']) print "Ringers past Carol 2 in PB not supported - setting to Default Ringer for " + e[ 'name'] + " id was: " + ecring ecring = None e['ringtone'] = ecring emring = helper.getringtone(entry.get('ringtones', []), 'message', None) if emring is not None: if emring not in Phone.builtinringtones: #self.log("Ringers past Carol 2 in PB not supported - setting to Default MsgRinger for "+e['name']) print "Ringers past Carol 2 in PB not supported - setting to Default MsgRinger for " + e[ 'name'] + " id was: " + emring emring = None e['msgringtone'] = emring # LG VX3200 does not support writing wallpaper in pb ewall = helper.getwallpaper(entry.get('wallpapers', []), 'call', None) if ewall is not None: #self.log("Custom Wallpapers in PB not supported - setting to Default Wallpaper for "+e['name']) print "Custom Wallpapers in PB not supported - setting to Default Wallpaper for " + e[ 'name'] e['wallpaper'] = None # flags e['secret'] = helper.getflag(entry.get('flags', []), 'secret', False) results[pbentry] = e except helper.ConversionFailed: continue if self.protocolclass.NUMSPEEDDIALS: data['speeddials'] = speeds data['phonebook'] = results return data _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar # ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), # merge and overwrite wallpaper ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('call_history', 'read', None), ('memo', 'read', None), # all memo list reading DJP ('memo', 'write', 'OVERWRITE'), # all memo list writing DJP ('sms', 'read', None), ('sms', 'write', 'OVERWRITE'), ) WALLPAPER_WIDTH = 128 WALLPAPER_HEIGHT = 128 MAX_WALLPAPER_BASENAME_LENGTH = 19 WALLPAPER_FILENAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT = "bmp" MAX_RINGTONE_BASENAME_LENGTH = 19 RINGTONE_FILENAME_CHARS = "abcdefghijklmnopqrstuvxwyz0123456789 ." imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 128, 'height': 128, 'format': "BMP" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self)
def getringtones(self, result): result=com_lgvx4400.Phone.getringtones(self, result) if not conversions.helperavailable('pvconv'): return result media=result['ringtone'] _qcp_file=common.gettempfilename('qcp') _wav_file=common.gettempfilename('wav') try: vmemo_files=self.listfiles(self.VoiceMemoDir) keys=vmemo_files.keys() for k in keys: if k.endswith('.qcp'): key_name='VoiceMemo'+k[-8:-4] file(_qcp_file, 'wb').write(self.getfilecontents(k, True)) conversions.convertqcptowav(_qcp_file, _wav_file) media[key_name]=file(_wav_file, 'rb').read() except: if __debug__: raise try: os.remove(_qcp_file) os.remove(_wav_file) except: pass result['ringtone']=media return result def saveringtones(self, results, merge): _new_ringtones=results.get('ringtone', {}) _rt_index=results.get('ringtone-index', {}) _voice_memo_l=[x['name'] for k,x in _rt_index.items() \ if x.get('origin', '')=='voicememo'] _del_keys=[k for k,x in _new_ringtones.items() \ if x.get('name', None) in _voice_memo_l] for k in _del_keys: del _new_ringtones[k] results['ringtone']=_new_ringtones return com_lgvx4400.Phone.saveringtones(self, results, merge) def savephonebook(self, data): "Saves out the phonebook" res=com_lgvx4400.Phone.savephonebook(self, data) pbook=res.get('phonebook', {}) wallpaper_index=res.get('wallpaper-index', {}) r1={} for k,e in pbook.items(): r1[e['bitpimserial']['id']]={ 'wallpaper': \ self._findmediainindex(wallpaper_index, e['wallpaper'], e['name'], 'wallpaper'), 'group': e['group'] } serialupdates=data.get("serialupdates", []) r2={} for bps, serials in serialupdates: r2[serials['serial1']]=r1[bps['id']] if self._update_wallpaper_index(r2): data["rebootphone"]=True return res def _update_wallpaper_index(self, wpi): buf=prototypes.buffer(self.getfilecontents( self.protocolclass.pb_file_name)) pb=self.protocolclass.pbfile() pb.readfrombuffer(buf) update_flg=False for e in pb.items: _info=wpi.get(e.serial1, None) if _info: wp=_info.get('wallpaper', None) if wp is not None and wp!=e.wallpaper: update_flg=True e.wallpaper=wp gr=_info.get('group', None) if gr is not None and gr!=e.group: update_flg=True e.group=gr if update_flg: self.log('Updating wallpaper index') buf=prototypes.buffer() pb.writetobuffer(buf) self.writefile(self.protocolclass.pb_file_name, buf.getvalue()) return update_flg _call_history_info={ call_history.CallHistoryEntry.Folder_Incoming: protocolclass.incoming_call_file, call_history.CallHistoryEntry.Folder_Outgoing: protocolclass.outgoing_call_file, call_history.CallHistoryEntry.Folder_Missed: protocolclass.missed_call_file } def getcallhistory(self, result): res={} for _folder, _file_name in Phone._call_history_info.items(): try: buf=prototypes.buffer(self.getfilecontents(_file_name)) hist_file=self.protocolclass.callhistoryfile() hist_file.readfrombuffer(buf) for i in range(hist_file.itemcount): hist_call=hist_file.items[i] entry=call_history.CallHistoryEntry() entry.folder=_folder entry.datetime=hist_call.datetime entry.number=hist_call.number entry.name=hist_call.name if _folder!=call_history.CallHistoryEntry.Folder_Missed: entry.duration=hist_call.duration res[entry.id]=entry except com_brew.BrewNoSuchFileException: pass result['call_history']=res return result def _setquicktext(self, result): canned_file=Phone.SMSCannedFile() canned_file.set_sms_canned_data(result.get('canned_msg', [])) buf=prototypes.buffer() canned_file.writetobuffer(buf) self.writefile(self.protocolclass.sms_canned_file, buf.getvalue()) def _getquicktext(self): try: buf=prototypes.buffer(self.getfilecontents( self.protocolclass.sms_canned_file)) canned_file=Phone.SMSCannedFile() canned_file.readfrombuffer(buf) return canned_file.get_sms_canned_data() except: if __debug__: raise return [] my_model='VX4650' class SMSCannedFile (protocolclass.SMSCannedFile) : def __init__(self, *args, **kwargs): Phone.protocolclass.SMSCannedFile.__init__(self, *args, **kwargs) def get_sms_canned_data(self): return [{ 'text': e.text, 'type': sms.CannedMsgEntry.user_type } for e in self.items] def set_sms_canned_data(self, canned_list): msg_lst=[x['text'] for x in canned_list \ if x['type']==sms.CannedMsgEntry.user_type] item_count=min(Phone.protocolclass.SMS_CANNED_MAX_ITEMS, len(msg_lst)) for i in range(item_count): entry=Phone.protocolclass.SMSCannedMsg() entry.text=msg_lst[i] self.items.append(entry) entry=Phone.protocolclass.SMSCannedMsg() entry.text='' for i in range(item_count, Phone.protocolclass.SMS_CANNED_MAX_ITEMS): self.items.append(entry) def _get_phone_number(self): s='' try: buf=self.getfilecontents('nvm/nvm/nvm_0000') ofs=0x240 if buf[ofs]=='\x01': ofs+=1 while buf[ofs]!='\x01': s+=buf[ofs] ofs+=1 except: if __debug__: raise return s def getphoneinfo(self, phone_info): try: if self.getfilecontents(self.brew_version_file)[:len(self.my_model)]==self.my_model: phone_info.model=self.my_model phone_info.manufacturer=Profile.phone_manufacturer phone_info.phone_number=self._get_phone_number() phone_info.firmware_version=self.getfirmwareinformation().firmwareversion phone_info.esn=self.get_esn() except: if __debug__: raise "Talk to the LG VX4650 cell phone" parentprofile=com_lgvx4400.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname WALLPAPER_WIDTH=128 WALLPAPER_HEIGHT=128 MAX_WALLPAPER_BASENAME_LENGTH=19 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT="bmp" MAX_RINGTONE_BASENAME_LENGTH=19 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='VX4650' imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 128, 'height': 114, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 128, 'height': 128, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin): return self.imagetargets _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'), ('wallpaper', 'write', 'MERGE'), ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), ('ringtone', 'write', 'OVERWRITE'), ('memo', 'read', None), ('memo', 'write', 'OVERWRITE'), ('call_history', 'read', None), ('sms', 'read', None), ('sms', 'write', 'OVERWRITE'), ) def __init__(self): parentprofile.__init__(self) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 128, 'height': 114, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 128, 'height': 128, 'format': "JPEG"}))
def getmediaindex(self, builtins, maps, results, key): """Gets the media (wallpaper/ringtone) index @param builtins: the builtin list on the phone @param results: places results in this dict @param maps: the list of index files and locations @param key: key to place results in """ self.log("Reading "+key) media={} c=1 for name in builtins: media[c]={'name': name, 'origin': 'builtin' } c+=1 type=None for offset,indexfile,location,type,maxentries,const in maps: index=self.getindex(indexfile) for i in index: media[i+offset]={'name': index[i], 'origin': type} if key=='ringtone-index': type='ringers' else: type='images' index,_,_=self.get_content_file(key) for i in index: media[i]={'name': index[i], 'origin': type} results[key]=media return media def savemedia(self, mediakey, mediaindexkey, results, merge, reindexfunction): """Actually saves out the media @param mediakey: key of the media (eg 'wallpapers' or 'ringtones') @param mediaindexkey: index key (eg 'wallpaper-index') @param maps: list index files and locations @param results: results dict @param merge: are we merging or overwriting what is there? @param reindexfunction: the media is re-indexed at the end. this function is called to do it """ content_changed=False media=results[mediakey].copy() if mediaindexkey=='ringtone-index': type='ringers' content_type="Ringers" indexfile=self.protocolclass.ringerindex index_const=self.protocolclass.ringerconst max_media_entries=self.protocolclass.max_ringers for i in media.keys(): try: if media[i]['origin']=='voice_memo': del media[i] except: pass else: type='images' content_type="Screen Savers" indexfile=self.protocolclass.imageindex index_const=self.protocolclass.imageconst max_media_entries=self.protocolclass.max_images for i in media.keys(): try: if media[i]['origin']=='camera': del media[i] except: pass content={} try: buf=prototypes.buffer(self.getfilecontents(self.protocolclass.content_file_name)) g=self.protocolclass.content_file() g.readfrombuffer(buf) for i in g.items: if i.type=='!C': content[int(i.index1)]= {'C': i} elif i.type=='!E': content[int(i.index2)]['E']=i except (com_brew.BrewNoSuchFileException,com_brew.BrewBadPathnameException,com_brew.BrewNameTooLongException): pass dirlisting=self.getfilesystem(self.protocolclass.media_directory) for i in dirlisting.keys(): dirlisting[i[len(self.protocolclass.media_directory)+1:]]=dirlisting[i] del dirlisting[i] init={} for k in content.keys(): if content[k]['C'].content_type==content_type: index=k name=content[k]['C'].name1 size=int(content[k]['C'].size) data=None for w in media: if common.stripext(media[w]['name'])==name and media[w]['data']!=None: size_fix=((3024+len(media[w]['data']))/1008)*1008 if size_fix==size: data=media[w]['data'] del media[w] break if not merge and data is None: del content[k] content_changed=True _fname='%02d.dat' % k if _fname in dirlisting: self.rmfile(self.protocolclass.media_directory+'/'+_fname) del dirlisting[_fname] gcdname='%02d.gcd' % k if gcdname in dirlisting: self.rmfile(self.protocolclass.media_directory+'/'+gcdname) del dirlisting[gcdname] urlname='%02d.url' % k if urlname in dirlisting: self.rmfile(self.protocolclass.media_directory+'/'+urlname) del dirlisting[urlname] continue init[index]={'name': name, 'data': data} applications={} for sp in range(100): if len(media.keys()) == 0: break if sp not in content: for w in media.keys(): C,E,add_to_index=self.make_new_media_entry(media[w], sp, type) if add_to_index=='index': content[sp]= {'C': C, 'E': E} init[sp]=media[w] content_changed=True elif add_to_index=='content': content[sp]= {'C': C, 'E': E} applications[sp]=media[w] content_changed=True else: self.log("Unknown media type for "+`media[w]['name']`+". Not written to phone.") sp-=1 del media[w] break if len(media.keys()): self.log("Phone index full, some media not written to phone") content_count=0 keys=content.keys() keys.sort() cfile=self.protocolclass.content_file() for k in keys: content_count+=1 cfile.items.append(content[k]['C']) for k in keys: cfile.items.append(content[k]['E']) entry=self.protocolclass.content_entry() entry.type='!F' cfile.items.append(entry) buffer=prototypes.buffer() cfile.writetobuffer(buffer) self.logdata("Updated content file "+self.protocolclass.content_file_name, buffer.getvalue(), cfile) self.writefile(self.protocolclass.content_file_name, buffer.getvalue()) countfile=self.protocolclass.content_count() countfile.count=`content_count` buffer=prototypes.buffer() countfile.writetobuffer(buffer) self.logdata("Updated content count file "+self.protocolclass.content_count_file_name, buffer.getvalue(), countfile) self.writefile(self.protocolclass.content_count_file_name, buffer.getvalue()) keys=init.keys() keys.sort() ifile=self.protocolclass.indexfile() ifile.numactiveitems=len(keys) for k in keys: entry=self.protocolclass.indexentry() entry.index=k entry.const=index_const entry.name='%02d.dat' % k ifile.items.append(entry) for k in range(max_media_entries): if k in keys: continue entry=self.protocolclass.indexentry() entry.index=k entry.const=index_const ifile.items.append(entry) buffer=prototypes.buffer() ifile.writetobuffer(buffer) self.logdata("Updated index file "+indexfile, buffer.getvalue(), ifile) self.writefile(indexfile, buffer.getvalue()) for k in keys: entry=init[k] data=entry.get("data", None) _fname='%02d.dat' % k gcdname='%02d.gcd' % k urlname='%02d.url' % k if data is None: if _fname not in dirlisting: self.log("Index error. I have no data for "+entry['name']+" and it isn't already in the filesystem") continue contentsize=len(data) urlcontents='file://'+entry['name'] gcdcontents=self.makegcd(entry['name'],contentsize) if _fname in dirlisting and len(data)==dirlisting[_fname]['size']: self.log("Skipping writing %s/%s as there is already a file of the same length" % (self.protocolclass.media_directory,entry['name'])) if gcdname not in dirlisting: self.writefile(self.protocolclass.media_directory+"/"+gcdname, gcdcontents) if urlname not in dirlisting: self.writefile(self.protocolclass.media_directory+"/"+urlname, urlcontents) continue self.writefile(self.protocolclass.media_directory+"/"+_fname, data) self.writefile(self.protocolclass.media_directory+"/"+gcdname, gcdcontents) self.writefile(self.protocolclass.media_directory+"/"+urlname, urlcontents) for k in applications.keys(): entry=applications[k] data=entry.get("data", None) _fname='%02d.jar' % k jadname='%02d.jad' % k urlname='%02d.url' % k if data is None: if _fname not in dirlisting: self.log("Index error. I have no data for "+entry['name']+" and it isn't already in the filesystem") print "here2" continue contentsize=len(data) urlcontents='file://'+entry['name'] jadcontents=self.makejad(entry['name'],contentsize) print "here3" if _fname in dirlisting and len(data)==dirlisting[_fname]['size']: self.log("Skipping writing %s/%s as there is already a file of the same length" % (self.protocolclass.media_directory,entry['name'])) if jadname not in dirlisting: self.writefile(self.protocolclass.media_directory+"/"+jadname, jadcontents) if urlname not in dirlisting: self.writefile(self.protocolclass.media_directory+"/"+urlname, urlcontents) print "here4" continue print "here5" self.writefile(self.protocolclass.media_directory+"/"+_fname, data) self.writefile(self.protocolclass.media_directory+"/"+jadname, jadcontents) self.writefile(self.protocolclass.media_directory+"/"+urlname, urlcontents) del results[mediakey] reindexfunction(results) if content_changed: results["rebootphone"]=True return results def make_new_media_entry(self, entry, index, type): c=self.protocolclass.content_entry() e=self.protocolclass.content_entry() name=common.stripext(entry['name']) ext=common.getext(entry['name']) data=entry.get("data", None) add_to_index='index' c.type='!C' c.index1=index c.name1=name try: c.mime_type=self.__mimetype[ext] except: add_to_index='none' return c, e, add_to_index if c.mime_type=='application/java-archive': c.content_type='Games' e.location_maybe='midlet:'+name add_to_index='content' elif type=='ringers': c.content_type='Ringers' else: c.content_type='Screen Savers' c.size=`((3024+len(data))/1008)*1008` e.type='!E' e.index2=index e.name2=name return c, e, add_to_index def makegcd(self,filename,size): "Build a GCD file for filename" ext=common.getext(filename.lower()) noextname=common.stripext(filename) try: mimetype=self.__mimetype[ext] gcdcontent="Content-Type: "+mimetype+"\nContent-Name: "+noextname+"\nContent-Version: 1.0\nContent-Vendor: BitPim\nContent-URL: file://"+filename+"\nContent-Size: "+`size`+"\nContent-Description: Content for V10044 LG PM225"+"\n\n\n" except: gcdcontent="Content-Name: "+noextname+"\nContent-Version: 1.0\nContent-Vendor: BitPim\nContent-URL: file://"+filename+"\nContent-Size: "+`size`+"\n\n\n" return gcdcontent def makejad(self,filename,size): "Build a JAD file for filename" ext=common.getext(filename.lower()) noextname=common.stripext(filename) jadcontent="MIDlet-1: "+noextname+", "+noextname+".png, BitPim\nMIDlet-Jar-Size: "+`size`+"\nMIDlet-Jar-URL: "+filename+"\nMIDlet-Name: "+noextname+"\nMIDlet-Vendor: Unknown\nMIDlet-Version: 1.0\nMicroEdition-Configuration: CLDC-1.0\nMicroEdition-Profile: MIDP-1.0\nContent-Folder: Games\n\n\n" return jadcontent brew_version_file='ams/version.txt' brew_version_txt_key='ams_version.txt' my_model='PM225' def getphoneinfo(self, phone_info): self.log('Getting Phone Info') try: s=self.getfilecontents('ams/version.txt') if s[:5]==self.my_model: phone_info.append('Model:', self.my_model) phone_info.append('ESN:', self.get_brew_esn()) req=p_brew.firmwarerequest() txt=self.getfilecontents("nvm/nvm/nvm_0000")[207:217] phone_info.append('Phone Number:', txt) except: pass return "Talk to the LG PM225 cell phone" parentprofile=com_lgvx4400.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='PM225' brew_required=True RINGTONE_LIMITS= { 'MAXSIZE': 250000 } WALLPAPER_WIDTH=160 WALLPAPER_HEIGHT=120 MAX_WALLPAPER_BASENAME_LENGTH=30 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .-_" WALLPAPER_CONVERT_FORMAT="jpg" MAX_RINGTONE_BASENAME_LENGTH=30 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .-_" DIALSTRING_CHARS="[^0-9PT#*]" imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 160, 'height': 120, 'format': "JPEG"})) autodetect_delay=3 def convertphonebooktophone(self, helper, data): """Converts the data to what will be used by the phone @param data: contains the dict returned by getfundamentals as well as where the results go""" results={} speeds={} for pbentry in data['phonebook']: if len(results)==self.protocolclass.NUMPHONEBOOKENTRIES: break e={} entry=data['phonebook'][pbentry] try: serial1=helper.getserial(entry.get('serials', []), self.serialsname, data['uniqueserial'], 'serial1', 0xFFFFFFFF) e['serial1']=serial1 for ss in entry["serials"]: if ss["sourcetype"]=="bitpim": e['bitpimserial']=ss assert e['bitpimserial'] e['name']=helper.getfullname(entry.get('names', []),1,1,32)[0] cat=helper.makeone(helper.getcategory(entry.get('categories', []),0,1,32), None) if cat is None: e['group']=0 else: key,value=self._getgroup(cat, data['groups']) if key is not None: e['group']=key else: e['group']=0 emails=helper.getemails(entry.get('emails', []) ,0,self.protocolclass.NUMEMAILS,72) e['emails']=helper.filllist(emails, self.protocolclass.NUMEMAILS, "") e['url']=helper.makeone(helper.geturls(entry.get('urls', []), 0,1,74), "") e['memo']=helper.makeone(helper.getmemos(entry.get('memos', []), 0, 1, self.protocolclass.MEMOLENGTH-1), "") minnumbers=1 if len(emails): minnumbers=0 numbers=helper.getnumbers(entry.get('numbers', []),minnumbers,self.protocolclass.NUMPHONENUMBERS) e['numberspeeds']=[] e['numbertypes']=[] e['numbers']=[] for numindex in range(len(numbers)): num=numbers[numindex] b4=len(e['numbertypes']) type=num['type'] for i,t in enumerate(self.protocolclass.numbertypetab): if type==t: e['numbertypes'].append(i) break if t=='none': e['numbertypes'].append(i) break if len(e['numbertypes'])==b4: helper.add_error_message("%s has number %s if of type %s not supported by phone" % (e['name'], num['number'], num['type'])) continue number=self.phonize(num['number']) if len(number)==0: continue if len(number)>48: number=number[:48] e['numbers'].append(number) sd=num.get("speeddial", 0xFF) if sd>=self.protocolclass.FIRSTSPEEDDIAL and sd<=self.protocolclass.LASTSPEEDDIAL: e['numberspeeds'].append(sd) else: e['numberspeeds'].append(0xFF) e['numberspeeds']=helper.filllist(e['numberspeeds'], 5, 0xFF) e['numbertypes']=helper.filllist(e['numbertypes'], 5, 0) e['numbers']=helper.filllist(e['numbers'], 5, "") e['ringtone']=helper.getringtone(entry.get('ringtones', []), 'call', None) e['wallpaper']=helper.getwallpaper(entry.get('wallpapers', []), 'call', None) e['secret']=helper.getflag(entry.get('flags',[]), 'secret', False) results[pbentry]=e except helper.ConversionFailed: continue data['phonebook']=results return data _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('call_history', 'read', None), ('memo', 'read', None), ('sms', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'), ('wallpaper', 'write', 'MERGE'), ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), ('ringtone', 'write', 'OVERWRITE'), ('memo', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), ) def QueryAudio(self, origin, currentextension, afi): if afi.format in ("MIDI", "QCP"): return currentextension, afi if afi.format=="MP3": if afi.channels==1 and 8<=afi.bitrate<=128 and 16000<=afi.samplerate<=44100: return currentextension, afi return ("mp3", fileinfo.AudioFileInfo(afi, **{'format': 'MP3', 'channels': 1, 'bitrate': 32, 'samplerate': 22050})) field_color_data={ 'phonebook': { 'name': { 'first': 0, 'middle': 0, 'last': 0, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 }, 'email': 3, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 1, 'memo': 1, 'category': 1, 'wallpaper': 1, 'ringtone': 1, 'storage': 0, }, 'calendar': { 'description': True, 'location': False, 'allday': True, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': False, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': True, 'date': False, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, } imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 160, 'height': 120, 'format': "JPEG"}))
def _get_phone_number(self): s='' try: buf=self.getfilecontents('nvm/nvm/nvm_0000') ofs=0x240 if buf[ofs]=='\x01': ofs+=1 while buf[ofs]!='\x01': s+=buf[ofs] ofs+=1 except: if __debug__: raise return s def getphoneinfo(self, phone_info): try: if self.getfilecontents(self.brew_version_file)[:len(self.my_model)]==self.my_model: phone_info.model=self.my_model phone_info.manufacturer=Profile.phone_manufacturer phone_info.phone_number=self._get_phone_number() phone_info.firmware_version=self.getfirmwareinformation().firmwareversion phone_info.esn=self.get_esn() except: if __debug__: raise "Talk to the LG VX4650 cell phone" parentprofile=com_lgvx4400.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname WALLPAPER_WIDTH=128 WALLPAPER_HEIGHT=128 MAX_WALLPAPER_BASENAME_LENGTH=19 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT="bmp" MAX_RINGTONE_BASENAME_LENGTH=19 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='VX4650' imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 128, 'height': 114, 'format': "JPEG"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 128, 'height': 128, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin):
def __init__(self): parentprofile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('call_history', 'read', None), ('sms', 'read', None), ('memo', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'), ('wallpaper', 'write', 'MERGE'), ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), ('memo', 'write', 'OVERWRITE'), ) field_color_data={ 'phonebook': { 'name': { 'first': 1, 'middle': 1, 'last': 1, 'full': 1, 'nickname': 0, 'details': 1 }, 'number': { 'type': 5, 'speeddial': 5, 'number': 5, 'details': 5 }, 'email': 2, 'address': { 'type': 0, 'company': 0, 'street': 0, 'street2': 0, 'city': 0, 'state': 0, 'postalcode': 0, 'country': 0, 'details': 0 }, 'url': 0, 'memo': 1, 'category': 1, 'wallpaper': 1, 'ringtone': 2, 'storage': 0, }, 'calendar': { 'description': True, 'location': True, 'allday': True, 'start': True, 'end': True, 'priority': False, 'alarm': True, 'vibrate': True, 'repeat': True, 'memo': False, 'category': False, 'wallpaper': False, 'ringtone': True, }, 'memo': { 'subject': True, 'date': True, 'secret': False, 'category': False, 'memo': True, }, 'todo': { 'summary': False, 'status': False, 'due_date': False, 'percent_complete': False, 'completion_date': False, 'private': False, 'priority': False, 'category': False, 'memo': False, }, } imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 320, 'height': 240, 'format': "JPEG"}))
WALLPAPER_WIDTH=275 WALLPAPER_HEIGHT=175 MAX_WALLPAPER_BASENAME_LENGTH=32 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT="jpg" DIALSTRING_CHARS="[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH=32 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 275, 'height': 175, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('call_history', 'read', None), ('sms', 'read', None),
class Profile(object): BP_Calendar_Version = 2 WALLPAPER_WIDTH = 100 WALLPAPER_HEIGHT = 100 MAX_WALLPAPER_BASENAME_LENGTH = 64 WALLPAPER_FILENAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT = "bmp" MAX_RINGTONE_BASENAME_LENGTH = 64 RINGTONE_FILENAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789 ." DIALSTRING_CHARS = "[^0-9PT#*]" field_color_data = field_color.default_field_info # delay auto-detection when the phone is plugged in (in seconds) autodetect_delay = 0 # delay in rebooting the phone after a send data and delay between offline and reboot in seconds. reboot_delay = 0 # which usb ids correspond to us usbids = () # which device classes we are. deviceclasses = ("modem", "serial") def __init__(self): pass _supportedsyncs = () def SyncQuery(self, source, action, actiontype): if actiontype == 'EXCLUSIVE': # Check for exclusive, shoud not be masked by None return (source, action, actiontype) in self._supportedsyncs else: return (source, action, actiontype) in self._supportedsyncs or \ (source, action, None) in self._supportedsyncs # fill in the list of ringtone/sound origins on your phone ringtoneorigins = () #e.g. #ringtoneorigins=('ringers', 'sounds') # ringtone origins that are not available for the contact assignment excluded_ringtone_origins = () # wallpaper origins that are not available for the contact assignment excluded_wallpaper_origins = ('video', ) # fill in your own image origins using these stockimageorigins = { "images": { 'meta-help': 'General images' }, "mms": { 'meta-help': 'Multimedia Messages' }, "drm": { 'meta-help': 'DRM protected images' }, "camera": { 'meta-help': 'Camera images' }, "camera-fullsize": { 'meta-help': 'Fullsize camera images' }, "video": { 'meta-help': 'Video clips' }, "images(sd)": { 'meta-help': 'General images stored on removable media' }, "video(sd)": { 'meta-help': 'Video clips stored on removable media' }, "picture ids": { 'meta-help': 'Images used for contact/group Picture ID' }, } stockimagetargets = { # You need to override in your GetTargetsForImageOrigin function and update # for ImgFileInfo fields "wallpaper": { 'meta-help': 'Display as wallpaper' }, "pictureid": { 'meta-help': 'Display as picture id for a caller' }, "outsidelcd": { 'meta-help': 'Display on outside screen' }, "fullscreen": { 'meta-help': 'Fullscreen such as startup screen' }, } # Override in derived class - use this template. Avoid defining new origins - # instead add them to the stock list and use that. That will ensure the # same string and description are used for all phones. imageorigins = {} imageorigins.update(common.getkv(stockimageorigins, "images")) imageorigins.update(common.getkv(stockimageorigins, "mms")) imageorigins.update(common.getkv(stockimageorigins, "camera")) imageorigins["<developerneedstoupdate>"] = { 'meta-help': "The developer needs to update this phone profile" } def GetImageOrigins(self): # Note: only return origins that you can write back to the phone return self.imageorigins def GetTargetsForImageOrigin(self, origin): if False: # this is how you should do it in your derived class. The update dictionary # fields must correspond to what fileinfo.ImgFileInfo uses. The information # is used to save the new file out. targets = {} targets.update( common.getkv(self.stockimagetargets, "wallpaper", { 'width': 77, 'height': 177, 'format': "BMP" })) targets.update( common.getkv(self.stockimagetargets, "outsidelcd", { 'width': 77, 'height': 77, 'format': "JPEG" })) return targets # this code is here to work with the old way we used to do things convert_format_map = {'bmp': 'BMP', 'jpg': 'JPEG', 'png': 'PNG'} return common.getkv( self.stockimagetargets, "wallpaper", { 'width': self.WALLPAPER_WIDTH, 'height': self.WALLPAPER_HEIGHT, 'format': convert_format_map[self.WALLPAPER_CONVERT_FORMAT] }) def QueryAudio(self, origin, currentextension, audiofileinfo): """Query for MP3 file support Raise an exception if you cannot support the ringtone or any conversion of it. @param audiofileinfo: A L{fileinfo.AudioFileInfo} object specifying file's audio properties @param currentextension: The extension currently used by the file @return: ("file extension", audiofile object). The file extension (excluding the leading dot) to make the file use. The audiofile object can be what was passed in unaltered meaning the file is fine as is, or make a new one to specify how the file should be converted. Note there is a MAXSIZE attribute if you need to limit file size. """ # default implementation leaves file unaltered return (currentextension, audiofileinfo) def phonize(self, str): """Convert the phone number into something the phone understands uses DIALSTRING_CHARS to compare phone number with and strips all other characters from the string """ return re.sub(self.DIALSTRING_CHARS, "", str)
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname BP_Calendar_Version = 3 phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX5200' WALLPAPER_WIDTH = 275 WALLPAPER_HEIGHT = 175 MAX_WALLPAPER_BASENAME_LENGTH = 32 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ." WALLPAPER_CONVERT_FORMAT = "jpg" # the 5200 uses "W" for wait in the dialstring, it does not support "T" DIALSTRING_CHARS = "[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH = 32 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_() ." # the 5200 doesn't have seperate origins - they are all dumped in "images" imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins ringtoneorigins = ('ringers', 'sounds') excluded_ringtone_origins = ('sounds') # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 275, 'height': 175, 'format': "JPEG" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets def __init__(self): parentprofile.__init__(self) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing )
def _write_index_file(self, type): _info=self.media_info.get(type, None) if not _info: return _files={} _local_dir=_info['localpath'] _rs_dir=_info['rspath'] _vtype=_info['vtype'] _icon=_info['icon'] _index=_info['index'] _maxsize=_info['maxsize'] _dunno=_info['dunno'] indexfile=_info['indexfile'] sizefile=_info['sizefile'] _need_date=_info['date'] try: _files=self.listfiles(_local_dir) except (com_brew.BrewNoSuchDirectoryException, com_brew.BrewBadPathnameException): pass try: if _rs_dir: _files.update(self.listfiles(_rs_dir)) except (com_brew.BrewNoSuchDirectoryException, com_brew.BrewBadPathnameException): pass _idx_keys={} for _i in xrange(_index, _index+_maxsize): _idx_keys[_i]=True for _item in self.getindex(indexfile): if _files.has_key(_item.filename): _files[_item.filename]['index']=_item.index _idx_keys[_item.index]=False _idx_keys_list=[k for k,x in _idx_keys.items() if x] _idx_keys_list.sort() _idx_cnt=0 _file_list=[x for x in _files if not _files[x].get('index', None)] _file_list.sort() if len(_file_list)>len(_idx_keys_list): _file_list=_file_list[:len(_idx_keys_list)] for i in _file_list: _files[i]['index']=_idx_keys_list[_idx_cnt] _idx_cnt+=1 _res_list=[(x['index'],k) for k,x in _files.items() if x.get('index', None)] _res_list.sort() _res_list.reverse() ifile=self.protocolclass.indexfile() _file_size=0 for index,idx in _res_list: _fs_size=_files[idx]['size'] ie=self.protocolclass.indexentry() ie.index=index ie.type=_vtype ie.filename=idx if _need_date: _stat=self.statfile(_files[idx]['name']) if _stat: ie.date=_stat['datevalue']-time.timezone ie.dunno=_dunno ie.icon=_icon ie.size=_fs_size ifile.items.append(ie) if not self._is_rs_file(idx): _file_size+=_fs_size buf=prototypes.buffer() ifile.writetobuffer(buf) self.logdata("Index file "+indexfile, buf.getvalue(), ifile) self.log("Writing index file "+indexfile+" for type "+type+" with "+`len(_res_list)`+" entries.") self.writefile(indexfile, buf.getvalue()) if sizefile: szfile=self.protocolclass.sizefile() szfile.size=_file_size buf=prototypes.buffer() szfile.writetobuffer(buf) self.log("You are using a total of "+`_file_size`+" bytes for "+type) self.writefile(sizefile, buf.getvalue()) def savemedia(self, mediakey, mediaindexkey, maps, results, merge, reindexfunction): """Actually saves out the media @param mediakey: key of the media (eg 'wallpapers' or 'ringtones') @param mediaindexkey: index key (eg 'wallpaper-index') @param maps: list index files and locations @param results: results dict @param merge: are we merging or overwriting what is there? @param reindexfunction: the media is re-indexed at the end. this function is called to do it """ wp=results[mediakey].copy() wpi=results[mediaindexkey].copy() for k in wpi.keys(): if wpi[k].get('origin', "")=='builtin': del wpi[k] init={} for type,_,_,_,lowestindex,_,typemajor,_,_ in maps: init[type]={} for k in wpi.keys(): if wpi[k]['origin']==type: index=k name=wpi[k]['name'] fullname=wpi[k]['filename'] vtype=wpi[k]['vtype'] icon=wpi[k]['icon'] data=None del wpi[k] for w in wp.keys(): if wp[w]['name']==name: data=wp[w]['data'] del wp[w] if not merge and data is None: continue init[type][index]={'name': name, 'data': data, 'filename': fullname, 'vtype': vtype, 'icon': icon} assert len(wpi)==0 print init.keys() for w in wp.keys(): o=wp[w].get("origin", "") if o is not None and len(o) and o in init: idx=-1 while idx in init[o]: idx-=1 init[o][idx]=wp[w] del wp[w] for type,_,_,_,lowestindex,maxentries,typemajor,def_icon,_ in maps: for w in wp.keys(): if len(init[type])>=maxentries: break idx=-1 while idx in init[type]: idx-=1 init[type][idx]=wp[w] del wp[w] for type, indexfile, sizefile, directory, lowestindex, maxentries,typemajor,def_icon,_ in maps: names=[init[type][x]['name'] for x in init[type]] for item in self.getindex(indexfile): if common.basename(item.filename) not in names and \ not self._is_rs_file(item.filename): self.log(item.filename+" is being deleted") self.rmfile(item.filename) fixups=[k for k in init[type].keys() if k<lowestindex] fixups.sort() for f in fixups: for ii in xrange(lowestindex, lowestindex+maxentries): if ii not in init[type]: init[type][ii]=init[type][f] del init[type][f] break fixups=[k for k in init[type].keys() if k<lowestindex] for f in fixups: self.log("There is no space in the index for "+type+" for "+init[type][f]['name']) del init[type][f] for idx in init[type].keys(): entry=init[type][idx] filename=entry.get('filename', directory+"/"+entry['name']) entry['filename']=filename fstat=self.statfile(filename) if 'data' not in entry: if fstat is None: self.log("Entry "+entry['name']+" is in index "+indexfile+" but there is no data for it and it isn't in the filesystem. The index entry will be removed.") del init[type][idx] continue data=entry['data'] if data is None: assert merge continue elif not data: self.log('Not writing file: '+filename) continue if fstat is not None and len(data)==fstat['size']: self.log("Not writing "+filename+" as a file of the same name and length already exists.") else: self.writefile(filename, data) self._write_index_file(type) return reindexfunction(results) "Talk to the LG VX8100 cell phone" parentprofile=com_lgvx7000.Profile class Profile (parentprofile) : protocolclass=Phone.protocolclass serialsname=Phone.serialsname BP_Calendar_Version=3 phone_manufacturer='LG Electronics Inc' phone_model='VX8100' WALLPAPER_WIDTH=160 WALLPAPER_HEIGHT=120 MAX_WALLPAPER_BASENAME_LENGTH=32 WALLPAPER_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" WALLPAPER_CONVERT_FORMAT="jpg" DIALSTRING_CHARS="[^0-9PW#*]" MAX_RINGTONE_BASENAME_LENGTH=32 RINGTONE_FILENAME_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_ .-" bluetooth_mfg_id="001256" imageorigins={} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) def GetImageOrigins(self): return self.imageorigins imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 320, 'height': 240, 'format': "JPEG"})) def GetTargetsForImageOrigin(self, origin):
class Profile(parentprofile): BP_Calendar_Version = 3 protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_model = Phone.my_model phone_manufacturer = 'LG Electronics Inc' # inside screen resoluation WALLPAPER_WIDTH = 320 WALLPAPER_HEIGHT = 240 imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) imageorigins.update(common.getkv(parentprofile.stockimageorigins, "video")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "images(sd)")) imageorigins.update( common.getkv(parentprofile.stockimageorigins, "video(sd)")) # our targets are the same for all origins imagetargets = {} imagetargets.update( common.getkv(parentprofile.stockimagetargets, "outsidelcd", { 'width': 190, 'height': 96, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "wallpaper", { 'width': 320, 'height': 240, 'format': "JPEG" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 320, 'height': 240, 'format': "JPEG" })) _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('call_history', 'read', None), # all call history list reading ('sms', 'read', None), # all SMS list reading ('memo', 'read', None), # all memo list reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ('sms', 'write', 'OVERWRITE'), # all SMS list writing ('memo', 'write', 'OVERWRITE'), # all memo list writing ## ('playlist', 'read', 'OVERWRITE'), ## ('playlist', 'write', 'OVERWRITE'), ('t9_udb', 'write', 'OVERWRITE'), ) if __debug__: _supportedsyncs += (('t9_udb', 'read', 'OVERWRITE'), )
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 ." 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 imagetargets={} imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", {'width': 120, 'height': 131, 'format': "BMP"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "pictureid", {'width': 120, 'height': 131, 'format': "BMP"})) imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", {'width': 120, 'height': 160, 'format': "BMP"})) def GetTargetsForImageOrigin(self, origin): return self.imagetargets _supportedsyncs=( ('phonebook', 'read', None), ('calendar', 'read', None), ('wallpaper', 'read', None), ('ringtone', 'read', None), ('phonebook', 'write', 'OVERWRITE'), ('calendar', 'write', 'OVERWRITE'),
class Profile(parentprofile): protocolclass = Phone.protocolclass serialsname = Phone.serialsname phone_manufacturer = 'LG Electronics Inc' phone_model = 'VX4600' WALLPAPER_WIDTH = 120 WALLPAPER_HEIGHT = 131 MAX_WALLPAPER_BASENAME_LENGTH = 19 WALLPAPER_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." WALLPAPER_CONVERT_FORMAT = "bmp" MAX_RINGTONE_BASENAME_LENGTH = 19 RINGTONE_FILENAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ." imageorigins = {} imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images")) 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" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "pictureid", { 'width': 120, 'height': 131, 'format': "BMP" })) imagetargets.update( common.getkv(parentprofile.stockimagetargets, "fullscreen", { 'width': 120, 'height': 160, 'format': "BMP" })) def GetTargetsForImageOrigin(self, origin): return self.imagetargets _supportedsyncs = ( ('phonebook', 'read', None), # all phonebook reading ('calendar', 'read', None), # all calendar reading ('wallpaper', 'read', None), # all wallpaper reading ('ringtone', 'read', None), # all ringtone reading ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook # ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar ('wallpaper', 'write', 'MERGE'), # merge and overwrite wallpaper ('wallpaper', 'write', 'OVERWRITE'), ('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone ('ringtone', 'write', 'OVERWRITE'), ) def __init__(self): parentprofile.__init__(self)