View source for Import Vcf Contacts
From Openmoko
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to Import Vcf Contacts.
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to Import Vcf Contacts.
To copy your contacts from other devices or desktop systems, you can use the VCF VCard format. This page explains how to export your contacts from various systems and how to import the resulting file on on Openmoko smartphone.
To use the import tools you need your Contacts in VCF format.
Evolution can export only to VCF version 3.0, so you need to post-process the exported file.
sed -r -e 's/"X-EVOLUTION-CALLBACK"/MSG/g' \ -e 's/;TYPE=([^,]+),[^;]+([;:])/;TYPE=\1\2/g' \ -e 's/;X-EVOLUTION-UI-SLOT=[0-9]//g' old.vcf \ | iconv -t ISO-8859-1 > new.vcf
Note that if you run into errors like
found unknown attribute in vobject, TEL
then there are probably still occurrences of X-EVOLUTION- fields that need to be removed. Also note that the above script converts your addressbook file to ISO-8859-1 (see last line), as its native UTF-8 apparently isn't recognized by Om2008.8. If necessary, eplace ISO-8859-1 by a encoding that better suits your needs.
To export VCF from Thunderbird:
To export VCF from Outlook, 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 Om 2007.2 python script below. (However not suitable for the addressbook tool of Om 2008.8.)
To export VCF:
iconv -f latin1 -t utf-8 vCards.vcf | sed 's/CHARSET=LATIN1://g' > all.vcf
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
Make sure your contact list has extension .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.tmp
mv all.tmp all.vcf
then 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
To import your address book from VCard format (>=QTextended 4.4.1 stable):
LD_LIBRARY_PATH=/opt/Trolltech/Qtopia/lib /opt/Trolltech/Qtopia/bin/addressbook /home/root/addressbook.vcf
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).
opkg install sqlite3 sqlite3 /home/root/Applications/Qtopia/qtopia_db.sqlite delete from contactcategories; delete from contactaddresses; delete from contactcustom; delete from contactphonenumbers; delete from contacts; .quit
The first two are shell commands, the delete commands must by typed in the sqlite> prompt which appears after the sqlite3 command. Prompt is not included here to allow copy/paste.
Make sure you have sqlite3 client installed
opkg install sqlite3
Now we can play with the PIM database file located at
/home/root/Applications/Qtopia/qtopia_db.sqlite
Exporting to VCF can be done via qtmail's 'send all' function (which only supports sms, bluetooth). Exporting all the contacts to a VCF file has yet to be documented. Here is Vasco Névoa's contribution to export to a tab-delimited file:
sqlite3 ~/Applications/Qtopia/qtopia_db.sqlite \ 'Select distinct nickname, title, firstname, middlename, lastname, suffix, \ profession, b_webpage, company, office, department, jobtitle, default_email, \ phone_number, h_webpage, spouse, gender, birthday, anniversary from contacts, \ contactphonenumbers where contacts.recid=contactphonenumbers.recid;'\ | sed 's/|/\t/g' > addressbook.txt
Vasco says:
Each contact that has more than one phone number will appear multiple times because I haven't yet come up with a clean way to show the "join" between the "contacts" and "contactphonenumbers" tables, so for now it just duplicates the whole line, with the only difference being the phone number. Also, this still does not take care of contacts with multiple email addresses, so it is just a work in progress (but better than nothing if you're in a jam). Anyone versed in SQL will be able to hack this into a full VCF file generator... or you can just go the Python or Perl way (but I prefer to use the nice tools already in place - SQL is pretty powerful if you know how).
scp root@192.168.0.202:~/Applications/Qtopia/qtopia_db.sqlite /tmp/ sqlite3 /tmp/qtopia_db.sqlite .dump
Then you can grep the output for your contacts.
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).
If you want to import your old contacts to the Neo you could use this script:
If you first want to remove all existing contacts you could use this script.
If you have all contacts in seperate vcf files and just want to import all at once:
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
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
This script needs all contacts in one big file
You also could run this script on a ssh session!
python manage-contacts.py load < contacts.txt
python manage-contacts.py dump > contacts.txt
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)
Thanks to Import_Sim_Contacts for the original Python Script.