Import Vcf Contacts

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (On Om 2008.8: quit command to sqlite.)
m (Mac OS X Addressbook)
 
(25 intermediate revisions by 19 users not shown)
Line 6: Line 6:
  
 
# On nokia phones use the Nokia phone manager {{Citation needed}}
 
# On nokia phones use the Nokia phone manager {{Citation needed}}
# On windows mobile phones you could use active sync to sync with Outlook and then use a Outlook export plugin to export as vcf
+
# On latest SonyEricsson phones choose to send all contacts (via bluetooth) or make a backup on memory card (tested on Z710i, no problems with unicode when importing to openmoko)
 +
# On windows mobile phones you could use active sync to sync with Outlook and then use a Outlook VCF export plugin below
 
# On LG phones the backup function to memory card creates one file with multiple VCards
 
# On LG phones the backup function to memory card creates one file with multiple VCards
  
=== Exporting from Outlook / ActiveSync to VCF ===
+
=== Evolution ===
  
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.
+
Evolution can export only to VCF version 3.0, so you need to post-process the exported file.
 +
 
 +
* Select Contacts, then File > Save Address Book as VCard and save to your desired destination.
 +
* Use the following command to remove evolution's proprietary fields and convert the file to an encoding Om2008.8 will understand (replace old.vcf to the filename you chose for export of your addressbook in evolution):
 +
 
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
Note that if you run into errors like
 +
 
 +
<pre>found unknown attribute in vobject, TEL </pre>
 +
 
 +
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.
 +
 
 +
=== Thunderbird ===
 +
 
 +
To export VCF from Thunderbird:
 +
 
 +
* Get "MoreFunctionsForAddressBook" from http://nic-nac-project.de/~kaosmos/morecols-en.html
 +
* Install the downloaded *.xpi file in Thunderbird
 +
* Open address book
 +
* Select address book to export (not a contact or set of contacts!)
 +
* Right click and export to Vcf format (or use the Tools menu, Actions for AddressBooks) (If gray, you did not select an addressbook.)
 +
* Select destination folder
 +
