Zhone

From Openmoko

Revision as of 15:47, 17 June 2009 by Mcmerix (Talk | contribs)

Jump to: navigation, search
Key pages on:
FSO

(Other distributions)


Contents

Zen Phone

Screenshots: FSO UI Tutorial

Zhone is often told to be a demo application for the free softphone framework (FSO). But it actually is a quite usable phone program that allows to send and receive calls, SMS messages and tells you your gps coordinates. The FSO automagically detects when the gps coordinates are no more shown and shuts down the GPS hardware as long as it is not needed.

Since it mainly only sends commands over dbus to the daemons that actually do the work it is rather stable and even able to do multitasking like allowing you to read an SMS whilst using the phone.

Using VCF within Zhone

Arne sent a small patch that imports phone numbers from a VCF 3.0 address book. Since Zhone has problems with numbers -, the patch below is a sligthly different and removes -.

In /usr/bin/zhone search for class pyphone_contacts(edje_group) and modify the prepare function:

    def prepare( self ):
        if not self.ready and not self.busy:
            logger.info( "retrieving phonebook from addressbook.vcf..." )
            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())
                    number = number.replace('-','')
                    number = number.replace(' ','')
                    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
                # Search for both N: and N; since it depends on the VCF file. For example ones created with tsv2vcf.pl have "N:", not the usual "N;"
                if line.startswith("N:"):
                    name = unicode(line.partition(":")[2].replace(';',' ').strip(), "utf8", "utf8")
                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'),
                ] )
             """

Beware this patch loads and parses addressbook.vcf on each start of zhone - I was pretty impressed I did not even notice a significant delay on my 241 entries vcf, though.

If you have multiple phone numbers per contact and these are separated with commas (like an export from abook, e.g. "112233,998877,665544") you don't see the name when being called - and you cannot call these "multiple" numbers. You can extend the above:

            for line in file:
                #if line.startswith("END:VCARD"):
                if line.startswith("TEL;"):
                     number = unicode(line.partition(":")[2].strip())
                     number = number.replace('-','')
                     number = number.replace(' ','')
                     if name and number:
-                    if name and number:
-                        entry = entry_nr, name, number
-                        entries.append(entry)
-                        entry_nr = entry_nr + 1
+                        nums = number.split(",")
+                        for num in nums:
+                            entry = entry_nr, name, num
+                            entries.append(entry)
+                            entry_nr = entry_nr + 1

This makes up one entry for each number - all with the same name.

After exporting from abook ("gcrd GnomeCard (VCard) addressbook" format) you should convert it to utf-8, possibly like this (all.vcf is the abook exported file):

iconv -f ISO-8859-1 -t utf-8 all.vcf > addressbook.vcf

Then transfer addressbook.vcf to your phone. Make sure the name stays the same, it's hardcoded in the code above. On my phone $HOME/addressbook.vcf resolves to /root/addressbook.vcf.

Installing Zhone on Ubuntu

WARNING: Adding those repositories (or the zhone installation?) may lead to problems on a Kubuntu 8.04 Hardy Heron.

Many packages update are done at the same time (200+ changes), and something break the upgrade. Removing repositories and launching an "apt-get -f install" fix the problem.


  • Add this to your /etc/apt/sources.lst :
deb http://pkg-fso.alioth.debian.org/debian/ unstable main
deb-src http://pkg-fso.alioth.debian.org/debian/ unstable main
deb http://ftp.debian.org/debian/ experimental main
deb http://e17.dunnewind.net/ubuntu hardy e17
  • Execute:
sudo apt-get update
sudo apt-get install zhone
  • remove this from your /etc/apt/sources.lst
deb http://ftp.debian.org/debian/ experimental main
  • Now you can finally execute:
zhone

Developing Zhone

Personal tools
Key pages on:
FSO

(Other distributions)


Zen Phone

Screenshots: FSO UI Tutorial

Zhone is often told to be a demo application for the free softphone framework (FSO). But it actually is a quite usable phone program that allows to send and receive calls, SMS messages and tells you your gps coordinates. The FSO automagically detects when the gps coordinates are no more shown and shuts down the GPS hardware as long as it is not needed.

Since it mainly only sends commands over dbus to the daemons that actually do the work it is rather stable and even able to do multitasking like allowing you to read an SMS whilst using the phone.

Using VCF within Zhone

Arne sent a small patch that imports phone numbers from a VCF 3.0 address book. Since Zhone has problems with numbers -, the patch below is a sligthly different and removes -.

In /usr/bin/zhone search for class pyphone_contacts(edje_group) and modify the prepare function:

    def prepare( self ):
        if not self.ready and not self.busy:
            logger.info( "retrieving phonebook from addressbook.vcf..." )
            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())
                    number = number.replace('-','')
                    number = number.replace(' ','')
                    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
                # Search for both N: and N; since it depends on the VCF file. For example ones created with tsv2vcf.pl have "N:", not the usual "N;"
                if line.startswith("N:"):
                    name = unicode(line.partition(":")[2].replace(';',' ').strip(), "utf8", "utf8")
                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'),
                ] )
             """

Beware this patch loads and parses addressbook.vcf on each start of zhone - I was pretty impressed I did not even notice a significant delay on my 241 entries vcf, though.

If you have multiple phone numbers per contact and these are separated with commas (like an export from abook, e.g. "112233,998877,665544") you don't see the name when being called - and you cannot call these "multiple" numbers. You can extend the above:

            for line in file:
                #if line.startswith("END:VCARD"):
                if line.startswith("TEL;"):
                     number = unicode(line.partition(":")[2].strip())
                     number = number.replace('-','')
                     number = number.replace(' ','')
                     if name and number:
-                    if name and number:
-                        entry = entry_nr, name, number
-                        entries.append(entry)
-                        entry_nr = entry_nr + 1
+                        nums = number.split(",")
+                        for num in nums:
+                            entry = entry_nr, name, num
+                            entries.append(entry)
+                            entry_nr = entry_nr + 1

This makes up one entry for each number - all with the same name.

After exporting from abook ("gcrd GnomeCard (VCard) addressbook" format) you should convert it to utf-8, possibly like this (all.vcf is the abook exported file):

iconv -f ISO-8859-1 -t utf-8 all.vcf > addressbook.vcf

Then transfer addressbook.vcf to your phone. Make sure the name stays the same, it's hardcoded in the code above. On my phone $HOME/addressbook.vcf resolves to /root/addressbook.vcf.

Installing Zhone on Ubuntu

WARNING: Adding those repositories (or the zhone installation?) may lead to problems on a Kubuntu 8.04 Hardy Heron.

Many packages update are done at the same time (200+ changes), and something break the upgrade. Removing repositories and launching an "apt-get -f install" fix the problem.


  • Add this to your /etc/apt/sources.lst :
deb http://pkg-fso.alioth.debian.org/debian/ unstable main
deb-src http://pkg-fso.alioth.debian.org/debian/ unstable main
deb http://ftp.debian.org/debian/ experimental main
deb http://e17.dunnewind.net/ubuntu hardy e17
  • Execute:
sudo apt-get update
sudo apt-get install zhone
  • remove this from your /etc/apt/sources.lst
deb http://ftp.debian.org/debian/ experimental main
  • Now you can finally execute:
zhone

Developing Zhone