From 1590b294ada703e500492fe7e66be78d11854783 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 29 Jun 2016 16:31:18 +0200 Subject: [PATCH] Improved performances related to vCard parsing --- coreapi/carddav.c | 2 +- coreapi/friend.c | 14 +++++++----- coreapi/friendlist.c | 4 ++-- coreapi/linphonecore.c | 6 ++++++ coreapi/private.h | 6 ++++++ coreapi/vcard.cc | 49 +++++++++++++++++++++++++++++++----------- coreapi/vcard.h | 11 +++++++--- coreapi/vcard_stubs.c | 26 +++++++++++++++++++--- tester/vcard_tester.c | 35 +++++++++++++++++++----------- 9 files changed, 115 insertions(+), 38 deletions(-) diff --git a/coreapi/carddav.c b/coreapi/carddav.c index e6aef80be..d63b20861 100644 --- a/coreapi/carddav.c +++ b/coreapi/carddav.c @@ -115,7 +115,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li while (vCards) { LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data; if (vCard) { - LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(vCard->vcard); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard); LinphoneFriend *lf = NULL; bctbx_list_t *local_friend = NULL; diff --git a/coreapi/friend.c b/coreapi/friend.c index 415bbc1ee..af6b511d8 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1250,12 +1250,13 @@ static int create_friend_list(void *data, int argc, char **argv, char **colName) * | 9 | presence_received */ static int create_friend(void *data, int argc, char **argv, char **colName) { - bctbx_list_t **list = (bctbx_list_t **)data; + LinphoneVcardContext *context = (LinphoneVcardContext *)data; + bctbx_list_t **list = (bctbx_list_t **)linphone_vcard_context_get_user_data(context); LinphoneFriend *lf = NULL; LinphoneVcard *vcard = NULL; unsigned int storage_id = (unsigned int)atoi(argv[0]); - vcard = linphone_vcard_new_from_vcard4_buffer(argv[6]); + vcard = linphone_vcard_new_from_vcard4_buffer(context, argv[6]); if (vcard) { linphone_vcard_set_etag(vcard, argv[7]); linphone_vcard_set_url(vcard, argv[8]); @@ -1281,10 +1282,10 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { #pragma GCC diagnostic pop #endif -static int linphone_sql_request_friend(sqlite3* db, const char *stmt, bctbx_list_t **list) { +static int linphone_sql_request_friend(sqlite3* db, const char *stmt, LinphoneVcardContext *context) { char* errmsg = NULL; int ret; - ret = sqlite3_exec(db, stmt, create_friend, list, &errmsg); + ret = sqlite3_exec(db, stmt, create_friend, context, &errmsg); if (ret != SQLITE_OK) { ms_error("linphone_sql_request: statement %s -> error sqlite3_exec(): %s.", stmt, errmsg); sqlite3_free(errmsg); @@ -1448,11 +1449,13 @@ bctbx_list_t* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFrie ms_warning("Either lc (or list) is NULL or friends database wasn't initialized with linphone_core_friends_storage_init() yet"); return NULL; } + + linphone_vcard_context_set_user_data(lc->vcard_context, &result); buf = sqlite3_mprintf("SELECT * FROM friends WHERE friend_list_id = %u ORDER BY id", list->storage_id); begin = ortp_get_cur_time_ms(); - linphone_sql_request_friend(lc->friends_db, buf, &result); + linphone_sql_request_friend(lc->friends_db, buf, lc->vcard_context); end = ortp_get_cur_time_ms(); ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)bctbx_list_size(result), (int)(end-begin)); sqlite3_free(buf); @@ -1462,6 +1465,7 @@ bctbx_list_t* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFrie lf->lc = lc; lf->friend_list = list; } + linphone_vcard_context_set_user_data(lc->vcard_context, NULL); return result; } diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index b28af36de..cf1b6a456 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -781,7 +781,7 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis return -1; } - vcards = linphone_vcard_list_from_vcard4_file(vcard_file); + vcards = linphone_vcard_list_from_vcard4_file(list->lc->vcard_context, vcard_file); vcards_iterator = vcards; if (!vcards) { ms_error("Failed to parse the file %s", vcard_file); @@ -820,7 +820,7 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l return -1; } - vcards = linphone_vcard_list_from_vcard4_buffer(vcard_buffer); + vcards = linphone_vcard_list_from_vcard4_buffer(list->lc->vcard_context, vcard_buffer); vcards_iterator = vcards; if (!vcards) { ms_error("Failed to parse the buffer"); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e6cbdc451..317a87a16 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1826,6 +1826,8 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab sqlite3_bctbx_vfs_register(0); #endif + lc->vcard_context = linphone_vcard_context_new(); + remote_provisioning_uri = linphone_core_get_provisioning_uri(lc); if (remote_provisioning_uri == NULL) { linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL); @@ -6488,6 +6490,10 @@ void sip_config_uninit(LinphoneCore *lc) } #endif + if (lc->vcard_context) { + linphone_vcard_context_destroy(lc->vcard_context); + } + sal_reset_transports(lc->sal); sal_unlisten_ports(lc->sal); /*to make sure no new messages are received*/ if (lc->http_provider) { diff --git a/coreapi/private.h b/coreapi/private.h index e0ca97b0a..7caf85c0d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1025,6 +1025,7 @@ struct _LinphoneCore jmethodID multicast_lock_acquire_id; jmethodID multicast_lock_release_id; #endif + LinphoneVcardContext *vcard_context; }; @@ -1554,6 +1555,11 @@ char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ; void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite); +LinphoneVcardContext* linphone_vcard_context_new(void); +void linphone_vcard_context_destroy(LinphoneVcardContext *context); +void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context); +void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data); + #ifdef __cplusplus } #endif diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index b4b566d89..388422915 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -23,6 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sal/sal.h" #include +struct _LinphoneVcardContext { + belcard::BelCardParser *parser; + void *user_data; +}; + struct _LinphoneVcard { shared_ptr belCard; char *etag; @@ -34,6 +39,29 @@ struct _LinphoneVcard { extern "C" { #endif +LinphoneVcardContext* linphone_vcard_context_new(void) { + LinphoneVcardContext* context = ms_new0(LinphoneVcardContext, 1); + context->parser = new belcard::BelCardParser(); + context->user_data = NULL; + return context; +} + +void linphone_vcard_context_destroy(LinphoneVcardContext *context) { + if (context) { + if (context->parser) delete context->parser; + ms_free(context); + } +} + +void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) { + return context ? context->user_data : NULL; +} + + +void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) { + if (context) context->user_data = data; +} + LinphoneVcard* linphone_vcard_new(void) { LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1); vCard->belCard = belcard::BelCardGeneric::create(); @@ -54,10 +82,10 @@ void linphone_vcard_free(LinphoneVcard *vCard) { ms_free(vCard); } -bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { +bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) { bctbx_list_t *result = NULL; - if (filename) { - belcard::BelCardParser *parser = new belcard::BelCardParser(); + if (context && filename) { + belcard::BelCardParser *parser = context->parser; shared_ptr belCards = parser->parseFile(filename); if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { @@ -66,15 +94,14 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { result = bctbx_list_append(result, vCard); } } - delete(parser); } return result; } -bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { +bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { bctbx_list_t *result = NULL; - if (buffer) { - belcard::BelCardParser *parser = new belcard::BelCardParser(); + if (context && buffer) { + belcard::BelCardParser *parser = context->parser; shared_ptr belCards = parser->parse(buffer); if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { @@ -83,22 +110,20 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { result = bctbx_list_append(result, vCard); } } - delete(parser); } return result; } -LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { +LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { LinphoneVcard *vCard = NULL; - if (buffer) { - belcard::BelCardParser *parser = new belcard::BelCardParser(); + if (context && buffer) { + belcard::BelCardParser *parser = context->parser; shared_ptr belCard = parser->parseOne(buffer); if (belCard) { vCard = linphone_vcard_new_from_belcard(belCard); } else { ms_error("Couldn't parse buffer %s", buffer); } - delete(parser); } return vCard; } diff --git a/coreapi/vcard.h b/coreapi/vcard.h index dc0e6db3b..62674a33d 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -36,6 +36,11 @@ extern "C" * @{ */ +/** + * Linphone vCard context object. + */ +typedef struct _LinphoneVcardContext LinphoneVcardContext; + /** * The LinphoneVcard object. */ @@ -57,21 +62,21 @@ LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard); * @param[in] file the path to the file to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *file); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *file); /** * Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none. * @param[in] buffer the buffer to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer); /** * Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise. * @param[in] buffer the buffer to parse * @return a LinphoneVcard if one could be parsed, or NULL otherwise */ -LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer); +LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer); /** * Returns the vCard4 representation of the LinphoneVcard. diff --git a/coreapi/vcard_stubs.c b/coreapi/vcard_stubs.c index 0a0fa20ae..50a8fc2e9 100644 --- a/coreapi/vcard_stubs.c +++ b/coreapi/vcard_stubs.c @@ -19,6 +19,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "vcard.h" +struct _LinphoneVcardContext { + void *dummy; +}; + +LinphoneVcardContext* linphone_vcard_context_new(void) { + return NULL; +} + +void linphone_vcard_context_destroy(LinphoneVcardContext *context) { + +} + +void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) { + return NULL; +} + +void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data) { + +} + struct _LinphoneVcard { void *dummy; }; @@ -31,15 +51,15 @@ void linphone_vcard_free(LinphoneVcard *vCard) { } -MSList* linphone_vcard_list_from_vcard4_file(const char *filename) { +MSList* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) { return NULL; } -MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { +MSList* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { return NULL; } -LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { +LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { return NULL; } diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 205dfa98c..28631db1f 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -137,7 +137,8 @@ static void linphone_vcard_update_existing_friends_test(void) { #endif static void linphone_vcard_phone_numbers_and_sip_addresses(void) { - LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n"); + LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf); bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf); @@ -149,7 +150,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { if (phone_numbers) bctbx_list_free(phone_numbers); linphone_friend_unref(lf); - lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n"); + lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n"); lf = linphone_friend_new_from_vcard(lvc); sip_addresses = linphone_friend_get_addresses(lf); phone_numbers = linphone_friend_get_phone_numbers(lf); @@ -191,6 +192,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { linphone_friend_unref(lf); lf = NULL; lvc = NULL; + linphone_core_manager_destroy(manager); } #ifdef SQLITE_STORAGE_ENABLED @@ -274,6 +276,7 @@ static void friends_sqlite_storage(void) { bctbx_list_t *friends_lists_from_db = NULL; char *friends_db = bc_tester_file("friends.db"); LinphoneFriendListStats *stats = (LinphoneFriendListStats *)ms_new0(LinphoneFriendListStats, 1); + char *address = NULL, *address2 = NULL; v_table->friend_list_created = friend_list_created_cb; v_table->friend_list_removed = friend_list_removed_cb; @@ -326,7 +329,11 @@ static void friends_sqlite_storage(void) { BC_ASSERT_EQUAL(lf2->storage_id, lf->storage_id, unsigned int, "%u"); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_etag(linphone_friend_get_vcard(lf2)), linphone_vcard_get_etag(linphone_friend_get_vcard(lf))); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_url(linphone_friend_get_vcard(lf2)), linphone_vcard_get_url(linphone_friend_get_vcard(lf))); - BC_ASSERT_STRING_EQUAL(linphone_address_as_string(linphone_friend_get_address(lf2)), linphone_address_as_string(linphone_friend_get_address(lf))); + address = linphone_address_as_string(linphone_friend_get_address(lf)); + address2 = linphone_address_as_string(linphone_friend_get_address(lf2)); + BC_ASSERT_STRING_EQUAL(address2, address); + ms_free(address); + ms_free(address2); linphone_friend_edit(lf); linphone_friend_set_name(lf, "Margaux"); @@ -357,6 +364,7 @@ end: ms_free(friends_db); linphone_address_unref(addr); linphone_core_destroy(lc); + linphone_core_v_table_destroy(v_table); } #endif @@ -465,7 +473,7 @@ static void carddav_sync_2(void) { static void carddav_sync_3(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); - LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n"); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:sylvain@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); char *friends_db = bc_tester_file("friends.db"); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); @@ -506,7 +514,7 @@ static void carddav_sync_3(void) { static void carddav_sync_4(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); - LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; @@ -567,13 +575,14 @@ static void carddav_sync_status_changed(LinphoneFriendList *list, LinphoneFriend static void carddav_integration(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); - LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); + LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); LinphoneVcard *lvc2 = NULL; LinphoneFriend *lf2 = NULL; LinphoneFriendListCbs *cbs = NULL; LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); const char *refkey = "toto"; + char *address = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); cbs = linphone_friend_list_get_callbacks(lfl); @@ -599,12 +608,12 @@ static void carddav_integration(void) { linphone_friend_unref(lf); lf = NULL; - lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n"); + lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n"); lf = linphone_friend_new_from_vcard(lvc); BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); linphone_friend_unref(lf); - lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); + lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf"); lf2 = linphone_friend_new_from_vcard(lvc2); linphone_friend_set_ref_key(lf2, refkey); @@ -627,7 +636,9 @@ static void carddav_integration(void) { BC_ASSERT_STRING_EQUAL(lf->refkey, refkey); BC_ASSERT_EQUAL(lf->storage_id, lf2->storage_id, unsigned int, "%u"); linphone_friend_unref(lf2); - BC_ASSERT_STRING_EQUAL(linphone_address_as_string_uri_only(lf->uri), "sip:sylvain@sip.linphone.org"); + address = linphone_address_as_string_uri_only(lf->uri); + BC_ASSERT_STRING_EQUAL(address, "sip:sylvain@sip.linphone.org"); + ms_free(address); linphone_friend_edit(lf); linphone_friend_done(lf); @@ -680,7 +691,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test } bctbx_list_free(friends); - lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); + lvc = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf"); lf = linphone_friend_new_from_vcard(lvc); linphone_friend_list_add_friend(lfl, lf); @@ -728,9 +739,9 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) { LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); - LinphoneVcard *lvc1 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); + LinphoneVcard *lvc1 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:margaux@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1); - LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n"); + LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2); bctbx_list_t *friends = NULL, *friends_iterator = NULL;