below a patch for zhone to read contatcs instead from sim from /root/addressbook.vcf (what's the easiest way to determine the user's home directory from python?) main difference to the patch proposed someweher on the wiki: _all_ numbers of one contact are added to the list, not just the last one.

actually, the last two section address
a) disabling the zhone screensaver which is probably unwanted if you run zhone from xfce b) catching an exception i've seen several times when suspending -- it slowed down suspend considerably

--- zhone.orig  2008-10-26 20:31:34.000000000 +0100
+++ zhone.patched       2008-10-26 20:31:47.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 #coding=utf8
 """
 Zen Phone - A Phone UI
@@ -731,6 +731,29 @@

     def prepare( self ):
         if not self.ready and not self.busy:
+            file = open("/root/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(
@@ -749,6 +772,7 @@
                     (6, u'Sulu', '+013244344'),
                     (7, u'Chekov', '+456663443'),
                 ] )
+            """

     def onReadyStatus( self, status ):
         logger.debug( "SIM is ready: %s" % status )
@@ -1818,7 +1842,7 @@
dbus_object.onReadyStatus.append( self.groups["contacts"].onReadyStatus ) dbus_object.onReadyStatus.append( self.groups["sms"].onReadyStatus ) dbus_object.onIncomingMessage.append( self.groups["sms"].onIncomingMessage )
-        dbus_object.onIdleStateChanged.append( self.lock_on_idle )
+        #dbus_object.onIdleStateChanged.append( self.lock_on_idle )

         logger.debug( "GUI init done" )

@@ -2182,7 +2206,10 @@
         elif name+action == "POWERreleased":
             if self.willSuspend:
                 self.willSuspend = False
+                try:
                 self.gsm_device_iface.PrepareForSuspend()
+                except DBusException:
+                    logger.info( "DBUSEXCEPTION" )
                 logger.info( "ENTERING SUSPEND" )
                 os.system( "apm -s" )
                 logger.info( "RETURN FROM SUSPEND" )

Attachment: zhone_contacts_from_vcf.patch.gz
Description: GNU Zip compressed data

_______________________________________________
Openmoko community mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to