Package phones :: Module com_sk6100
[hide private]
[frames] | no frames]

Source Code for Module phones.com_sk6100

  1  ### BITPIM 
  2  ### 
  3  ### Copyright (C) 2005 Yosef Meller <mellerf@netvision.net.il> 
  4  ### 
  5  ### This program is free software; you can redistribute it and/or modify 
  6  ### it under the terms of the BitPim license as detailed in the LICENSE file. 
  7  ### 
  8  ### $Id: com_sk6100.py 3092 2006-04-13 03:13:47Z skyjunky $ 
  9   
 10  import com_phone 
 11  import com_brew 
 12  import prototypes 
 13  import p_sk6100 
 14   
15 -class Phone(com_phone.Phone, com_brew.BrewProtocol):
16 """Talk to SK Music Slider""" 17 18 desc="SK Music Slider" 19 protocolclass=p_sk6100 20 serialsname='sk6100' 21 22 # This is ordered by the type id nums the phone uses: 23 phonetypes = [ 'cell', 'home', 'office', 'fax', 'pager' ] 24
25 - def __init__(self, logtarget, commport):
26 com_phone.Phone.__init__(self, logtarget, commport) 27 com_brew.BrewProtocol.__init__(self)
28
29 - def getfundamentals(self, results):
30 grbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/group.pbk')) 31 groups = self.protocolclass.groups() 32 groups.readfrombuffer(grbuf, logtitle="Groups read") 33 34 # decode caharachters to unicode - should use some global setting, 35 # hard-coding is bad for you :-) 36 grsort = [group for group in groups.pbgroups if group.name != ''] 37 38 results['groups'] = grsort 39 return results
40
41 - def getphonebook(self, results):
42 43 # Get a list of phone numbers: 44 phonebuf = prototypes.buffer(self.getfilecontents('SKY/PBK/number.pbk')) 45 phones = self.protocolclass.phones() 46 phones.readfrombuffer(phonebuf, logtitle="Phonenumbers") 47 48 # Drop empty phone records, listify: 49 phones = [phone for phone in phones.records if phone.owner_id] 50 51 # Retrieve people names and groups 52 pbook={} 53 bookbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/book.pbk')) 54 entries = self.protocolclass.wholebook() 55 entries.readfrombuffer(bookbuf, logtitle="Names read") 56 57 for entry in entries.pbentries: 58 # Ignore deleted records 59 if not entry.record: 60 continue 61 62 # Find group name: 63 group_name = "Group not recognised" 64 for group in results['groups']: 65 if group.group_id == entry.group_id: 66 group_name = group.name 67 break 68 69 pbook[entry.slot] = { 70 'names': [{'title': '', 'first': '', 71 'last': '', 'full': entry.name, 'nickname': ''}], 72 'categories': [{'category': group_name}], 73 'numbers': [{'number': phone.number, 74 'type': self.phonetypes[phone.type - 1]} 75 for phone in phones 76 if phone.owner_id == entry.slot], 77 'serials': [{'sourcetype': self.serialsname}] 78 } 79 80 results['phonebook'] = pbook 81 results['categories'] = [group.name for group in results['groups']] 82 return pbook
83
84 - def getcalendar(self, results):
85 pass
86
87 - def getwallpapers(self, results):
88 pass
89
90 - def getringtones(self, results):
91 pass
92
93 -class Profile(com_phone.Profile):
94 deviceclasses=("modem",) 95 96 _supportedsyncs=( 97 ('phonebook', 'read', None), # all phonebook reading 98 )
99