0001 ### BITPIM 0002 ### 0003 ### Copyright (C) 2005 Yosef Meller <mellerf@netvision.net.il> 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_sk6100.py 3092 2006-04-13 03:13:47Z skyjunky $ 0009 0010 import com_phone 0011 import com_brew 0012 import prototypes 0013 import p_sk6100 0014 0015 class Phone(com_phone.Phone, com_brew.BrewProtocol): 0016 """Talk to SK Music Slider""" 0017 0018 desc="SK Music Slider" 0019 protocolclass=p_sk6100 0020 serialsname='sk6100' 0021 0022 # This is ordered by the type id nums the phone uses: 0023 phonetypes = [ 'cell', 'home', 'office', 'fax', 'pager' ] 0024 0025 def __init__(self, logtarget, commport): 0026 com_phone.Phone.__init__(self, logtarget, commport) 0027 com_brew.BrewProtocol.__init__(self) 0028 0029 def getfundamentals(self, results): 0030 grbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/group.pbk')) 0031 groups = self.protocolclass.groups() 0032 groups.readfrombuffer(grbuf, logtitle="Groups read") 0033 0034 # decode caharachters to unicode - should use some global setting, 0035 # hard-coding is bad for you :-) 0036 grsort = [group for group in groups.pbgroups if group.name != ''] 0037 0038 results['groups'] = grsort 0039 return results 0040 0041 def getphonebook(self, results): 0042 0043 # Get a list of phone numbers: 0044 phonebuf = prototypes.buffer(self.getfilecontents('SKY/PBK/number.pbk')) 0045 phones = self.protocolclass.phones() 0046 phones.readfrombuffer(phonebuf, logtitle="Phonenumbers") 0047 0048 # Drop empty phone records, listify: 0049 phones = [phone for phone in phones.records if phone.owner_id] 0050 0051 # Retrieve people names and groups 0052 pbook={} 0053 bookbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/book.pbk')) 0054 entries = self.protocolclass.wholebook() 0055 entries.readfrombuffer(bookbuf, logtitle="Names read") 0056 0057 for entry in entries.pbentries: 0058 # Ignore deleted records 0059 if not entry.record: 0060 continue 0061 0062 # Find group name: 0063 group_name = "Group not recognised" 0064 for group in results['groups']: 0065 if group.group_id == entry.group_id: 0066 group_name = group.name 0067 break 0068 0069 pbook[entry.slot] = { 0070 'names': [{'title': '', 'first': '', 0071 'last': '', 'full': entry.name, 'nickname': ''}], 0072 'categories': [{'category': group_name}], 0073 'numbers': [{'number': phone.number, 0074 'type': self.phonetypes[phone.type - 1]} 0075 for phone in phones 0076 if phone.owner_id == entry.slot], 0077 'serials': [{'sourcetype': self.serialsname}] 0078 } 0079 0080 results['phonebook'] = pbook 0081 results['categories'] = [group.name for group in results['groups']] 0082 return pbook 0083 0084 def getcalendar(self, results): 0085 pass 0086 0087 def getwallpapers(self, results): 0088 pass 0089 0090 def getringtones(self, results): 0091 pass 0092 0093 class Profile(com_phone.Profile): 0094 deviceclasses=("modem",) 0095 0096 _supportedsyncs=( 0097 ('phonebook', 'read', None), # all phonebook reading 0098 ) 0099 0100
Generated by PyXR 0.9.4