[FSO]: zhone patch for reading vcf instead of sim. was: Re: Once a whiner
arne anka
openmoko at ginguppin.de
Sat Jan 10 11:20:32 CET 2009
here it is.
the code looks for addressbook.vcf in the user's $HOME and reads it in.
multiple numbers per contact are supported.
in /usr/bin/zhone search for
class pyphone_contacts(edje_group):
and find some lines below
def prepare( self ):
and modify like below (be aware of unintentional linebreaks!)
def prepare( self ):
if not self.ready and not self.busy:
file = open(os.environ.get('HOME')+"/addressbook.vcf", "r")
entries = []
entry_nr = 1
name = None
number = None
for line in file:
#if line.startswith("END:VCARD"):
if line.startswith("TEL;"):
number = unicode(line.partition(":")[2].strip())
if name and number:
entry = entry_nr, name, number
entries.append(entry)
entry_nr = entry_nr + 1
if line.startswith("END:VCARD"):
name = None
number = None
if line.startswith("N:"):
name = unicode(line.partition(":")[2].replace(';','
').strip(), "utf8", "utf8")
#if line.startswith("TEL;"):
# number = unicode(line.partition(":")[2].strip())
file.close()
self.cbPhonebookReply(entries)
"""
if dbus_object.gsm_device_obj:
logger.info( "retrieving phonebook..." )
dbus_object.gsm_sim_iface.RetrievePhonebook(
"contacts",
reply_handler=self.cbPhonebookReply,
error_handler=self.cbPhonebookError
)
self.busy = True
else:
# Fake phonebook...
self.cbPhonebookReply( [
(1, u'Kirk', '+023224433'),
(2, u'Spock', '+034433463'),
(3, u'McCoy', '+013244344'),
(4, u'Scott', '+013244344'),
(5, u'Uhura', '+013244344'),
(6, u'Sulu', '+013244344'),
(7, u'Chekov', '+456663443'),
] )
"""
More information about the support
mailing list