From b56cf72c87c42cdc49d619bf3f147f1708bc3983 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 1 Apr 2025 19:42:26 +0000 Subject: [PATCH] api: add legacy Python bindings for make_vcard and import_vcard --- python/src/deltachat/account.py | 5 +++++ python/src/deltachat/contact.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index f78013962..6003e4a5e 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -368,6 +368,11 @@ class Account: dc_array = ffi.gc(lib.dc_get_contacts(self._dc_context, flags, query_c), lib.dc_array_unref) return list(iter_array(dc_array, lambda x: Contact(self, x))) + def import_vcard(self, vcard): + """Import a vCard and return an array of contacts.""" + dc_array = ffi.gc(lib.dc_import_vcard(self._dc_context, as_dc_charpointer(vcard)), lib.dc_array_unref) + return list(iter_array(dc_array, lambda x: Contact(self, x))) + def get_fresh_messages(self) -> Generator[Message, None, None]: """yield all fresh messages from all chats.""" dc_array = ffi.gc(lib.dc_get_fresh_msgs(self._dc_context), lib.dc_array_unref) diff --git a/python/src/deltachat/contact.py b/python/src/deltachat/contact.py index e28a31178..fc5713d61 100644 --- a/python/src/deltachat/contact.py +++ b/python/src/deltachat/contact.py @@ -90,6 +90,14 @@ class Contact: dc_res = lib.dc_contact_get_profile_image(self._dc_contact) return from_optional_dc_charpointer(dc_res) + def make_vcard(self) -> str: + """Make a contact vCard. + + :returns: vCard + """ + dc_context = self.account._dc_context + return from_dc_charpointer(lib.dc_make_vcard(dc_context, self.id)) + @property def status(self): """Get contact status.