Skip to content

vCard-based address book import API #5202

@link2xt

Description

@link2xt

We have several issues and forum discussions related to contact sharing, export and import. There is generally an agreement to use vCard because it is supported by at least Android Contacts application and Thunderbird, but no plan to introduce it or API design.

Current contact import API is dc_add_address_book. It takes input in an ad-hoc text format where each contact is represented as a line containing contact display name followed by the line containing contact email address. Call returns the number of imported contacts which can be displayed in a dialog on success. Android UI currently iterates over contacts returned by Contacts Provider to construct dc_add_address_book input.

This issue is a proposal to add similar API dc_add_vcard_contacts accepting a single string consisting of vCards concatenated together like in .vcf file generated by Android Contacts or Thunderbird. Android Contacts Provider has APIs to provide vCard: https://developer.android.com/reference/android/provider/ContactsContract.Contacts#CONTENT_MULTI_VCARD_URI Besides that, vCards may be imported in the UI by selecting a file or drag-and-dropping a .vcf file. Reading the file contents should be done by the UI in this case to avoid adding more APIs accepting filenames which may be problematic when running the core sandboxed, dealing with OS-specific permissions and portals etc.

As a first step a JSON-RPC API with a test being able to import email addresses and display names from .vcf files exported from Thunderbird and Android is enough. Next step is to be able to read KEY:data:application/pgp-keys;base64,... key and apply it as a gossiped key if we don't have a peerstate for the contact yet, see https://datatracker.ietf.org/doc/html/rfc6350#section-6.8.1 How to treat the key if we already have a peerstate is not clear, but for now it is safe to ignore it then. We can always change this behavior later based on how we implement contact export and contact sharing.

Exporting vCards, sharing contacts as vCards, storing additional fields like phone number in Delta Chat address book etc. is outside of the scope of this issue.

There is a closed PR with an attempt to encode avatars as vCards: #1279 It is closed without merging because we decided to gossip avatars via invisible headers, but the code can be looked up for an example of using ical crate for parsing. Other vCard-parsing crates may be evaluated, but this one has already been lightly tested, has good stats on crates.io and is maintained, so should be good enough.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions