0001 ### BITPIM 0002 ### 0003 ### Copyright (C) 2005 Stephen Wood <saw@bitpim.org> 0004 ### 0005 ### This program is free software; you can redistribute it and/or modify 0006 ### it under the terms of the BitPim license as detailed in the LICENSE file. 0007 ### 0008 ### $Id: com_samsungspha460.py 3918 2007-01-19 05:15:12Z djpham $ 0009 0010 """Communicate with a Samsung SPH-A460""" 0011 0012 import sha 0013 import re 0014 import struct 0015 0016 import common 0017 import commport 0018 import p_samsungspha460 0019 import p_brew 0020 import com_brew 0021 import com_phone 0022 import com_samsung_packet 0023 import prototypes 0024 import helpids 0025 0026 numbertypetab=('home','office','cell','pager','fax','none') 0027 0028 class Phone(com_samsung_packet.Phone): 0029 "Talk to a Samsung SPH-A460 phone" 0030 0031 desc="SPH-A460" 0032 helpid=helpids.ID_PHONE_SAMSUNGOTHERS 0033 protocolclass=p_samsungspha460 0034 serialsname='spha460' 0035 __groups_range=xrange(5) 0036 0037 imagelocations=() 0038 # offset, index file, files location, type, maximumentries 0039 0040 __ams_index_file="ams/AmsRegistry" 0041 0042 def __init__(self, logtarget, commport): 0043 com_samsung_packet.Phone.__init__(self, logtarget, commport) 0044 self.numbertypetab=numbertypetab 0045 self.mode=self.MODENONE 0046 0047 def getfundamentals(self, results): 0048 """Gets information fundamental to interopating with the phone and UI.""" 0049 0050 # use a hash of ESN and other stuff (being paranoid) 0051 self.log("Retrieving fundamental phone information") 0052 self.log("Phone serial number") 0053 print "Calling setmode MODEMODEM" 0054 self.setmode(self.MODEMODEM) 0055 print "Getting serial number" 0056 results['uniqueserial']=sha.new(self.get_esn()).hexdigest() 0057 0058 self.log("Reading group information") 0059 print "Getting Groups" 0060 results['groups']=self.read_groups() 0061 print "Got Groups" 0062 0063 self.log("Fundamentals retrieved") 0064 return results 0065 0066 def savegroups(self, data): 0067 """Write the groups, sending only those groups that have had 0068 a name change. (So that ringers don't get messed up)""" 0069 groups=data['groups'] 0070 0071 groups_onphone=self.read_groups() # Get groups on phone 0072 0073 keys=groups.keys() 0074 keys.sort() 0075 0076 for k in keys: 0077 if groups[k]['name']!=groups_onphone[k]['name']: 0078 if groups[k]['name']!="Unassigned": 0079 req=self.protocolclass.groupnamesetrequest() 0080 req.gid=k 0081 req.groupname=groups[k]['name'] 0082 # Response will have ERROR, even though it works 0083 self.sendpbcommand(req, self.protocolclass.unparsedresponse, ignoreerror=True) 0084 0085 getwallpapers=None 0086 getringtones=None 0087 0088 class Profile(com_samsung_packet.Profile): 0089 protocolclass=Phone.protocolclass 0090 serialsname=Phone.serialsname 0091 phone_manufacturer='SAMSUNG' 0092 phone_model='SPH-A460/148' 0093 0094 def __init__(self): 0095 com_samsung_packet.Profile.__init__(self) 0096 self.numbertypetab=numbertypetab 0097 0098 _supportedsyncs=( 0099 ('phonebook', 'read', None), # all phonebook reading 0100 ('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook 0101 ('calendar', 'read', None), # all calendar reading 0102 ('calendar', 'write', 'OVERWRITE'), # only overwriting calendar 0103 ('todo', 'read', None), # all todo list reading 0104 ('todo', 'write', 'OVERWRITE'), # only overwriting calendar 0105 ) 0106 0107
Generated by PyXR 0.9.4