Basic support for sktt imt2000

Yosef Meller <[email protected]>
Newsgroups gmane.comp.mobile.bitpim.devel
Message-ID <[email protected]>
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.

An issue: I hard coded in a conversion from 'iso-8859-8' character set,
but I've put it in a variable that can take it's value from anywhere. I
think there should be a list box with encodings in the settings dialog.
Another option is to use the current locale for that. What do you think?
-- 
   "Necessity may be the mother of invention but coffee is the fuel."
- seen on web.archive.org
com_sktt_imt2000.py (text/plain, 2.7 KB)
import com_phone
import com_brew
import prototypes
import p_sktt_imt2000

# debug
import pickle

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.3 KB)
### BITPIM
###
### Copyright (C) 2003-2004 Roger Binns <[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.
###
### $Id: p_lg.p,v 1.11 2004/04/29 21:21:08 rogerb Exp $

%{
NUM_PBGROUPS=41

"""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
sk_introduce.diff (text/plain, 614 B)
Index: guiwidgets.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/guiwidgets.py,v
retrieving revision 1.227
diff -u -r1.227 guiwidgets.py
--- guiwidgets.py	27 Jan 2005 08:06:26 -0000	1.227
+++ guiwidgets.py	19 Feb 2005 18:40:39 -0000
@@ -339,6 +339,7 @@
                   'SPH-A620 (VGA1000)': 'com_samsungspha620',
                   'SCH-A650': 'com_samsungscha650',
                   'SCH-A670': 'com_samsungscha670',
+                  'SKTT-IMT2000': 'com_sktt_imt2000',
                   'Other CDMA phone': 'com_othercdma',
                   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.