* sed -r -e 's/;TYPE=([^,]+),[^;]+([;:])/;TYPE=\1\2;/g' < contacts.vcf | iconv -t 'ascii//TRANSLIT' > exported.vcf (otherwise the import function below will bark claiming that the vcard contains no valid information, as described at http://lists.openmoko.org/nabble.html#nabble-td784024 )
 +
 
 +
=== Outlook / ActiveSync to VCF ===
 +
 
 +
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:'''
 
'''Code:'''
Line 20: Line 54:
  
  
    'Cheap and nasty way to export All Contacts to VCF files.  
+
'Cheap and nasty way to export All Contacts to VCF files.
    'By Dale Maggee, antisol (at) earthling (dot) net
+
'By Dale Maggee, antisol (at) earthling (dot) net
  
    Dim CN As ContactItem
+
Dim CN As ContactItem
    Dim NS As NameSpace
+
Dim NS As NameSpace
    Dim Fld As MAPIFolder  
+
Dim Fld As MAPIFolder
  
    Set NS = Application.GetNamespace("MAPI")
+
Set NS = Application.GetNamespace("MAPI")
    Set Fld = NS.GetDefaultFolder(olFolderContacts)    
+
Set Fld = NS.GetDefaultFolder(olFolderContacts)
  
    For Each CN In Fld.Items
+
For Each CN In Fld.Items
        Debug.Print CN.FullName
+
Debug.Print CN.FullName
        CN.SaveAs "z:\Openmoko\contacts\" & CN.FullName & ".vcf", olVCard
+
CN.SaveAs "z:\Openmoko\contacts\" & CN.FullName & ".vcf", olVCard
    Next CN
+
Next CN
  
    MsgBox "Done!"
+
MsgBox "Done!"
  
 
End Sub
 
End Sub
Line 42: Line 76:
 
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.)
 
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.)
  
=== Export vCards from Mac OS X Addressbook ===
+
=== Mac OS X Addressbook ===
 +
Open addressbook on MacOS and click with together with the Control (Ctrl) on the group of addresses and a menu will appear. Select option to export the adresses to vCard.
  
# Set the vCard Format to 2.1 in the config dialog
+
To export VCF:
# Select all contacts and say "export vcard"
+
 
 +
# Set the vCard Format to 2.1 in the ''vCard'' config dialog in <tt>Adressbook-/-Preferences</tt>
 +
# Set charset to be utf-8  in the ''vCard'' config dialog in <tt>Adressbook-/-Preferences</tt>
 +
# Select all contacts (Ctrl-Click in your MacOS adressbook) and select "export vcard"
 
# Despite having selected the charset to be utf-8 you may need to do:
 
# Despite having selected the charset to be utf-8 you may need to do:
  
 
<code>
 
<code>
iconv -f latin1 -t utf-8 vCards.vcf | sed 's/CHARSET=LATIN1://g' > all.vcf
+
iconv -f latin1 -t utf-8 vCards.vcf | sed 's/CHARSET=LATIN1://g' > all.vcf
 
</code>
 
</code>
  
== Import on Om 2008.8 and Qtopia ==
+
== Import on Om 2008.12 ==
 +
 
 +
The Qtopia addressbook application supports import of VCF files out of the box. The following character encodings have be confirmed to work:
 +
 
 +
* ASCII
 +
* latin1
 +
 
 +
Files encoded in UTF8 are not supported (non-ASCII characters get mangled on import). To change the character encoding use the following command:
 +
 
 +
<code>
 +
$ iconv -c -f utf8 -t latin1 addressbook-vCard3.0-utf8.vcf > addressbook-vCard3.0-latin1.vcf
 +
</code>
 +
 
 +
== Import (and export?) on Om 2008.8 and 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.
 
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:
 
If you're connected via SSH, run the following command first:
  export DISPLAY=:0
+
 
 +
<pre>
 +
export DISPLAY=:0
 +
</pre>
  
 
''(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.)''
 
''(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:
 
Then you can simply run:
  addressbook path_to_vCards_file_to_import.vcf
+
 
 +
<pre>
 +
addressbook path_to_vCards_file_to_import.vcf
 +
</pre>
 +
 
 +
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).
 
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
+
To import a huge number of contacts, single .vcf files can be merged together using:
 +
 
 +
<pre>
 +
cat *.vcf > all.tmp
 +
mv all.tmp all.vcf
 +
</pre>
 +
 
 +
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:''
 
''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
+
 
 +
<pre>
 +
ulimit -v 50000
 +
</pre>
  
 
If the above does not work, here are the original import guidelines:
 
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):
 
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
+
 
 +
'''''Note: On later versions of QT Extended, replace /opt/Qtopia with /opt/Trolltech/Qtopia in the instructions below'''''
 +
 
 +
<pre>
 +
export LD_LIBRARY_PATH=/opt/Qtopia/lib
 +
/opt/Qtopia/bin/addressbook /home/root/addressbook.vcf
 +
</pre>
  
 
To import your address book from VCard format (>=Qtopia 4.3.2 stable):
 
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===
+
<pre>
 +
export LD_LIBRARY_PATH=/opt/Nokia/Qtopia/lib
 +
/opt/Nokia/Qtopia/bin/addressbook /home/root/addressbook.vcf
 +
</pre>
  
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.
+
To import your address book from VCard format (>=QTextended 4.4.1 stable):
  
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).  
+
<pre>
 +
export LD_LIBRARY_PATH=/opt/Trolltech/Qtopia/lib
 +
/opt/Trolltech/Qtopia/bin/addressbook /home/root/addressbook.vcf
 +
</pre>
  
Shutdown Qtopia and use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db.
 
  
Important tables:
+
===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).
  
{|cellspacing="0" border="1" cellpadding="5"
+
====Qtopia====
| 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.
+
* Shutdown Qtopia
 +
* Use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db.
 +
* Important tables: contacts, contactphonenumbers, contactaddresses
 +
* Restart Qtopia when you're done and you should have a reset addressbook.
  
 
====On Om 2008.8====
 
====On Om 2008.8====
Line 108: Line 185:
 
* Delete all data from the contacts tables '''This will erase all your contacts and contact categories.'''
 
* Delete all data from the contacts tables '''This will erase all your contacts and contact categories.'''
  
opkg install sqlite3
+
<pre>
sqlite3 /home/root/Applications/Qtopia/qtopia_db.sqlite
+
opkg install sqlite3
+
sqlite3 /home/root/Applications/Qtopia/qtopia_db.sqlite
delete from contactcategories;
+
 
delete from contactaddresses;
+
delete from contactcategories;
delete from contactcustom;
+
delete from contactaddresses;
delete from contactphonenumbers;
+
delete from contactcustom;
delete from contacts;
+
delete from contactphonenumbers;
.quit
+
delete from contacts;
 +
.quit
 +
</pre>
 +
 
  
 
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.
 
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.
  
[[Category:Advanced End User]]
+
==== Exporting ====
 +
Make sure you have sqlite3 client installed
 +
<pre>opkg install sqlite3</pre>
 +
 
 +
Now we can play with the PIM database file located at
 +
<pre>/home/root/Applications/Qtopia/qtopia_db.sqlite</pre>
 +
 
 +
Exporting to VCF can be done via qtmail's 'send all' function (which only supports sms, e-mail, bluetooth).
 +
 
 +
You can export all your contacts (with each contact's phone numbers on the same line) with this SQL query. This works because the contactphonenumbers table has limited phone_type values. We can't do the same left outer join query for the emails because there can be an unlimited count of emails per contacts.
 +
<pre>
 +
Select distinct nickname, title, firstname, middlename, lastname, suffix,
 +
profession, b_webpage, company, office, department, jobtitle, default_email,
 +
cpn1.phone_number as Home_Phone,
 +
cpn2.phone_number as Home_Mobile,
 +
cpn3.phone_number as Home_VOIP,
 +
cpn4.phone_number as Home_Fax,
 +
cpn5.phone_number as Business_Phone,
 +
cpn6.phone_number as Business_Mobile,
 +
cpn7.phone_number as Business_VOIP,
 +
cpn8.phone_number as Business_Fax,
 +
cpn9.phone_number as Business_Pager,
 +
h_webpage, spouse, gender, birthday, anniversary from contacts
 +
 
 +
left outer join contactphonenumbers as cpn1
 +
on contacts.recid=cpn1.recid and cpn1.phone_type=1
 +
 
 +
left outer join contactphonenumbers as cpn2
 +
on contacts.recid=cpn2.recid and cpn2.phone_type=257
 +
 
 +
left outer join contactphonenumbers as cpn3
 +
on contacts.recid=cpn3.recid and cpn3.phone_type=769
 +
 
 +
left outer join contactphonenumbers as cpn4
 +
on contacts.recid=cpn4.recid and cpn4.phone_type=513
 +
 
 +
left outer join contactphonenumbers as cpn5
 +
on contacts.recid=cpn5.recid and cpn5.phone_type=2
 +
 
 +
left outer join contactphonenumbers as cpn6
 +
on contacts.recid=cpn6.recid and cpn6.phone_type=258
 +
 
 +
left outer join contactphonenumbers as cpn7
 +
on contacts.recid=cpn7.recid and cpn7.phone_type=770
 +
 
 +
left outer join contactphonenumbers as cpn8
 +
on contacts.recid=cpn8.recid and cpn8.phone_type=514
 +
 
 +
left outer join contactphonenumbers as cpn9
 +
on contacts.recid=cpn9.recid and cpn9.phone_type=1026;
 +
</pre>
 +
 
 +
I needed the vcf file for other purposes and found a script [http://sourceforge.net/projects/tsv2vcf/] on SF.net to convert a tab seperated value to a vcf file.
 +
So I used this ugly thing:
 +
 
 +
<pre>
 +
 
 +
sqlite3 ~/Applications/Qtopia/qtopia_db.sqlite $1 'Select distinct firstname, lastname, middlename,
 +
nickname, default_email,title,
 +
cpn5.phone_number as Business_Phone,
 +
cpn1.phone_number as Home_Phone,
 +
cpn8.phone_number as Business_Fax,
 +
cpn9.phone_number as Business_Pager,
 +
cpn2.phone_number as Home_Mobile from contacts
 +
left outer join contactphonenumbers as cpn1
 +
on contacts.recid=cpn1.recid and cpn1.phone_type=1
 +
left outer join contactphonenumbers as cpn2
 +
on contacts.recid=cpn2.recid and cpn2.phone_type=257
 +
left outer join contactphonenumbers as cpn3
 +
on contacts.recid=cpn3.recid and cpn3.phone_type=769
 +
left outer join contactphonenumbers as cpn4
 +
on contacts.recid=cpn4.recid and cpn4.phone_type=513
 +
left outer join contactphonenumbers as cpn5
 +
on contacts.recid=cpn5.recid and cpn5.phone_type=2
 +
left outer join contactphonenumbers as cpn6
 +
on contacts.recid=cpn6.recid and cpn6.phone_type=258
 +
left outer join contactphonenumbers as cpn7
 +
on contacts.recid=cpn7.recid and cpn7.phone_type=770
 +
left outer join contactphonenumbers as cpn8
 +
on contacts.recid=cpn8.recid and cpn8.phone_type=514
 +
left outer join contactphonenumbers as cpn9
 +
on contacts.recid=cpn9.recid and cpn9.phone_type=1026;'| sed 's/|/\t/g' > addressbook.tsv
 +
 
 +
</pre>
 +
 
 +
put the output through tsv2vcf:
 +
<pre>
 +
perl tsv2vcf addressbook.tsv addressbook.vcf
 +
</pre>
 +
 
 +
and got a usable vcf File, with some problems with special chars.
 +
 
 +
== Export raw config (including contacts) with Qtopia ==
 +
<pre>
 +
scp root@192.168.0.202:~/Applications/Qtopia/qtopia_db.sqlite /tmp/
 +
sqlite3 /tmp/qtopia_db.sqlite .dump
 +
</pre>
 +
 
 +
Then you can grep the output for your contacts.
  
== Import for 2007.2 ==
+
== Import and export for 2007.2 ==
  
 
=== Basic Information ===
 
=== Basic Information ===
  
Neo FreeRunner uses Evolution data server (eds) to save 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).
 
However, the specific version used differs from what is probably used on your desktop (if you have Evolution installed).
  
Line 150: Line 328:
  
 
In the simple scripts you need to add the following lines
 
In the simple scripts you need to add the following lines
ps = os.popen ('ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS')
+
ps = os.popen ('ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS')
l = ps.read ()
+
l = ps.read ()
r = re.compile ('DBUS_SESSION_BUS_ADDRESS=(\S+)')
+
r = re.compile ('DBUS_SESSION_BUS_ADDRESS=(\S+)')
m = r.search (l)
+
m = r.search (l)
a = m.expand ('\\1')
+
a = m.expand ('\\1')
os.environ ['DBUS_SESSION_BUS_ADDRESS'] = a
+
os.environ ['DBUS_SESSION_BUS_ADDRESS'] = a
  
 
=== Usage ===
 
=== Usage ===
Line 163: Line 341:
 
You need Python to use this script so do a
 
You need Python to use this script so do a
  
opkg install python-dbus
+
opkg install python-dbus
  
 
to install python and the python dbus module
 
to install python and the python dbus module
Line 179: Line 357:
 
# To import the file run on the SSH shell:
 
# To import the file run on the SSH shell:
  
python manage-contacts.py load < contacts.txt
+
python manage-contacts.py load < contacts.txt
  
 
# For a backup your existing contacts on the Neo
 
# For a backup your existing contacts on the Neo
  
python manage-contacts.py dump > contacts.txt
+
python manage-contacts.py dump > contacts.txt
  
 
==== Simple Script ====
 
==== Simple Script ====
Line 213: Line 391:
  
 
Thanks to [[Import_Sim_Contacts]] for the original Python Script.
 
Thanks to [[Import_Sim_Contacts]] for the original Python Script.
 +
 +
[[Category:PIM]]

Latest revision as of 19:02, 11 August 2009

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.

Contents

[edit] Exporting old contacts to VCard format

To use the import tools you need your Contacts in VCF format.

  1. On nokia phones use the Nokia phone manager Citation needed
  1. On latest SonyEricsson phones choose to send all contacts (via bluetooth) or make a backup on memory card (tested on Z710i, no problems with unicode when importing to openmoko)
  2. On windows mobile phones you could use active sync to sync with Outlook and then use a Outlook VCF export plugin below
  3. On LG phones the backup function to memory card creates one file with multiple VCards

[edit] Evolution

Evolution can export only to VCF version 3.0, so you need to post-process the exported file.

  • Select Contacts, then File > Save Address Book as VCard and save to your desired destination.
  • Use the following command to remove evolution's proprietary fields and convert the file to an encoding Om2008.8 will understand (replace old.vcf to the filename you chose for export of your addressbook in evolution):
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.

[edit] Thunderbird

To export VCF from Thunderbird:

  • Get "MoreFunctionsForAddressBook" from http://nic-nac-project.de/~kaosmos/morecols-en.html
  • Install the downloaded *.xpi file in Thunderbird
  • Open address book
  • Select address book to export (not a contact or set of contacts!)
  • Right click and export to Vcf format (or use the Tools menu, Actions for AddressBooks) (If gray, you did not select an addressbook.)
  • Select destination folder
  • sed -r -e 's/;TYPE=([^,]+),[^;]+([;:])/;TYPE=\1\2;/g' < contacts.vcf | iconv -t 'ascii//TRANSLIT' > exported.vcf (otherwise the import function below will bark claiming that the vcard contains no valid information, as described at http://lists.openmoko.org/nabble.html#nabble-td784024 )

[edit] Outlook / ActiveSync to VCF

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.)

[edit] Mac OS X Addressbook

Open addressbook on MacOS and click with together with the Control (Ctrl) on the group of addresses and a menu will appear. Select option to export the adresses to vCard.

To export VCF:

  1. Set the vCard Format to 2.1 in the vCard config dialog in Adressbook-/-Preferences
  2. Set charset to be utf-8 in the vCard config dialog in Adressbook-/-Preferences
  3. Select all contacts (Ctrl-Click in your MacOS adressbook) and select "export vcard"
  4. Despite having selected the charset to be utf-8 you may need to do:

iconv -f latin1 -t utf-8 vCards.vcf | sed 's/CHARSET=LATIN1://g' > all.vcf

[edit] Import on Om 2008.12

The Qtopia addressbook application supports import of VCF files out of the box. The following character encodings have be confirmed to work:

  • ASCII
  • latin1

Files encoded in UTF8 are not supported (non-ASCII characters get mangled on import). To change the character encoding use the following command:

$ iconv -c -f utf8 -t latin1 addressbook-vCard3.0-utf8.vcf > addressbook-vCard3.0-latin1.vcf

[edit] Import (and export?) on Om 2008.8 and 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

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):

Note: On later versions of QT Extended, replace /opt/Qtopia with /opt/Trolltech/Qtopia in the instructions below

export 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):

export 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):

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


[edit] 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).

[edit] Qtopia

  • Shutdown Qtopia
  • Use the client you have chosen to open up /home/root/Applications/qtopia_sqlite.db.
  • Important tables: contacts, contactphonenumbers, contactaddresses
  • Restart Qtopia when you're done and you should have a reset addressbook.

[edit] On Om 2008.8

  • Install sqlite3
  • Open the database
  • Delete all data from the contacts tables This will erase all your contacts and contact categories.
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.

[edit] Exporting

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, e-mail, bluetooth).

You can export all your contacts (with each contact's phone numbers on the same line) with this SQL query. This works because the contactphonenumbers table has limited phone_type values. We can't do the same left outer join query for the emails because there can be an unlimited count of emails per contacts.

Select distinct nickname, title, firstname, middlename, lastname, suffix,
profession, b_webpage, company, office, department, jobtitle, default_email,
cpn1.phone_number as Home_Phone,
cpn2.phone_number as Home_Mobile,
cpn3.phone_number as Home_VOIP,
cpn4.phone_number as Home_Fax,
cpn5.phone_number as Business_Phone,
cpn6.phone_number as Business_Mobile,
cpn7.phone_number as Business_VOIP,
cpn8.phone_number as Business_Fax,
cpn9.phone_number as Business_Pager,
h_webpage, spouse, gender, birthday, anniversary from contacts

left outer join contactphonenumbers as cpn1
on contacts.recid=cpn1.recid and cpn1.phone_type=1

left outer join contactphonenumbers as cpn2
on contacts.recid=cpn2.recid and cpn2.phone_type=257

left outer join contactphonenumbers as cpn3
on contacts.recid=cpn3.recid and cpn3.phone_type=769

left outer join contactphonenumbers as cpn4
on contacts.recid=cpn4.recid and cpn4.phone_type=513

left outer join contactphonenumbers as cpn5
on contacts.recid=cpn5.recid and cpn5.phone_type=2

left outer join contactphonenumbers as cpn6
on contacts.recid=cpn6.recid and cpn6.phone_type=258

left outer join contactphonenumbers as cpn7
on contacts.recid=cpn7.recid and cpn7.phone_type=770

left outer join contactphonenumbers as cpn8
on contacts.recid=cpn8.recid and cpn8.phone_type=514

left outer join contactphonenumbers as cpn9
on contacts.recid=cpn9.recid and cpn9.phone_type=1026;

I needed the vcf file for other purposes and found a script [1] on SF.net to convert a tab seperated value to a vcf file. So I used this ugly thing:


sqlite3 ~/Applications/Qtopia/qtopia_db.sqlite $1 'Select distinct firstname, lastname, middlename,
nickname, default_email,title,
cpn5.phone_number as Business_Phone,
cpn1.phone_number as Home_Phone,
cpn8.phone_number as Business_Fax,
cpn9.phone_number as Business_Pager,
cpn2.phone_number as Home_Mobile from contacts
left outer join contactphonenumbers as cpn1
on contacts.recid=cpn1.recid and cpn1.phone_type=1
left outer join contactphonenumbers as cpn2
on contacts.recid=cpn2.recid and cpn2.phone_type=257
left outer join contactphonenumbers as cpn3
on contacts.recid=cpn3.recid and cpn3.phone_type=769
left outer join contactphonenumbers as cpn4
on contacts.recid=cpn4.recid and cpn4.phone_type=513
left outer join contactphonenumbers as cpn5
on contacts.recid=cpn5.recid and cpn5.phone_type=2
left outer join contactphonenumbers as cpn6
on contacts.recid=cpn6.recid and cpn6.phone_type=258
left outer join contactphonenumbers as cpn7
on contacts.recid=cpn7.recid and cpn7.phone_type=770
left outer join contactphonenumbers as cpn8
on contacts.recid=cpn8.recid and cpn8.phone_type=514
left outer join contactphonenumbers as cpn9
on contacts.recid=cpn9.recid and cpn9.phone_type=1026;'| sed 's/|/\t/g' > addressbook.tsv

put the output through tsv2vcf:

perl tsv2vcf addressbook.tsv addressbook.vcf

and got a usable vcf File, with some problems with special chars.

[edit] Export raw config (including contacts) with Qtopia

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.

[edit] Import and export for 2007.2

[edit] 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).

[edit] 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

[edit] 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

[edit] 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

[edit] 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

[edit] 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


[edit] 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.

Personal tools

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.

Exporting old contacts to VCard format

To use the import tools you need your Contacts in VCF format.

  1. On nokia phones use the Nokia phone manager Citation needed
  1. On windows mobile phones you could use active sync to sync with Outlook and then use a Outlook export plugin to export as vcf
  2. On LG phones the backup function to memory card creates one file with multiple VCards

Exporting from Outlook / ActiveSync to VCF

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.)

Export vCards from Mac OS X Addressbook

  1. Set the vCard Format to 2.1 in the config dialog
  2. Select all contacts and say "export vcard"
  3. Despite having selected the charset to be utf-8 you may need to do:

iconv -f latin1 -t utf-8 vCards.vcf | sed 's/CHARSET=LATIN1://g' > all.vcf

Import on Om 2008.8 and 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.

On Om 2008.8

  • Install sqlite3
  • Open the database
  • Delete all data from the contacts tables This will erase all your contacts and contact categories.
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.

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

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.