Saturday, January 30, 2010

Import/sync N78 contacts into/with Evolution

Backup N78 contacts via vcard

In address book of N78, contacts can be backupped from phone to memory card via menu. By default the backupped contacts is saved in Others/Contacts directory of micro-SD card. There is one vcard file (.vcf) for one contact.

Import vcard into Evolution

Vcard can be imported into Evolution, but only one vcard file once. To import vcard files generated by N78, the vcard files from N78 can be catenated into one vcard file, then imported into Evolution.

The vcard file generated by N78 is compatible with Evolution, that is, all information can be imported properly so far. But some information is not displayed in Evolution, and not available when accessed via python-evolution (should be not available in other libedata client too). After changing any field then change back to original value and save the "changes", evething goes OK. Appears a BUG of Evolution, hopes that can be fixed in the future.

Multple contacts in Evolution can exported into one vcard file too. Just select multiple contacts, then click "Save Contact as VCard" in menu, Or save all contacts in one address book with "Save Address Book as VCard".

Import vcard into Evolution via python

Because of the BUG of Evolution vcard importing, I try python-evolution and python-vobject to import N78 vcards into Evolution.

python-vobject is not completely compatible with the vcard 2.1 version, which is used by N78. This can be fixed with simple python scripting or via importing vcards into Evolution then exporting them because Evolution will export vcard 3.0 version file.

This method works good for me. But I encountered one issue too, the address can not be imported because EContactAddress is not wrapped properly in python-evolution yet. Hope that will be resolved in the future. Fortunately, there is only one not so important contact in my N78 address book has address field set.

Import vcard into Evolution via opensync

msynctool --addgroup evo2-file
msynctool --addmember evo2-file evo2-sync
msynctool --addmember evo2-file file-sync
msynctool --configure evo2-file 1
#
# You can keep it as default or use the address book URL in <address_path>
#
msynctool --configure evo2-file 2
#
# Set directory hold the vcard files from N78 in <path>
#

There is issue for this method too. Some information such as phone number is not displayed in imported Evolution contacts, similar with importing vcard with Evolution itself, and can be fixed in same way too. But situation is much better here, that is, more information can be displayed, at least one phone number for each contact.

Bidirectional synchronization with Evolution via opensync

After testing, I found N78 can be bidirectionally synchronized with Evolution via N78 syncml over USB. But again, there is some issues for method too. Like file-Evolution sync via opensync, some information can not be displayed correctly. But among supported object type, contact has the best support, then calendar and task, but notes must be turned off, or opensync will hang.

Firstly, setup USB device file permission for opensync user space driver. Add following lines into udev rules file or put into a rule file under rules.d directory of udev.

BUS=="usb", SYSFS{idProduct}=="007b", SYSFS{idVendor}=="0421", MODE="660", GROUP="plugdev"

Command line as follow can be used to test the USB link.

syncml-obex-client -u
# Found 2 USB OBEX interfaces
# Interface 0:
# Manufacturer: Nokia
# Product: N78
# Interface description: SYNCML-SYNC
# Interface 1:
# Manufacturer: Nokia
# Product: N78
# Interface description: PC Suite Services
syncml-obex-client -u 0 --identifier "PC Suite" --slow-sync text/x-vcard Contacts --wbxml
syncml-obex-client -u 0 --identifier "PC Suite" --slow-sync text/x-vcalendar Calendar --wbxml
syncml-obex-client -u 0 --identifier "PC Suite" --slow-sync text/plain Notes --wbxml

Command line for setup is as follow.

msynctool --addgroup n78-evo2
msynctool --addmember n78-evo2 syncml-obex-client
msynctool --addmember n78-evo2 evo2-sync
msynctool --configure n78-evo2 1
msynctool --configure n78-evo2 2
#
# You can keep it as default or use the address book URL in <address_path>
#

syncml-obex-client configuration is as follow. The notes database name should be left as empty, because notes synchronization for Evolution is not supported, opensync will hang if you set notes database name.

<?xml version="1.0"?>
<config>
<!-- (Only for bluetooth) The bluetooth address if the bluetooth mode is selected -->
<bluetooth_address></bluetooth_address>

<!-- (Only for bluetooth) The bluetooth channel to use. `sdptool browse $MAC` to search for the correct channel -->
<bluetooth_channel></bluetooth_channel>

<!-- (Only for USB) The usb interface number of the SYNCML-SYNC target. use syncml-obex-client -u (you will need access to the USB raw device) to find it. -->
<interface>0</interface>

<!-- The string that the plugin will use to identify itself. Some devices need a special string here. -->
<identifier>PC Suite</identifier>

<!-- The syncml version to use: 0 for 1.0, 1 for 1.1 and 2 for 1.2 -->
<version>1</version>

<!-- if the plugin should use wbxml -->
<wbxml>1</wbxml>

<!-- The username to use. Leave empty to not require a username -->
<username></username>

<!-- the password for the username -->
<password></password>

<!-- sets the connection type to use. 5 means obex over usb, 2 means obex over bluetooth -->
<type>5</type>

<!-- If wbxml is enabled, defines wether the wbxml should use string tables -->
<usestringtable>0</usestringtable>

<!-- Never send ADD command, but send REPLACE (not needed normally) -->
<onlyreplace>0</onlyreplace>

<!-- Workaround around for mobile phones which only use local timestamps and _no_ UTC timestamps! -->
<onlyLocaltime>0</onlyLocaltime>

<!-- Sets the maximum allowed size in bytes of incoming messages (some device need this option set). Example: 10000 -->
<recvLimit>0</recvLimit>

<maxObjSize>0</maxObjSize>

<!-- The name of the contacts db. Must be the same as the phones sends -->
<contact_db>Contacts</contact_db>

<!-- The name of the calendar db. Must be the same as the phones sends -->
<calendar_db>Calendar</calendar_db>

<!-- The name of the note db. Must be the same as the phones sends -->
<note_db></note_db>
</config>

Google Mobile Sync

The last and the best so far. I use it now. The best features of this method are as follow:

  • Works good so far, although some information is not displayed inEvolution, similar with other Evolution importing method.
  • Synchronizing automatically, periodically.
  • Wireless, Evolution side uses WIFI, and N78 side uses GPRS (because my N78 has no WIFI). Some methods above can be done in wireless way too, such as with bluetooth, with some additional work.
  • You need not keep both PC and N78 on for synchronization, because you have the third side now, the Google, in other word, the cloud.

To setup N78 side, you can refer to: Nokia Setup Instructions for Google Mobile Sync.

To setup Evolution side, you can refer to: How to sync Evolution with Google's PIM apps.

No comments: