New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue: Allow to share contacts as vCards #5422
Comments
fn create_vcard(contact_id: ContactId, additional_keys: Option<Hashmap<String, String>>)
|
What does |
@Simon-Laux @link2xt Probably it makes sense if |
Should we use a crate to parse the vCards, or parse and create vCards manually?1. Use
|
I would like to implement #5422 in its own crate, but it will depend on some functions that are in the `deltachat` crate. So, this PR extracts these functions into its own crate so that I can add https:////github.com//issues/5422 into the new crate.
I would like to implement #5422 in its own crate, but it will depend on some functions that are in the `deltachat` crate. So, this PR extracts these functions into its own crate so that I can add https:////github.com//issues/5422 into the new crate.
Problem with rolling out our own parsing that can only parse a small subset of vcards created by Delta Chat itself is that we cannot use it to import .vcf generated by android contacts application for #5202 If |
I just tried it out, and it's actually the other way round: I exported a .vcf file generated by my android contacts application and tried to parse it with both my hand-written "parser" (not sure if you can call it a parser, it's really simple, just searching through the file for the lines we need) and my code using ical. My own "parser" successfully extracted the name and email address, while Details
Code to test: #[test]
fn test_android_contact_export() {
let contacts = parse_vcard(
"BEGIN:VCARD
VERSION:2.1
N:;Bob;;;
FN:Bob
TEL;CELL:+1-234-567-890
EMAIL;HOME:bob@example.org
END:VCARD
BEGIN:VCARD
VERSION:2.1
N:;Alice;;;
FN:Alice
EMAIL;HOME:alice@example.org
END:VCARD
"
.to_string(),
)
.unwrap();
assert_eq!(contacts[0].addr, "bob@example.org".to_string());
assert_eq!(contacts[0].display_name, "Bob".to_string());
assert_eq!(contacts[0].key, "".to_string());
assert_eq!(contacts[0].profile_photo, "".to_string());
assert_eq!(contacts[1].addr, "alice@example.org".to_string());
assert_eq!(contacts[1].display_name, "Alice".to_string());
assert_eq!(contacts[1].key, "".to_string());
assert_eq!(contacts[1].profile_photo, "".to_string());
assert_eq!(contacts.len(), 2);
} With the code from #5482, it succeeds, with the code using
(it doesn't like the I pushed it to
This seems like a huge task, because there were multiple problems all of which we would need to fix, and if we want to contribute upstream then we don't only have to grep for the lines that are interesting for us, but actually parse it. |
Tracking issue for sending a contact via Delta Chat, you probably know it from other messengers:
Motivation
Problem:
Solution:
API design and implementation steps
From an a/v with @hpk42:
parse_vcard()
, takes a file and returns a list, the UI can just show the first vCard for now (also see vCard-based address book import API #5202)create_vcard()
, takes a contact and returns a file (also see vCard-based address book export API #5203)Rationale:
parse_vcard()
directly create a hidden contact and then giving the contact id to the UI. Then opening a chat in which we received a vCard would have the sideeffect of creating a contact in the db, and if the user then later writes to this contact then the information we received would be reused - not a huge problem, but also not 100% nice.parse_vcard()
will still return a list so that UIs later have the possibility to show multiple vCard's without another API change.Questions and design choices
For each point, I specified which solution I prefer; if noone objects, we'll go with my preferred solutions
import_vcard()
, which would then be the same as vCard-based address book import API #5202import_vcard()
and then show a dialog that edits the contact (in fact, it can just open the "edit contact" activity we already have)parse_vcard()
could directly save the peerstate, which would letparse_vcard()
have a side effect.parse_vcard()
has side effectscreate_vcard()
- a contact id? A json struct with all the fields?create_vcard()
takes a single contact. However, looking at vCard-based address book export API #5203, it may still be nice to take a list of contact ids so that we don't need another API for that.create_vcard()
andparse_vcard()
more symmetriccreate_vcard()
return? A filename, a vCard as text, set as draft?parse_vcard()
take? A filename, a vCard as text, a message id?create_vcard()
The text was updated successfully, but these errors were encountered: