Import Vcf Contacts

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (Import for ASU/Qtopia: +why to use DISPLAY=:0)
(Add ASU addressbook purging details)
Line 156: Line 156:
 
   LD_LIBRARY_PATH=/opt/Nokia/Qtopia/lib /opt/Nokia/Qtopia/bin/addressbook /home/root/addressbook.vcf
 
   LD_LIBRARY_PATH=/opt/Nokia/Qtopia/lib /opt/Nokia/Qtopia/bin/addressbook /home/root/addressbook.vcf
  
 +
===Mass Delete===
 +
 +
The Qtopia addressbook doesn't seem to have a delete all function, which means that botching a vcf import is a painful process to undo through the phone gui.
 +
 +
If you want to delete your entire addressbook or do other mass edits then you'll need access to a command line or GUI SQLite client (SQLite Database Browser seems to be a good, free one, though the SQLite command line client should be fine). Shutdown Qtopia and use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db
 +
 +
Important tables -
 +
{|cellspacing="0" border="1" cellpadding="5"
 +
| contacts
 +
| Contact names and other descriptive information, plus a unique id (recid)
 +
|-
 +
| contactphonenumbers
 +
| A list of contact phone numbers matched to recid
 +
|-
 +
| contactaddresses
 +
| Links address information to recid
 +
|}
 +
 +
Restart Qtopia when you're done and you should have a reset addressbook.
 
[[Category:Advanced End User]]
 
[[Category:Advanced End User]]

Revision as of 15:33, 10 September 2008

Contents

Import for 2007.2

Basic Information

Neo FreeRunner uses Evolution data server (eds) to save contacts. However, the specific version used differs from what is probably used on your desktop (if you have Evolution installed).

You cannot copy your addressbook.db from your desktop to Neo (bug 1119).

Import and Manage Scripts

If you want to import your old contacts to the Neo you could use this script:

Manage Contacts script mirror

If you first want to remove all existing contacts you could use this script.

remove all script

If you have all contacts in seperate vcf files and just want to import all at once:

Simple script

Simple script for one big contactsfile

(please add a .py after the filename, sorry my hoster gives an error if i link to .py files, even .py.txt)

In the simple scripts you need to add the following lines

ps = os.popen ('ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS')
l = ps.read ()
r = re.compile ('DBUS_SESSION_BUS_ADDRESS=(\S+)')
m = r.search (l)
a = m.expand ('\\1')
os.environ ['DBUS_SESSION_BUS_ADDRESS'] = a

Exporting old contacts to VCard format

To use the manage Script you need your Contacts in VCF format.

  1. on nokia phones i used the nokia phone manager (long time ago)
  2. on windows mobile phones you could use active sync to sync with Outlook and then use a Outlook export plugin to export as vcf
  3. on lg phones the backup function to memory card creates one file with multiple VCards.

Exporting from Outlook / ActiveSync to VCF

Doing a quick google I was unable to find a free export plugin for outlook (they all seem to want between $19.95 and $49), so I put together some quick-and-dirty VB code to do it. To use it, Open Outlook, then open the VB editor by pressing ALT-F11, Insert a module, and paste in the following. Change "Z:\Openmoko\contacts" to wherever you want your vcf files saved (should be an existing, empty directory), and press F5 to run it.

Code:


Sub ExportContactsToVCF()


    'Cheap and nasty way to export All Contacts to VCF files. 
    'By Dale Maggee, antisol (at) earthling (dot) net

    Dim CN As ContactItem
    Dim NS As NameSpace
    Dim Fld As MAPIFolder    

    Set NS = Application.GetNamespace("MAPI")
    Set Fld = NS.GetDefaultFolder(olFolderContacts)     

    For Each CN In Fld.Items
        Debug.Print CN.FullName
        CN.SaveAs "z:\Openmoko\contacts\" & CN.FullName & ".vcf", olVCard
    Next CN

    MsgBox "Done!"

