From f6edea6eec1678dccb4f168e6baa6fd55890b3b7 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 15 Dec 2015 17:13:00 +0100 Subject: [PATCH] Use linphone_core_get_friend_list to ease future merge with friends lists + added method to add SIP address into vCard --- coreapi/friend.c | 2 +- coreapi/vcard.cc | 6 ++++++ coreapi/vcard.h | 29 ++++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index ef65b55db..1c173aba9 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -836,7 +836,7 @@ int linphone_core_import_friends_from_vcard4_file(LinphoneCore *lc, const char * void linphone_core_export_friends_as_vcard4_file(LinphoneCore *lc, const char *vcard_file) { FILE *file = NULL; - MSList *friends = lc->friends; + const MSList *friends = linphone_core_get_friend_list(lc); file = fopen(vcard_file, "w"); if (file == NULL) { diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index d5c22e76f..7e049f87d 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -98,6 +98,12 @@ extern "C" const char* linphone_vcard_get_full_name(const LinphoneVCard *vCard) return result; } +extern "C" void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_address) { + shared_ptr impp = belcard::BelCardGeneric::create(); + impp->setValue(sip_address); + vCard->belCard->addImpp(impp); +} + extern "C" MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard) { MSList *result = NULL; for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { diff --git a/coreapi/vcard.h b/coreapi/vcard.h index e45dc01a5..ac3f4d296 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -45,9 +45,9 @@ LINPHONE_PUBLIC LinphoneVCard* linphone_vcard_new(void); /** * Deletes a LinphoneVCard object properly - * @param[in] vcard the LinphoneVCard to destroy + * @param[in] vCard the LinphoneVCard to destroy */ -LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVCard *vcard); +LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVCard *vCard); /** * Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVCards, or NULL if it contains none. @@ -72,31 +72,38 @@ LINPHONE_PUBLIC LinphoneVCard* linphone_vcard_new_from_vcard4_buffer(const char /** * Returns the vCard4 representation of the LinphoneVCard. - * @param[in] vcard the LinphoneVCard - * @return a const char * that represents the vcard + * @param[in] vCard the LinphoneVCard + * @return a const char * that represents the vCard */ -LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVCard *vcard); +LINPHONE_PUBLIC const char* linphone_vcard_as_vcard4_string(LinphoneVCard *vCard); /** * Sets the FN attribute of the vCard (which is mandatory). - * @param[in] vcard the LinphoneVCard + * @param[in] vCard the LinphoneVCard * @param[in] name the display name to set for the vCard */ -LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVCard *vcard, const char *name); +LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVCard *vCard, const char *name); /** * Returns the FN attribute of the vCard, or NULL if it isn't set yet. - * @param[in] vcard the LinphoneVCard + * @param[in] vCard the LinphoneVCard * @return the display name of the vCard, or NULL */ -LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVCard *vcard); +LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVCard *vCard); + +/** + * Adds a SIP address in the vCard, using the IMPP property + * @param[in] vCard the LinphoneVCard + * @param[in] sip_address the SIP address to add + */ +LINPHONE_PUBLIC void linphone_vcard_add_sip_address(LinphoneVCard *vCard, const char *sip_address); /** * Returns the list of SIP addresses (as const char *) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL - * @param[in] vcard the LinphoneVCard + * @param[in] vCard the LinphoneVCard * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vcard); +LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVCard *vCard); /** * @}