Re: Basic support for sktt imt2000
Yosef Meller <[email protected]>
| Newsgroups | gmane.comp.mobile.bitpim.devel |
|---|---|
| Message-ID | <[email protected]> |
Stephen Wood wrote: > On Sun, 20 Feb 2005 00:41:38 +0200, Yosef Meller > <[email protected]> wrote: > >>I've done the basics for SKTT IMT2000 (AKA "SK Music Slider" in Israel). >>Currently it only supports reading names, categories and phone numbers, >>but I wanted to get this in, since I'm starting a new semester now and >>my work rate will go down. > > > Yosef: > > I'll be happy to check your code into the CVS, but first you need > to put your copyright on com_ and p_ files and license them with the > BitPim license (GPL with a special exception, see LICENSE) You can > repost the files with the copyright or email them to me. > > Thanks, Stephen There we go. I hope I got it right this time. -- "Necessity may be the mother of invention but coffee is the fuel." - seen on web.archive.org
com_sktt_imt2000.py
(text/plain, 2.9 KB)
### BITPIM ### ### Copyright (C) 2005 Yosef Meller <[email protected]> ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of the BitPim license as detailed in the LICENSE file. ### import com_phone import com_brew import prototypes import p_sktt_imt2000 class Phone(com_phone.Phone, com_brew.BrewProtocol): """Talk to SK Music Slider""" desc="SK Music Slider" protocolclass=p_sktt_imt2000 # This is ordered by the type id nums the phone uses: phonetypes = [ 'cell', 'home', 'office', 'fax' ] def __init__(self, logtarget, commport): com_phone.Phone.__init__(self, logtarget, commport) com_brew.BrewProtocol.__init__(self) def getfundamentals(self, results): grbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/group.pbk')) groups = self.protocolclass.groups() groups.readfrombuffer(grbuf) self.logdata("Groups read", grbuf.getdata(), groups) # decode caharachters to unicode - should use some global setting, # hard-coding is bad for you :-) grsort = [group for group in groups.pbgroups if group.name != ''] results['groups'] = grsort return results def getphonebook(self, results): encoding = 'iso-8859-8' # Should be some global setting # Get a list of phone numbers: phonebuf = prototypes.buffer(self.getfilecontents('SKY/PBK/number.pbk')) phones = self.protocolclass.phones() phones.readfrombuffer(phonebuf) # Drop empty phone records, listify: phones = [phone for phone in phones.records if phone.owner_id] # Retrieve people names and groups pbook={} bookbuf = prototypes.buffer(self.getfilecontents('SKY/PBK/book.pbk')) entries = self.protocolclass.wholebook() entries.readfrombuffer(bookbuf) self.logdata("Names read", bookbuf.getdata(), entries) for entry in entries.pbentries: # Ignore deleted records if not entry.record: continue # Find group name: group_name = "Group not recognised" for group in results['groups']: if group.group_id == entry.group_id: group_name = group.name.decode(encoding) break pbook[entry.slot] = { 'names': [{'title': '', 'first': '', 'last': '', 'full': entry.name.decode(encoding), 'nickname': ''}], 'categories': [{'category': group_name}], 'numbers': [{'number': phone.number, 'type': self.phonetypes[phone.type - 1]} for phone in phones if phone.owner_id == entry.slot], 'serials': [{'sourcetype': "sktt_imt2000"}] } results['phonebook'] = pbook results['categories'] = [group.name.decode(encoding) for group in results['groups']] return pbook def getcalendar(self, results): pass def getwallpapers(self, results): pass def getringtones(self, results): pass class Profile(com_phone.Profile): deviceclasses=("modem",) _supportedsyncs=( ('phonebook', 'read', None), # all phonebook reading )
p_sktt_imt2000.p
(text/plain, 1.2 KB)
### BITPIM ### ### Copyright (C) 2005 Yosef Meller <[email protected]> ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of the BitPim license as detailed in the LICENSE file. ### %{ """Various descriptions of data specific to SKTT IMT2000""" from prototypes import * # We use LSB for all integer like fields UINT=UINTlsb BOOL=BOOLlsb NUM_PBENTRIES=1200 NUM_PBGROUPS=41 NUM_PHONES=2400 %} PACKET wholebook: 16 STRING filename * LIST {'elementclass': pbentry, 'length': NUM_PBENTRIES} pbentries PACKET pbentry: 1 UINT slot "All of them are numbered" 3 UNKNOWN unk1 1 UINT group_id 1 UNKNOWN unk3 1 UINT record "Only nonzero if not deleted" 5 UNKNOWN unk4 20 STRING name "The place until the zeroes end" 96 UNKNOWN unk2 PACKET groups: 16 STRING filename "group file name" * LIST {'elementclass': pbgroup, 'length': NUM_PBGROUPS} pbgroups PACKET pbgroup: 1 UINT group_id 3 UNKNOWN unk1 21 STRING name 1 UINT unk3 30 UNKNOWN unk2 PACKET phones: 16 STRING filename * LIST {'elementclass': phone, 'length': NUM_PHONES} records # 44 total record length PACKET phone: 2 UINT slot 4 UINT others 4 UINT owner_id 1 UINT type "Home / Work / Cell / Fax" 33 STRING number