End Sub

voila! you now have multiple VCF files in whatever directory you chose, suitable to be imported by the python script below.

Usage

The script is for the 2007.2 Version (default install on Neo FreeRunner), not for Qtopia

You need Python to use this script so do a

opkg install python-dbus

to install python and the python dbus module

Manage Contacts Script

This script needs all contacts in one big file

You also could run this script on a ssh session!

  1. Copy your big contacts file (contacts.txt) to your Neo
  2. Copy script to your Neo
  3. Connect via ssh to your Neo
  4. Fix special chars in your contacts file with you favorite text editor
  5. To import the file run on the SSH shell:
python manage-contacts.py load < contacts.txt
  1. For a backup your existing contacts on the Neo
python manage-contacts.py dump > contacts.txt

Simple Script

You must run the script in the OM Terminal, not over ssh

The script does a listdir and imports ALL files it found in that dir. (i'm a bad python programmer)

  1. Copy all vcf files to a separate directory on my freerunner
  2. Copy the ac script to the parent directory also on my freerunner
  3. Have the contacts program running (so you have eds running too)
  4. Go to the terminal on the freerunner and type in the vcf directory: "python ../ac" (root@om-gta02:~/vcf# python ../ac)
    1. Note: You must call the script in the OM terminal not via Bluetooth or USB or you get a dbus error. Using "dbus-launch python ../ac" doesn't work either.
  5. Done :D

Troubleshooting

  • Make sure you have python and python-dbus installed
  • Make sure you have no illegal chars (utf) in the filename and inside the vcf files. (I had problems with Ü,Ä etc)
    • The characters seem to work if you convert them from =C3=A4 type of format to proper UTF-8, and the vcards also specify UTF-8 charset. you cannot use other charsets besides UTF-8 since they are delivered via DBus which does not allow others.
  • Only vcf files should be in your current directory so do a ../ac.
  • You must call the script in the OM terminal not via Bluetooth or USB. If you do so a dbus error occur


Authors

  • Simple script by smurfy - phil <openmoko at smurfy.de>
  • Manage Contacts script by Roland Mas <lolando at debian.org>
  • Remove all Contacts script / simple script for one big file by Andreas Dalsgaard <andreas.dalsgaard at gmail.com>

Thanks to Import_Sim_Contacts for the original Python Script.

Import for ASU/Qtopia

The Qtopia addressbook application supports import of VCF files out of the box. However, since there is a bug, if there are non-ASCII characters in your contacts you cannot use the version 3 format, otherwise you get multibyte UTF-8 characters mangled. Use the version 2.1 to get the encoding stated explicitly and thus characters imported correctly. But because there is another bug, when using version 2.1 vCards, the addressbook eats up all memory (and potentionally crashes the system) on some vCards with multiline entries.

If you're connected via SSH, run the following command first:

 export DISPLAY=:0

(So that the addressbook will show on your phone. If you do not that and try to run addressbook locally on your computer display, you won't be able to use the application since the needed buttons will not show.)

Then you can simply run:

 addressbook path_to_vCards_file_to_import.vcf

You will be asked if you want to import the contacts form addressbook.vcf (the contact name will be taken from the "N:" vCard field).

To import a huge number of contacts, single .vcf files can be merged together using cat *.vcf > all.vcf, than import all.vcf

Tip: If you want to prevent crashing your system if the memory leak occurs, set some limit on memory available to use, so that only the addressbook application dies after reaching the limit. I.e. prior to running the import, do something like:

 ulimit -v 50000

If the above does not work, here are the original import guidelines:

To import your address book from VCard format (ASU/<=Qtopia 4.3.2-080808 snapshot):

 LD_LIBRARY_PATH=/opt/Qtopia/lib /opt/Qtopia/bin/addressbook /home/root/addressbook.vcf

To import your address book from VCard format (>=Qtopia 4.3.2 stable):

 LD_LIBRARY_PATH=/opt/Nokia/Qtopia/lib /opt/Nokia/Qtopia/bin/addressbook /home/root/addressbook.vcf

Mass Delete

The Qtopia addressbook doesn't seem to have a delete all function, which means that botching a vcf import is a painful process to undo through the phone gui.

If you want to delete your entire addressbook or do other mass edits then you'll need access to a command line or GUI SQLite client (SQLite Database Browser seems to be a good, free one, though the SQLite command line client should be fine). Shutdown Qtopia and use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db

Important tables -

contacts Contact names and other descriptive information, plus a unique id (recid)
contactphonenumbers A list of contact phone numbers matched to recid
contactaddresses Links address information to recid

Restart Qtopia when you're done and you should have a reset addressbook.

Personal tools

Import for 2007.2

Basic Information

Neo FreeRunner uses Evolution data server (eds) to save contacts. However, the specific version used differs from what is probably used on your desktop (if you have Evolution installed).

You cannot copy your addressbook.db from your desktop to Neo (bug 1119).

Import and Manage Scripts

If you want to import your old contacts to the Neo you could use this script:

Manage Contacts script mirror

If you first want to remove all existing contacts you could use this script.

remove all script

If you have all contacts in seperate vcf files and just want to import all at once:

Simple script

Simple script for one big contactsfile

(please add a .py after the filename, sorry my hoster gives an error if i link to .py files, even .py.txt)

In the simple scripts you need to add the following lines

ps = os.popen ('ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS')
l = ps.read ()
r = re.compile ('DBUS_SESSION_BUS_ADDRESS=(\S+)')
m = r.search (l)
a = m.expand ('\\1')
os.environ ['DBUS_SESSION_BUS_ADDRESS'] = a

Exporting old contacts to VCard format

To use the manage Script you need your Contacts in VCF format.

  1. on nokia phones i used the nokia phone manager (long time ago)
  2. on windows mobile phones you could use active sync to sync with Outlook and then use a Outlook export plugin to export as vcf
  3. on lg phones the backup function to memory card creates one file with multiple VCards.

Exporting from Outlook / ActiveSync to VCF

Doing a quick google I was unable to find a free export plugin for outlook (they all seem to want between $19.95 and $49), so I put together some quick-and-dirty VB code to do it. To use it, Open Outlook, then open the VB editor by pressing ALT-F11, Insert a module, and paste in the following. Change "Z:\Openmoko\contacts" to wherever you want your vcf files saved (should be an existing, empty directory), and press F5 to run it.

Code:


Sub ExportContactsToVCF()


    'Cheap and nasty way to export All Contacts to VCF files. 
    'By Dale Maggee, antisol (at) earthling (dot) net

    Dim CN As ContactItem
    Dim NS As NameSpace
    Dim Fld As MAPIFolder    

    Set NS = Application.GetNamespace("MAPI")
    Set Fld = NS.GetDefaultFolder(olFolderContacts)     

    For Each CN In Fld.Items
        Debug.Print CN.FullName
        CN.SaveAs "z:\Openmoko\contacts\" & CN.FullName & ".vcf", olVCard
    Next CN

    MsgBox "Done!"

End Sub

voila! you now have multiple VCF files in whatever directory you chose, suitable to be imported by the python script below.

Usage

The script is for the 2007.2 Version (default install on Neo FreeRunner), not for Qtopia

You need Python to use this script so do a

opkg install python-dbus

to install python and the python dbus module

Manage Contacts Script

This script needs all contacts in one big file

You also could run this script on a ssh session!

  1. Copy your big contacts file (contacts.txt) to your Neo
  2. Copy script to your Neo
  3. Connect via ssh to your Neo
  4. Fix special chars in your contacts file with you favorite text editor
  5. To import the file run on the SSH shell:
python manage-contacts.py load < contacts.txt
  1. For a backup your existing contacts on the Neo
python manage-contacts.py dump > contacts.txt

Simple Script

You must run the script in the OM Terminal, not over ssh

The script does a listdir and imports ALL files it found in that dir. (i'm a bad python programmer)

  1. Copy all vcf files to a separate directory on my freerunner
  2. Copy the ac script to the parent directory also on my freerunner
  3. Have the contacts program running (so you have eds running too)
  4. Go to the terminal on the freerunner and type in the vcf directory: "python ../ac" (root@om-gta02:~/vcf# python ../ac)
    1. Note: You must call the script in the OM terminal not via Bluetooth or USB or you get a dbus error. Using "dbus-launch python ../ac" doesn't work either.
  5. Done :D

Troubleshooting

  • Make sure you have python and python-dbus installed
  • Make sure you have no illegal chars (utf) in the filename and inside the vcf files. (I had problems with Ü,Ä etc)
    • The characters seem to work if you convert them from =C3=A4 type of format to proper UTF-8, and the vcards also specify UTF-8 charset. you cannot use other charsets besides UTF-8 since they are delivered via DBus which does not allow others.
  • Only vcf files should be in your current directory so do a ../ac.
  • You must call the script in the OM terminal not via Bluetooth or USB. If you do so a dbus error occur


Authors

  • Simple script by smurfy - phil <openmoko at smurfy.de>
  • Manage Contacts script by Roland Mas <lolando at debian.org>
  • Remove all Contacts script / simple script for one big file by Andreas Dalsgaard <andreas.dalsgaard at gmail.com>

Thanks to Import_Sim_Contacts for the original Python Script.

Import for ASU/Qtopia

The Qtopia addressbook application supports import of VCF files out of the box. However, since there is a bug, if there are non-ASCII characters in your contacts you cannot use the version 3 format, otherwise you get multibyte UTF-8 characters mangled. Use the version 2.1 to get the encoding stated explicitly and thus characters imported correctly. But because there is another bug, when using version 2.1 vCards, the addressbook eats up all memory (and potentionally crashes the system) on some vCards with multiline entries.

If you're connected via SSH, run the following command first:

 export DISPLAY=:0

(So that the addressbook will show on your phone. If you do not that and try to run addressbook locally on your computer display, you won't be able to use the application since the needed buttons will not show.)

Then you can simply run:

 addressbook path_to_vCards_file_to_import.vcf

You will be asked if you want to import the contacts form addressbook.vcf (the contact name will be taken from the "N:" vCard field).

To import a huge number of contacts, single .vcf files can be merged together using cat *.vcf > all.vcf, than import all.vcf

Tip: If you want to prevent crashing your system if the memory leak occurs, set some limit on memory available to use, so that only the addressbook application dies after reaching the limit. I.e. prior to running the import, do something like:

 ulimit -v 50000

If the above does not work, here are the original import guidelines:

To import your address book from VCard format (ASU/<=Qtopia 4.3.2-080808 snapshot):

 LD_LIBRARY_PATH=/opt/Qtopia/lib /opt/Qtopia/bin/addressbook /home/root/addressbook.vcf

To import your address book from VCard format (>=Qtopia 4.3.2 stable):

 LD_LIBRARY_PATH=/opt/Nokia/Qtopia/lib /opt/Nokia/Qtopia/bin/addressbook /home/root/addressbook.vcf

Mass Delete

The Qtopia addressbook doesn't seem to have a delete all function, which means that botching a vcf import is a painful process to undo through the phone gui.

If you want to delete your entire addressbook or do other mass edits then you'll need access to a command line or GUI SQLite client (SQLite Database Browser seems to be a good, free one, though the SQLite command line client should be fine). Shutdown Qtopia and use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db

Important tables -

contacts Contact names and other descriptive information, plus a unique id (recid)
contactphonenumbers A list of contact phone numbers matched to recid
contactaddresses Links address information to recid

Restart Qtopia when you're done and you should have a reset addressbook.