From c8ae29742aee37727658df310f3be603d216c499 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 1 Jul 2016 10:34:16 +0200 Subject: [PATCH 01/30] Moved and renamed some vcard methods for python wrapper --- coreapi/carddav.c | 2 +- coreapi/friend.c | 2 +- coreapi/friendlist.c | 4 ++-- coreapi/private.h | 5 ----- coreapi/vcard.cc | 26 ++++++++++++++++---------- coreapi/vcard.h | 38 ++++++++++++++++++++++++++++++++++---- coreapi/vcard_stubs.c | 8 ++++---- tester/vcard_tester.c | 20 ++++++++++---------- 8 files changed, 68 insertions(+), 37 deletions(-) diff --git a/coreapi/carddav.c b/coreapi/carddav.c index d63b20861..63b22c6bd 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(cdc->friend_list->lc->vcard_context, vCard->vcard); + LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_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 af6b511d8..896e4cab5 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1256,7 +1256,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { LinphoneVcard *vcard = NULL; unsigned int storage_id = (unsigned int)atoi(argv[0]); - vcard = linphone_vcard_new_from_vcard4_buffer(context, argv[6]); + vcard = linphone_vcard_context_get_vcard_from_buffer(context, argv[6]); if (vcard) { linphone_vcard_set_etag(vcard, argv[7]); linphone_vcard_set_url(vcard, argv[8]); diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index cf1b6a456..a63992e3d 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(list->lc->vcard_context, vcard_file); + vcards = linphone_vcard_context_get_vcard_list_from_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(list->lc->vcard_context, vcard_buffer); + vcards = linphone_vcard_context_get_vcard_list_from_buffer(list->lc->vcard_context, vcard_buffer); vcards_iterator = vcards; if (!vcards) { ms_error("Failed to parse the buffer"); diff --git a/coreapi/private.h b/coreapi/private.h index 7caf85c0d..b4ed35089 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1555,11 +1555,6 @@ 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 388422915..f944ad07c 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -53,7 +53,7 @@ void linphone_vcard_context_destroy(LinphoneVcardContext *context) { } } -void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) { +void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) { return context ? context->user_data : NULL; } @@ -82,11 +82,13 @@ void linphone_vcard_free(LinphoneVcard *vCard) { ms_free(vCard); } -bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) { +bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) { bctbx_list_t *result = NULL; if (context && filename) { - belcard::BelCardParser *parser = context->parser; - shared_ptr belCards = parser->parseFile(filename); + if (!context->parser) { + context->parser = new belcard::BelCardParser(); + } + shared_ptr belCards = context->parser->parseFile(filename); if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); @@ -98,11 +100,13 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context return result; } -bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { +bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) { bctbx_list_t *result = NULL; if (context && buffer) { - belcard::BelCardParser *parser = context->parser; - shared_ptr belCards = parser->parse(buffer); + if (!context->parser) { + context->parser = new belcard::BelCardParser(); + } + shared_ptr belCards = context->parser->parse(buffer); if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); @@ -114,11 +118,13 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *conte return result; } -LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { +LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) { LinphoneVcard *vCard = NULL; if (context && buffer) { - belcard::BelCardParser *parser = context->parser; - shared_ptr belCard = parser->parseOne(buffer); + if (!context->parser) { + context->parser = new belcard::BelCardParser(); + } + shared_ptr belCard = context->parser->parseOne(buffer); if (belCard) { vCard = linphone_vcard_new_from_belcard(belCard); } else { diff --git a/coreapi/vcard.h b/coreapi/vcard.h index 62674a33d..550fa8d81 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -37,10 +37,36 @@ extern "C" */ /** - * Linphone vCard context object. + * The LinphoneVcardContext object. */ typedef struct _LinphoneVcardContext LinphoneVcardContext; +/** + * Creates a vCard context to reuse the same BelCardParser object + * @return a new LinphoneVcardContext object + */ +LINPHONE_PUBLIC LinphoneVcardContext* linphone_vcard_context_new(void); + +/** + * Destroys the vCard context + * @param[in] context a LinphoneVcardContext object + */ +LINPHONE_PUBLIC void linphone_vcard_context_destroy(LinphoneVcardContext *context); + +/** + * Gets the user data set in the LinphoneVcardContext + * @param[in] context a LinphoneVcardContext object + * @return the user data pointer + */ +LINPHONE_PUBLIC void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context); + +/** + * Sets the user data in the LinphoneVcardContext + * @param[in] context a LinphoneVcardContext object + * @param[in] data the user data pointer + */ +LINPHONE_PUBLIC void linphone_vcard_context_set_user_data(LinphoneVcardContext *context, void *data); + /** * The LinphoneVcard object. */ @@ -48,6 +74,7 @@ typedef struct _LinphoneVcard LinphoneVcard; /** * Creates a LinphoneVcard object that has a pointer to an empty vCard + * @return a new LinphoneVcard object */ LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); @@ -59,24 +86,27 @@ 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. + * @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time) * @param[in] file the path to the file to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *file); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_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] context the vCard context to use (speed up the process by not creating a Belcard parser each time) * @param[in] buffer the buffer to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_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] context the vCard context to use (speed up the process by not creating a Belcard parser each time) * @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(LinphoneVcardContext *context, const char *buffer); +LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_context_get_vcard_from_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 4ba4df8e8..99afe1d7d 100644 --- a/coreapi/vcard_stubs.c +++ b/coreapi/vcard_stubs.c @@ -35,7 +35,7 @@ void linphone_vcard_context_destroy(LinphoneVcardContext *context) { } } -void* linphone_vcard_context_get_user_data(LinphoneVcardContext *context) { +void* linphone_vcard_context_get_user_data(const LinphoneVcardContext *context) { return context ? context->user_data : NULL; } @@ -55,15 +55,15 @@ void linphone_vcard_free(LinphoneVcard *vCard) { } -MSList* linphone_vcard_list_from_vcard4_file(LinphoneVcardContext *context, const char *filename) { +MSList* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *filename) { return NULL; } -MSList* linphone_vcard_list_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { +MSList* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer) { return NULL; } -LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(LinphoneVcardContext *context, const char *buffer) { +LinphoneVcard* linphone_vcard_context_get_vcard_from_buffer(LinphoneVcardContext *context, const char *buffer) { return NULL; } diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 28631db1f..790244f19 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -138,7 +138,7 @@ static void linphone_vcard_update_existing_friends_test(void) { static void linphone_vcard_phone_numbers_and_sip_addresses(void) { 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"); + LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_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); @@ -150,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(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"); + lvc = linphone_vcard_context_get_vcard_from_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); @@ -473,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(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"); + LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_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); @@ -514,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(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"); + LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_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; @@ -575,7 +575,7 @@ 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(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"); + LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_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; @@ -608,12 +608,12 @@ static void carddav_integration(void) { linphone_friend_unref(lf); lf = NULL; - 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"); + lvc = linphone_vcard_context_get_vcard_from_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(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"); + lvc2 = linphone_vcard_context_get_vcard_from_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); @@ -691,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(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"); + lvc = linphone_vcard_context_get_vcard_from_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); @@ -739,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(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"); + LinphoneVcard *lvc1 = linphone_vcard_context_get_vcard_from_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(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"); + LinphoneVcard *lvc2 = linphone_vcard_context_get_vcard_from_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; From a2b7ff1a09eb73108e62fcedb86612ad31535db0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Jul 2016 15:19:47 +0200 Subject: [PATCH 02/30] Update ortp and ms2 submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index ea379434c..a7e405772 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit ea379434c6c725a734b418449b799d5ef8a030c2 +Subproject commit a7e40577252419e9cf6e3288e610d49d7fed3936 diff --git a/oRTP b/oRTP index 96f89c625..3054572f6 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 96f89c62589f9fb84c78be2a092dc94a016ec775 +Subproject commit 3054572f62a2f0e20bb6bc9a47188aad1606de7d From 300c8b87377c58751bb793a0e49d284007ed2299 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Jul 2016 15:20:13 +0200 Subject: [PATCH 03/30] Fix build for Windows 10. --- coreapi/bellesip_sal/sal_op_call.c | 2 +- coreapi/conference.cc | 2 +- coreapi/enum.c | 2 +- coreapi/lime.c | 6 ++-- coreapi/linphonecore.c | 16 ++++----- coreapi/lpconfig.c | 4 +-- coreapi/misc.c | 8 ++--- coreapi/presence.c | 20 +++++------ coreapi/sal.c | 2 +- tester/call_multi_tester.c | 6 ++-- tester/call_single_tester.c | 2 +- tester/complex_sip_case_tester.c | 15 ++++---- tester/flexisip_tester.c | 12 +++++-- tester/message_tester.c | 58 +++++++++++++++--------------- tester/presence_tester.c | 2 +- tester/quality_reporting_tester.c | 2 +- tester/register_tester.c | 8 ++--- tester/tester.c | 2 +- 18 files changed, 87 insertions(+), 82 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index f8e42e211..ec7ef149c 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -985,7 +985,7 @@ int sal_call_send_dtmf(SalOp *h, char dtmf){ if (h->dialog && (belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(h->dialog) == BELLE_SIP_DIALOG_EARLY)){ belle_sip_request_t *req=belle_sip_dialog_create_queued_request(h->dialog,"INFO"); if (req){ - int bodylen; + size_t bodylen; char dtmf_body[128]={0}; snprintf(dtmf_body, sizeof(dtmf_body)-1, "Signal=%c\r\nDuration=250\r\n", dtmf); diff --git a/coreapi/conference.cc b/coreapi/conference.cc index db5930713..16b9f82a4 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -112,7 +112,7 @@ public: bool microphoneIsMuted() const {return m_isMuted;} float getInputVolume() const; - virtual int getSize() const {return m_participants.size() + (isIn()?1:0);} + virtual int getSize() const {return (int)m_participants.size() + (isIn()?1:0);} const std::list &getParticipants() const {return m_participants;} virtual int startRecording(const char *path) = 0; diff --git a/coreapi/enum.c b/coreapi/enum.c index 419e7000e..b083595d7 100644 --- a/coreapi/enum.c +++ b/coreapi/enum.c @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static char *create_enum_domain(const char *number){ - size_t len=strlen(number); + long len=(long)strlen(number); char *domain=ms_malloc((len*2)+10); long i,j; diff --git a/coreapi/lime.c b/coreapi/lime.c index 7d4e1ab93..4af7177a7 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -588,7 +588,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t lime_strToUint8(selfZid, selfZidHex, 24); /* encrypted message length is plaintext + 16 for tag */ - encryptedMessageLength = strlen((char *)message) + 16; + encryptedMessageLength = (uint32_t)strlen((char *)message) + 16; /* retrieve keys associated to the peer URI */ associatedKeys.peerURI = (uint8_t *)malloc(strlen((char *)peerURI)+1); @@ -626,7 +626,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t limeKey_t *currentKey = associatedKeys.peerKeys[i]; /* encrypted message include a 16 bytes tag */ uint8_t *encryptedMessage = (uint8_t *)malloc(encryptedMessageLength); - lime_encryptMessage(currentKey, message, strlen((char *)message), selfZid, encryptedMessage); + lime_encryptMessage(currentKey, message, (uint32_t)strlen((char *)message), selfZid, encryptedMessage); /* add a "msg" node the the output message, doc node is : * * peerZID @@ -795,7 +795,7 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_ /* decrypt the message */ *output = (uint8_t *)malloc(encryptedMessageLength - 16 +1); /* plain message is same length than encrypted one with 16 bytes less for the tag + 1 to add the null termination char */ - retval = lime_decryptMessage(&associatedKey, encryptedMessage, encryptedMessageLength, selfZid, *output); + retval = lime_decryptMessage(&associatedKey, encryptedMessage, (uint32_t)encryptedMessageLength, selfZid, *output); free(encryptedMessage); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 317a87a16..66bc483e2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -603,7 +603,7 @@ static int compress_file(FILE *input_file, COMPRESS_FILE_PTR output_file) { total_bytes += fwrite(buffer, 1, bytes, output_file); #endif } - return total_bytes; + return (int)total_bytes; } static int prepare_log_collection_file_to_upload(const char *filename) { @@ -799,7 +799,7 @@ static void net_config_read (LinphoneCore *lc) static void build_sound_devices_table(LinphoneCore *lc){ const char **devices; const char **old; - int ndev; + size_t ndev; int i; const bctbx_list_t *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(lc->factory)); ndev=bctbx_list_size(elem); @@ -1369,7 +1369,7 @@ static void codecs_config_read(LinphoneCore *lc){ static void build_video_devices_table(LinphoneCore *lc){ const bctbx_list_t *elem; int i; - int ndev; + size_t ndev; const char **devices; if (lc->video_conf.cams) ms_free((void *)lc->video_conf.cams); @@ -5390,7 +5390,7 @@ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) { void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { bctbx_list_t *logs_to_migrate = NULL; LpConfig *lpc = NULL; - int original_logs_count, migrated_logs_count; + size_t original_logs_count, migrated_logs_count; int i; #ifndef SQLITE_STORAGE_ENABLED @@ -5423,7 +5423,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { logs_to_migrate = lc->call_logs; lc->call_logs = NULL; // We can't use bctbx_list_for_each because logs_to_migrate are listed in the wrong order (latest first), and we want to store the logs latest last - for (i = bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) { + for (i = (int)bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) { LinphoneCallLog *log = (LinphoneCallLog *) bctbx_list_nth_data(logs_to_migrate, i); linphone_core_store_call_log(lc, log); } @@ -5431,13 +5431,13 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { original_logs_count = bctbx_list_size(logs_to_migrate); migrated_logs_count = bctbx_list_size(lc->call_logs); if (original_logs_count == migrated_logs_count) { - int i = 0; + size_t i = 0; ms_debug("call logs migration successful: %u logs migrated", (unsigned int)bctbx_list_size(lc->call_logs)); lp_config_set_int(lpc, "misc", "call_logs_migration_done", 1); for (; i < original_logs_count; i++) { char logsection[32]; - snprintf(logsection, sizeof(logsection), "call_log_%i", i); + snprintf(logsection, sizeof(logsection), "call_log_%u", (unsigned int)i); lp_config_clean_section(lpc, logsection); } } else { @@ -6895,7 +6895,7 @@ void linphone_core_destroy(LinphoneCore *lc){ * @ingroup call_control **/ int linphone_core_get_calls_nb(const LinphoneCore *lc){ - return bctbx_list_size(lc->calls);; + return (int)bctbx_list_size(lc->calls); } /** diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index ace08362b..d855cc5d7 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -1020,7 +1020,7 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename, } - if(bctbx_file_read(pFile, data, 1, max_length) < 0){ + if(bctbx_file_read(pFile, data, 1, (off_t)max_length) < 0){ ms_error("%s could not be loaded.", realfilepath); goto err; @@ -1043,7 +1043,7 @@ err: const char** lp_config_get_sections_names(LpConfig *lpconfig) { const char **sections_names; const bctbx_list_t *sections = lpconfig->sections; - int ndev; + size_t ndev; int i; ndev = bctbx_list_size(sections); diff --git a/coreapi/misc.c b/coreapi/misc.c index 6f713553c..a5bf43040 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -319,7 +319,7 @@ static ortp_socket_t create_socket(int local_port){ static int send_stun_request(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t change_addr){ char *buf = NULL; - int len; + size_t len; int err = 0; MSStunMessage *req = ms_stun_binding_request_create(); UInt96 tr_id = ms_stun_message_get_tr_id(req); @@ -332,7 +332,7 @@ static int send_stun_request(int sock, const struct sockaddr *server, socklen_t ms_error("Fail to encode stun message."); err = -1; } else { - err = sendto(sock, buf, len, 0, server, addrlen); + err = bctbx_sendto(sock, buf, len, 0, server, addrlen); if (err < 0) { ms_error("sendto failed: %s",strerror(errno)); err = -1; @@ -905,7 +905,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess IceSessionState session_state = ice_session_state(session); int nb_candidates; int i; - size_t j; + int j; bool_t result; if (session_state == IS_Completed) { @@ -955,7 +955,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess stream->ice_mismatch = ice_check_list_is_mismatch(cl); if ((ice_check_list_state(cl) == ICL_Running) || (ice_check_list_state(cl) == ICL_Completed)) { memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates)); - for (j = 0; j < MIN(bctbx_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { + for (j = 0; j < MIN((int)bctbx_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates]; IceCandidate *ice_candidate = bctbx_list_nth_data(cl->local_candidates, j); const char *default_addr = NULL; diff --git a/coreapi/presence.c b/coreapi/presence.c index 306fc9a1f..294a8ac74 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -360,7 +360,7 @@ int linphone_presence_model_set_contact(LinphonePresenceModel *model, const char } static void presence_model_count_activities(const LinphonePresencePerson *person, unsigned int *nb) { - *nb += bctbx_list_size(person->activities); + *nb += (unsigned int)bctbx_list_size(person->activities); } struct _get_activity_st { @@ -371,7 +371,7 @@ struct _get_activity_st { static void presence_model_get_activity(const LinphonePresencePerson *person, struct _get_activity_st *st) { if (st->current_idx != (unsigned)-1) { - unsigned int size = bctbx_list_size(person->activities); + unsigned int size = (unsigned int)bctbx_list_size(person->activities); if (st->requested_idx < (st->current_idx + size)) { st->activity = (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, st->requested_idx - st->current_idx); st->current_idx = (unsigned)-1; @@ -471,10 +471,8 @@ struct _find_note_st { }; static LinphonePresenceNote * find_presence_note_in_list(bctbx_list_t *list, const char *lang) { - int nb; int i; - - nb = bctbx_list_size(list); + int nb = (int)bctbx_list_size(list); for (i = 0; i < nb; i++) { LinphonePresenceNote *note = (LinphonePresenceNote *)bctbx_list_nth_data(list, i); if (lang == NULL) { @@ -632,7 +630,7 @@ LinphonePresenceModel * linphone_presence_model_new(void) { } unsigned int linphone_presence_model_get_nb_services(const LinphonePresenceModel *model) { - return bctbx_list_size(model->services); + return (unsigned int)bctbx_list_size(model->services); } LinphonePresenceService * linphone_presence_model_get_nth_service(const LinphonePresenceModel *model, unsigned int idx) { @@ -658,7 +656,7 @@ int linphone_presence_model_clear_services(LinphonePresenceModel *model) { } unsigned int linphone_presence_model_get_nb_persons(const LinphonePresenceModel *model) { - return bctbx_list_size(model->persons); + return (unsigned int)bctbx_list_size(model->persons); } LinphonePresencePerson * linphone_presence_model_get_nth_person(const LinphonePresenceModel *model, unsigned int idx) { @@ -762,7 +760,7 @@ int linphone_presence_service_set_contact(LinphonePresenceService *service, cons } unsigned int linphone_presence_service_get_nb_notes(const LinphonePresenceService *service) { - return bctbx_list_size(service->notes); + return (unsigned int)bctbx_list_size(service->notes); } LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx) { @@ -815,7 +813,7 @@ int linphone_presence_person_set_id(LinphonePresencePerson *person, const char * unsigned int linphone_presence_person_get_nb_activities(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return bctbx_list_size(person->activities); + return (unsigned int)bctbx_list_size(person->activities); } LinphonePresenceActivity * linphone_presence_person_get_nth_activity(const LinphonePresencePerson *person, unsigned int idx) { @@ -841,7 +839,7 @@ int linphone_presence_person_clear_activities(LinphonePresencePerson *person) { unsigned int linphone_presence_person_get_nb_notes(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return bctbx_list_size(person->notes); + return (unsigned int)bctbx_list_size(person->notes); } LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx) { @@ -866,7 +864,7 @@ int linphone_presence_person_clear_notes(LinphonePresencePerson *person) { unsigned int linphone_presence_person_get_nb_activities_notes(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return bctbx_list_size(person->activities_notes); + return (unsigned int)bctbx_list_size(person->activities_notes); } LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx) { diff --git a/coreapi/sal.c b/coreapi/sal.c index a54df1611..05b472fd1 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -854,7 +854,7 @@ const char* sal_privacy_to_string(SalPrivacy privacy) { } static void remove_trailing_spaces(char *line){ - int i; + size_t i; for(i=strlen(line)-1;i>=0;--i){ if (isspace(line[i])) line[i]='\0'; else break; diff --git a/tester/call_multi_tester.c b/tester/call_multi_tester.c index fbece53c6..f73698964 100644 --- a/tester/call_multi_tester.c +++ b/tester/call_multi_tester.c @@ -342,7 +342,7 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag BC_ASSERT_PTR_NOT_NULL(conference = linphone_core_get_conference(marie->lc)); if(conference) { bctbx_list_t *participants = linphone_conference_get_participants(conference); - BC_ASSERT_EQUAL(bctbx_list_size(participants), 2, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(participants), 2, unsigned int, "%u"); bctbx_list_free_with_data(participants, (void(*)(void *))linphone_address_destroy); } @@ -716,7 +716,7 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallStreamsRunning,3,10000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,5,10000)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc)); - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 2, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_calls(marie->lc)), 2, unsigned int, "%u"); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); } else { @@ -811,7 +811,7 @@ static void eject_from_4_participants_conference(void) { BC_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE(linphone_core_is_in_conference(marie->lc)); BC_ASSERT_EQUAL(linphone_core_get_conference_size(marie->lc),3, int, "%d"); - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 3, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_calls(marie->lc)), 3, unsigned int, "%u"); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(michelle->lc)); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 6fcc548ff..5bd6a7821 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4359,7 +4359,7 @@ static void call_logs_migrate(void) { BC_ASSERT_TRUE(linphone_core_get_call_history_size(laure->lc) == 10); for (; i < bctbx_list_size(laure->lc->call_logs); i++) { - LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, i); + LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, (int)i); LinphoneCallStatus state = linphone_call_log_get_status(log); LinphoneCallDir direction = linphone_call_log_get_dir(log); diff --git a/tester/complex_sip_case_tester.c b/tester/complex_sip_case_tester.c index 1e524bb2c..6e9aa8dc4 100644 --- a/tester/complex_sip_case_tester.c +++ b/tester/complex_sip_case_tester.c @@ -23,6 +23,7 @@ #include "private.h" +#if HAVE_SIPP void check_rtcp(LinphoneCall *call) { MSTimeSpec ts; @@ -45,7 +46,6 @@ void check_rtcp(LinphoneCall *call) { } FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres) { -#if HAVE_SIPP char *dest; char *command; FILE *file; @@ -65,14 +65,10 @@ FILE *sip_start(const char *senario, const char* dest_username, const char *pass ms_free(command); ms_free(dest); return file; -#else - return NULL; -#endif } static FILE *sip_start_recv(const char *senario) { -#if HAVE_SIPP char *command; FILE *file; @@ -83,9 +79,6 @@ static FILE *sip_start_recv(const char *senario) { file = popen(command, "r"); ms_free(command); return file; -#else - return NULL; -#endif } static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list) { @@ -359,6 +352,7 @@ static test_t tests[] = { TEST_NO_TAG("Call with multiple video mline in sdp", call_with_multiple_video_mline_in_sdp), TEST_NO_TAG("Call invite 200ok without contact header", call_invite_200ok_without_contact_header) }; +#endif test_suite_t complex_sip_call_test_suite = { "Complex SIP Case", @@ -366,6 +360,11 @@ test_suite_t complex_sip_call_test_suite = { NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, +#if HAVE_SIPP sizeof(tests) / sizeof(tests[0]), tests +#else + 0, + NULL +#endif }; diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 1310aab47..d6dcb3ef0 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -962,7 +962,7 @@ static void dos_module_trigger(void) { linphone_core_manager_destroy(pauline); } - +#if HAVE_SIPP static void test_subscribe_notify_with_sipp_publisher(void) { char *scen; FILE * sipp_out; @@ -1004,7 +1004,8 @@ static void test_subscribe_notify_with_sipp_publisher(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } - //does not work because sipp seams not able to manage 2 call id in case file + +//does not work because sipp seams not able to manage 2 call id in case file #if 0 static void test_subscribe_notify_with_sipp_publisher_double_publish(void) { char *scen; @@ -1046,6 +1047,7 @@ static void test_subscribe_notify_with_sipp_publisher_double_publish(void) { linphone_core_manager_destroy(pauline); } #endif +#endif static void test_publish_unpublish(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); @@ -1142,6 +1144,7 @@ static void test_list_subscribe (void) { linphone_core_manager_destroy(laure); } +#if HAVE_SIPP static void test_subscribe_on_wrong_dialog(void) { char *scen; FILE * sipp_out; @@ -1162,6 +1165,7 @@ static void test_subscribe_on_wrong_dialog(void) { linphone_core_manager_destroy(marie); } +#endif test_t flexisip_tests[] = { @@ -1183,15 +1187,19 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Call ipv6 to ipv6", call_with_ipv6), TEST_NO_TAG("Call ipv6 to ipv4", call_ipv6_to_ipv4), TEST_NO_TAG("Call ipv4 to ipv6", call_ipv4_to_ipv6), +#if HAVE_SIPP TEST_ONE_TAG("Subscribe Notify with sipp publisher", test_subscribe_notify_with_sipp_publisher, "LeaksMemory"), /*TEST_ONE_TAG("Subscribe Notify with sipp double publish", test_subscribe_notify_with_sipp_publisher_double_publish, "LeaksMemory"),*/ +#endif TEST_NO_TAG("Publish/unpublish", test_publish_unpublish), TEST_ONE_TAG("List subscribe", test_list_subscribe,"LeaksMemory"), TEST_NO_TAG("File transfer message rcs to external body client", file_transfer_message_rcs_to_external_body_client), TEST_ONE_TAG("File transfer message external body to rcs client", file_transfer_message_external_body_to_rcs_client, "LeaksMemory"), TEST_ONE_TAG("File transfer message external body to external body client", file_transfer_message_external_body_to_external_body_client, "LeaksMemory"), TEST_NO_TAG("DoS module trigger by sending a lot of chat messages", dos_module_trigger), +#if HAVE_SIPP TEST_NO_TAG("Subscribe on wrong dialog", test_subscribe_on_wrong_dialog) +#endif }; test_suite_t flexisip_test_suite = {"Flexisip", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, diff --git a/tester/message_tester.c b/tester/message_tester.c index abdf8edf2..6f535ee9b 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -362,7 +362,7 @@ static void text_message_with_send_error(void) { linphone_chat_room_send_chat_message(chat_room,msg); /* check transient msg list: the msg should be in it, and should be the only one */ - BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u"); BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1)); @@ -370,7 +370,7 @@ static void text_message_with_send_error(void) { BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d"); /* the msg should have been discarded from transient list after an error */ - BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u"); sal_set_send_error(marie->lc->sal, 0); @@ -396,7 +396,7 @@ static void text_message_with_external_body(void) { linphone_chat_room_send_chat_message(chat_room,msg); /* check transient msg list: the msg should be in it, and should be the only one */ - BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u"); BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); @@ -405,7 +405,7 @@ static void text_message_with_external_body(void) { BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1, int, "%d"); - BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u"); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -615,7 +615,7 @@ static void file_transfer_2_messages_simultaneously(void) { cbs = linphone_chat_message_get_callbacks(msg2); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, unsigned int, "%u"); if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) == 0) { linphone_chat_room_send_chat_message(pauline_room,msg); linphone_chat_room_send_chat_message(pauline_room,msg2); @@ -623,7 +623,7 @@ static void file_transfer_2_messages_simultaneously(void) { msg = linphone_chat_message_clone(marie->stat.last_received_chat_message); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2)); msg2 = marie->stat.last_received_chat_message; - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, unsigned int, "%u"); if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) { char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", bctbx_list_size(linphone_core_get_chat_rooms(marie->lc))); const bctbx_list_t *it = linphone_core_get_chat_rooms(marie->lc); @@ -1028,12 +1028,12 @@ static void lime_unit(void) { ms_message("session index %d\n", associatedKey.sessionIndex); /* encrypt/decrypt a msg */ - lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage); + lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, (uint32_t)strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage); printHex("Ciphered", encryptedMessage, strlen((char *)encryptedMessage)); /* invert sender and receiverZID to decrypt/authenticate */ memcpy(receiverZID, associatedKeys.peerKeys[0]->peerZID, 12); memcpy(associatedKeys.peerKeys[0]->peerZID, senderZID, 12); - retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage); + retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, (uint32_t)strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage); BC_ASSERT_EQUAL(retval, 0, int, "%d"); BC_ASSERT_STRING_EQUAL((char *)plainMessage, (char *)PLAIN_TEXT_TEST_MESSAGE); ms_message("Decrypt and auth returned %d\nPlain text is %s\n", retval, plainMessage); @@ -1190,9 +1190,9 @@ int check_no_strange_time(void* data,int argc, char** argv,char** cNames) { return 0; } -void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, int expected ){ +void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, unsigned int expected ){ bctbx_list_t* messages = linphone_chat_room_get_history_range(chatroom, x, y); - BC_ASSERT_EQUAL(bctbx_list_size(messages), expected, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), expected, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void *))linphone_chat_message_unref); } @@ -1288,16 +1288,16 @@ static void history_count(void) { BC_ASSERT_PTR_NOT_NULL(chatroom); if (chatroom){ messages=linphone_chat_room_get_history(chatroom,10); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 10, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 10, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); messages=linphone_chat_room_get_history(chatroom,1); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); messages=linphone_chat_room_get_history(chatroom,0); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(chatroom), 1270, int, "%d"); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270, unsigned int, "%u"); /*check the second most recent msg*/ BC_ASSERT_PTR_NOT_NULL(messages); @@ -1312,23 +1312,23 @@ static void history_count(void) { /*test offset+limit: retrieve the 42th latest msg only and check its content*/ messages=linphone_chat_room_get_history_range(chatroom, 42, 42); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1, unsigned int, "%u"); BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text((LinphoneChatMessage *)messages->data), "If you open yourself to the Tao is intangible and evasive, yet prefers to keep us at the mercy of the kingdom, then all of the streams of hundreds of valleys because of its limitless possibilities."); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test offset without limit*/ messages = linphone_chat_room_get_history_range(chatroom, 1265, -1); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270-1265, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test limit without offset*/ messages = linphone_chat_room_get_history_range(chatroom, 0, 5); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 6, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 6, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test invalid start*/ messages = linphone_chat_room_get_history_range(chatroom, 1265, 1260); - BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(messages), 1270-1265, unsigned int, "%u"); bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } @@ -1476,7 +1476,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo for (i = 0; i < strlen(message); i++) { BC_ASSERT_FALSE(linphone_chat_message_put_char(rtt_message, message[i])); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); @@ -1488,11 +1488,11 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo LinphoneChatMessage *marie_msg = NULL; LinphoneChatMessage *pauline_msg = NULL; if (do_not_store_rtt_messages_in_sql_storage) { - BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 0, int , "%i"); - BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 0, int , "%i"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(marie_messages), 0, unsigned int , "%u"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(pauline_messages), 0, unsigned int , "%u"); } else { - BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 1, int , "%i"); - BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 1, int , "%i"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(marie_messages), 1, unsigned int , "%u"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(pauline_messages), 1, unsigned int , "%u"); if (!marie_messages || !pauline_messages) { goto end; } @@ -1569,11 +1569,11 @@ static void real_time_text_conversation(void) { for (i = 0; i < strlen(message1_1); i++) { linphone_chat_message_put_char(pauline_rtt_message, message1_1[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message1_1[i], char, "%c"); linphone_chat_message_put_char(marie_rtt_message, message1_2[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(pauline_chat_room), message1_2[i], char, "%c"); } @@ -1605,11 +1605,11 @@ static void real_time_text_conversation(void) { for (i = 0; i < strlen(message2_1); i++) { linphone_chat_message_put_char(pauline_rtt_message, message2_1[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message2_1[i], char, "%c"); linphone_chat_message_put_char(marie_rtt_message, message2_2[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(pauline_chat_room), message2_2[i], char, "%c"); } @@ -1680,7 +1680,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_ for (i = 0; i < strlen(message); i++) { linphone_chat_message_put_char(rtt_message, message[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } @@ -1689,7 +1689,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_ } else if (end_with_lf) { linphone_chat_message_put_char(rtt_message, lf); } - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, strlen(message), 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)strlen(message), 1000)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); linphone_chat_message_unref(rtt_message); } @@ -1794,7 +1794,7 @@ static void real_time_text_copy_paste(void) { linphone_chat_message_put_char(rtt_message, message[i-1]); if (i % 4 == 0) { int j; - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i, 1000)); for (j = 4; j > 0; j--) { BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i-j], char, "%c"); } diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 6bb1771bd..042dff08f 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -529,7 +529,7 @@ static void simple_subscribe_with_friend_from_rc(void) { LinphoneCoreManager *marie = presence_linphone_core_manager_new_with_rc_name("marie", "pauline_as_friend_rc"); LinphoneFriend *pauline_as_friend; - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i"); + BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_friend_list(marie->lc)), 1, unsigned int , "%u"); if (bctbx_list_size(linphone_core_get_friend_list(marie->lc))>0) { pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data; diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 31ec4d7a5..ad6563ecc 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -406,7 +406,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { for (i = 0; i < strlen(message); i++) { linphone_chat_message_put_char(rtt_message, message[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); diff --git a/tester/register_tester.c b/tester/register_tester.c index d9a33a4e2..d8392a1e2 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -505,7 +505,7 @@ static LinphoneCoreManager* configure_lcm(void) { if (transport_supported(LinphoneTransportTls)) { LinphoneCoreManager *lcm=linphone_core_manager_new2( "multi_account_rc", FALSE); stats *counters=&lcm->stat; - BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); + BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,(int)bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0, int, "%d"); return lcm; } @@ -567,7 +567,7 @@ static void transport_change(void){ register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); - total_number_of_proxies=bctbx_list_size(linphone_core_get_proxy_config_list(lc)); + total_number_of_proxies=(int)bctbx_list_size(linphone_core_get_proxy_config_list(lc)); linphone_core_get_sip_transports(lc,&sip_tr_orig); sip_tr.udp_port=sip_tr_orig.udp_port; @@ -739,7 +739,7 @@ static void io_recv_error_late_recovery(void){ lc=lcm->lc; sal_set_refresher_retry_after(lc->sal,1000); counters=&lcm->stat; - BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); + BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,(int)bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); counters = get_stats(lc); @@ -791,7 +791,7 @@ static void io_recv_error_without_active_register(void){ /*nothing should happen because no active registration*/ wait_for_until(lc,lc, &dummy, 1, 3000); - BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, bctbx_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d"); + BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, (int)bctbx_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d"); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0,int,"%d"); diff --git a/tester/tester.c b/tester/tester.c index 69d51f4c8..5c5f8c97a 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -358,7 +358,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies /*BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/ if (check_for_proxies){ /**/ - proxy_count=bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc)); + proxy_count=(int)bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc)); }else{ proxy_count=0; /*this is to prevent registration to go on*/ From 1260c18640832bfde62acb7e291ac8f78b45e621 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 4 Jul 2016 17:31:36 +0200 Subject: [PATCH 04/30] Cast size_t to int in ms_error --- coreapi/linphonecore.c | 2 +- mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 66bc483e2..982d801ad 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5441,7 +5441,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { lp_config_clean_section(lpc, logsection); } } else { - ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", original_logs_count, migrated_logs_count); + ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", (int)original_logs_count, (int)migrated_logs_count); } bctbx_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref); diff --git a/mediastreamer2 b/mediastreamer2 index a7e405772..34160e44d 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a7e40577252419e9cf6e3288e610d49d7fed3936 +Subproject commit 34160e44ddb2a6b064cb5623cd8c8a67ed766587 From b77c0beb8d256d40f0a7918ebffcfd56c64bbc79 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 4 Jul 2016 21:50:15 +0200 Subject: [PATCH 05/30] fix bad git url in README --- README | 2 +- mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index e6c2679ea..cde6c760e 100644 --- a/README +++ b/README @@ -47,7 +47,7 @@ libglew1.6-dev libv4l-dev libxml2-dev libsqlite3-dev libupnp4-dev libsrtp-dev + Install zrtp (optional), for unbreakable call encryption - $ git clone git://git.linphone.org:bzrtp + $ git clone git://git.linphone.org/bzrtp.git $ cd bzrtp && ./autogen.sh && ./configure && make $ sudo make install diff --git a/mediastreamer2 b/mediastreamer2 index 34160e44d..df21f3b18 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 34160e44ddb2a6b064cb5623cd8c8a67ed766587 +Subproject commit df21f3b1841489d3e6ff67aa03f13e158ac07ed9 From 9d99aa7c001184b4f4cc41fa093cd7deb97e953f Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 5 Jul 2016 10:07:09 +0200 Subject: [PATCH 06/30] Fix previous commit --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 982d801ad..1e142de88 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5441,7 +5441,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { lp_config_clean_section(lpc, logsection); } } else { - ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", (int)original_logs_count, (int)migrated_logs_count); + ms_error("not as many logs saved in db has logs read from rc ("FORMAT_SIZE_T" in rc against "FORMAT_SIZE_T" in db)!", original_logs_count, migrated_logs_count); } bctbx_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref); From 44d3c1d2278dffefce9531b9f63ab663cec8eb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 5 Jul 2016 15:29:41 +0200 Subject: [PATCH 07/30] Fix auto answer delay setting on Windows --- gtk/linphone.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/linphone.h b/gtk/linphone.h index 865b0bc7a..764663508 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -364,6 +364,7 @@ LINPHONE_PUBLIC void linphone_gtk_reload_sound_devices(void); LINPHONE_PUBLIC void linphone_gtk_reload_video_devices(void); LINPHONE_PUBLIC bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact); LINPHONE_PUBLIC gboolean linphone_gtk_auto_answer_enabled(void); +LINPHONE_PUBLIC void linphone_gtk_auto_answer_delay_changed(GtkSpinButton *spinbutton, gpointer user_data); LINPHONE_PUBLIC void linphone_gtk_update_status_bar_icons(void); LINPHONE_PUBLIC void linphone_gtk_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data); From 5fdf96eb7eae9adb36ddb3652ff359664810e3b8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 5 Jul 2016 18:10:29 +0200 Subject: [PATCH 08/30] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index df21f3b18..2cff42a6f 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit df21f3b1841489d3e6ff67aa03f13e158ac07ed9 +Subproject commit 2cff42a6f1a6424e71012c8bf89b5ef11a4d70c4 From a99e1d8eb9827751af1a3d42ff2b20144a06e103 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 5 Jul 2016 18:35:44 +0200 Subject: [PATCH 09/30] fix crash on windows when moving the video window frequently --- gtk/videowindow.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gtk/videowindow.c b/gtk/videowindow.c index 145ef084a..09938d444 100644 --- a/gtk/videowindow.c +++ b/gtk/videowindow.c @@ -121,7 +121,7 @@ static void _resize_video_window(GtkWidget *video_window, MSVideoSize vsize){ } } -static gint resize_video_window(LinphoneCall *call){ +static gboolean resize_video_window(LinphoneCall *call){ const LinphoneCallParams *params=linphone_call_get_current_params(call); if (params){ MSVideoSize vsize=linphone_call_params_get_received_video_size(params); @@ -232,6 +232,18 @@ static gboolean video_window_moved(GtkWidget *widget, GdkEvent *event, gpointer return FALSE; } +static gint do_gtk_widget_destroy(GtkWidget *w){ + gtk_widget_destroy(w); + return FALSE; +} + +static void schedule_video_controls_disapearance(GtkWidget *w){ + gint timeout=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"timeout")); + if (timeout != 0) g_source_remove(timeout); + timeout=g_timeout_add(3000,(GSourceFunc)do_gtk_widget_destroy,w); + g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout)); +} + static GtkWidget *show_video_controls(GtkWidget *video_window){ GtkWidget *w; w=(GtkWidget*)g_object_get_data(G_OBJECT(video_window),"controls"); @@ -240,7 +252,6 @@ static GtkWidget *show_video_controls(GtkWidget *video_window){ const char *stock_button=isfullscreen ? GTK_STOCK_LEAVE_FULLSCREEN : GTK_STOCK_FULLSCREEN; gint response_id=isfullscreen ? GTK_RESPONSE_NO : GTK_RESPONSE_YES ; GtkWidget *image = gtk_image_new_from_icon_name(linphone_gtk_get_ui_config("stop_call_icon_name","linphone-stop-call"), GTK_ICON_SIZE_BUTTON); - gint timeout; GtkWidget *button; w=gtk_dialog_new_with_buttons("",GTK_WINDOW(video_window),GTK_DIALOG_DESTROY_WITH_PARENT,stock_button,response_id,NULL); gtk_window_set_opacity(GTK_WINDOW(w),0.5); @@ -255,18 +266,14 @@ static GtkWidget *show_video_controls(GtkWidget *video_window){ gtk_widget_show(button); gtk_dialog_add_action_widget(GTK_DIALOG(w),button,GTK_RESPONSE_APPLY); g_signal_connect(w,"response",(GCallback)on_controls_response,video_window); - timeout=g_timeout_add(3000,(GSourceFunc)gtk_widget_destroy,w); - g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout)); + schedule_video_controls_disapearance(w); g_signal_connect(w,"destroy",(GCallback)on_controls_destroy,NULL); g_object_set_data(G_OBJECT(w),"video_window",video_window); g_object_set_data(G_OBJECT(video_window),"controls",w); set_video_controls_position(video_window); gtk_widget_show(w); }else{ - gint timeout=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"timeout")); - g_source_remove(timeout); - timeout=g_timeout_add(3000,(GSourceFunc)gtk_widget_destroy,w); - g_object_set_data(G_OBJECT(w),"timeout",GINT_TO_POINTER(timeout)); + schedule_video_controls_disapearance(w); } return w; } From db4be5abeaf2d2e88dc1785bd6ccd03f4fe27077 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 7 Jul 2016 10:46:34 +0200 Subject: [PATCH 10/30] Update ortp and ms2 submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 2cff42a6f..10d64b908 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2cff42a6f1a6424e71012c8bf89b5ef11a4d70c4 +Subproject commit 10d64b908e4ba7f382aff5e50f4a81d5ae6e2071 diff --git a/oRTP b/oRTP index 3054572f6..e7ae3587d 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 3054572f62a2f0e20bb6bc9a47188aad1606de7d +Subproject commit e7ae3587d3b7638a59c0929b332a50b78d84aa1c From 507c3d6428560b6c4bf201d4c3a60c55cb1cbf69 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 7 Jul 2016 11:41:20 +0200 Subject: [PATCH 11/30] Simple tool to list most of lp_config items (and their default values if possible) --- tools/lpconfig_items.py | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/lpconfig_items.py diff --git a/tools/lpconfig_items.py b/tools/lpconfig_items.py new file mode 100644 index 000000000..6c002c5ab --- /dev/null +++ b/tools/lpconfig_items.py @@ -0,0 +1,51 @@ +#!/usr/bin/python + +from collections import defaultdict +items = defaultdict(list) + +def get_files_in_coreapi_directory(): + from os import walk + files = [] + for (dirpath, dirnames, filenames) in walk('../coreapi'): + files.extend(filenames) + break + return files + +def parse_file(filename): + with open('../coreapi/' + filename, 'r') as infile: + for line in infile: + if 'lp_config_get_' in line: + parse_lpconfig_line(line) + +def parse_lpconfig_line(line): + token = line[line.find('lp_config_get_') + len('lp_config_get_'):] + split = token.split('(', 1) + item_type = split[0] + if '_' in item_type: + return + + params_split = split[1].split(',', 3) + item_section = params_split[1] + if item_section[0] != '"': + return + item_section = item_section.split('"')[1] + + item_name = params_split[2] + if item_name[0] != '"': + return + item_name = item_name.split('"')[1] + + item_default_value = params_split[3].split(')')[0] + if item_type == 'string' and item_default_value[0] != '"': + item_default_value = '' + + item = [item_type, item_name, item_default_value] + items[item_section].append(item) + +for files in get_files_in_coreapi_directory(): + parse_file(files) +for section, items in items.iteritems(): + print '[' + section + ']' + for item in items: + print item[1] + '=' + item[2] + print '' \ No newline at end of file From 7c778a4f9d2c49e2ff0bc5a88ddefdfbe220814e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 7 Jul 2016 12:04:43 +0200 Subject: [PATCH 12/30] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 10d64b908..47fad95d1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 10d64b908e4ba7f382aff5e50f4a81d5ae6e2071 +Subproject commit 47fad95d1b25b19ca2cb0db822f46d0098fc5461 From 3180a3fdfbfcb7b8422d23ff8bbd368b28d3ea96 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 8 Jul 2016 11:50:51 +0200 Subject: [PATCH 13/30] Big AES patch --- coreapi/misc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index a5bf43040..fe748b1d3 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1748,8 +1748,7 @@ void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *aud } const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){ - const char *config=lp_config_get_string(lc->config,"sip","srtp_crypto_suites","AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_CM_256_HMAC_SHA1_80, AES_CM_256_HMAC_SHA1_32"); - char *tmp=ms_strdup(config); + const char *config= lp_config_get_string(lc->config, "sip", "srtp_crypto_suites", "AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_256_CM_HMAC_SHA1_80, AES_256_CM_HMAC_SHA1_32"); char *sep; char *pos; char *nextpos; From a164602fa77f8463486d5c29de7fdd6e209b4741 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 8 Jul 2016 15:07:17 +0200 Subject: [PATCH 14/30] Fixing error in bug fiex AES. --- coreapi/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreapi/misc.c b/coreapi/misc.c index fe748b1d3..555d5b06c 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1749,6 +1749,8 @@ void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *aud const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){ const char *config= lp_config_get_string(lc->config, "sip", "srtp_crypto_suites", "AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_256_CM_HMAC_SHA1_80, AES_256_CM_HMAC_SHA1_32"); + char *tmp=ms_strdup(config); + char *sep; char *pos; char *nextpos; From ee8296fd6d29db1b39636ef1ce0568d3277c4f4c Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 8 Jul 2016 16:38:49 +0200 Subject: [PATCH 15/30] Add missing license headers. --- .../org/linphone/core/LinphoneContent.java | 19 +++++++++++++++++++ .../linphone/core/LinphoneContentImpl.java | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/java/common/org/linphone/core/LinphoneContent.java b/java/common/org/linphone/core/LinphoneContent.java index eb41c62f7..e6aaf6c68 100644 --- a/java/common/org/linphone/core/LinphoneContent.java +++ b/java/common/org/linphone/core/LinphoneContent.java @@ -1,3 +1,22 @@ +/* +LinphoneContent.java +Copyright (C) 2015 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package org.linphone.core; /** diff --git a/java/impl/org/linphone/core/LinphoneContentImpl.java b/java/impl/org/linphone/core/LinphoneContentImpl.java index 0231fd539..4f5fe651a 100644 --- a/java/impl/org/linphone/core/LinphoneContentImpl.java +++ b/java/impl/org/linphone/core/LinphoneContentImpl.java @@ -1,3 +1,22 @@ +/* +LinphoneContentImpl.java +Copyright (C) 2015 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + package org.linphone.core; public class LinphoneContentImpl implements LinphoneContent { From 2e475b0bcd752652bf08e5106d78b5d8d64638f0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 8 Jul 2016 16:42:56 +0200 Subject: [PATCH 16/30] Use bctbx_list_t instead of MSList in JNI. --- coreapi/linphonecore_jni.cc | 130 ++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 664fb1df4..ef27f4966 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1431,7 +1431,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addListener(JNIEnv* env, } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeListener(JNIEnv* env, jobject thiz, jlong lc, jobject jlistener) { - MSList* iterator; + bctbx_list_t* iterator; LinphoneCore *core = (LinphoneCore*)lc; //jobject listener = env->NewGlobalRef(jlistener); for (iterator = core->vtable_refs; iterator != NULL; ) { @@ -1563,12 +1563,12 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig } extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) { - const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc); - int proxyCount = ms_list_size(proxies); + const bctbx_list_t* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc); + size_t proxyCount = bctbx_list_size(proxies); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc); jobjectArray jProxies = env->NewObjectArray(proxyCount,ljb->proxyClass,NULL); - for (int i = 0; i < proxyCount; i++ ) { + for (size_t i = 0; i < proxyCount; i++ ) { LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)proxies->data; jobject jproxy = getProxy(env,proxy,thiz); if(jproxy != NULL){ @@ -1598,12 +1598,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeAuthInfo(JNIEnv* e } extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getAuthInfosList(JNIEnv* env, jobject thiz,jlong lc) { - const MSList* authInfos = linphone_core_get_auth_info_list((LinphoneCore*)lc); - int listCount = ms_list_size(authInfos); + const bctbx_list_t* authInfos = linphone_core_get_auth_info_list((LinphoneCore*)lc); + size_t listCount = bctbx_list_size(authInfos); jlongArray jAuthInfos = env->NewLongArray(listCount); jlong *jInternalArray = env->GetLongArrayElements(jAuthInfos, NULL); - for (int i = 0; i < listCount; i++ ) { + for (size_t i = 0; i < listCount; i++ ) { jInternalArray[i] = (unsigned long) (authInfos->data); authInfos = authInfos->next; } @@ -1750,12 +1750,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* en ,jobject thiz ,jlong lc ,jint position) { - return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position); + return (jlong)bctbx_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env ,jobject thiz ,jlong lc) { - return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); + return (jint)bctbx_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); } extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getLastOutgoingCallLog( JNIEnv* env ,jobject thiz @@ -1901,12 +1901,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env ,jobject thiz ,jlong lc) { - const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc); - int codecsCount = ms_list_size(codecs); + const bctbx_list_t* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc); + size_t codecsCount = bctbx_list_size(codecs); jlongArray jCodecs = env->NewLongArray(codecsCount); jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL); - for (int i = 0; i < codecsCount; i++ ) { + for (size_t i = 0; i < codecsCount; i++ ) { jInternalArray[i] = (unsigned long) (codecs->data); codecs = codecs->next; } @@ -1917,12 +1917,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTy } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) { - MSList *pts = NULL; + bctbx_list_t *pts = NULL; int codecsCount = env->GetArrayLength(jCodecs); jlong *codecs = env->GetLongArrayElements(jCodecs, NULL); for (int i = 0; i < codecsCount; i++) { PayloadType *pt = (PayloadType *)codecs[i]; - ms_list_append(pts, pt); + bctbx_list_append(pts, pt); } linphone_core_set_video_codecs((LinphoneCore *)lc, pts); env->ReleaseLongArrayElements(jCodecs, codecs, 0); @@ -1931,12 +1931,12 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoCodecs(JN extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env ,jobject thiz ,jlong lc) { - const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc); - int codecsCount = ms_list_size(codecs); + const bctbx_list_t* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc); + size_t codecsCount = bctbx_list_size(codecs); jlongArray jCodecs = env->NewLongArray(codecsCount); jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL); - for (int i = 0; i < codecsCount; i++ ) { + for (size_t i = 0; i < codecsCount; i++ ) { jInternalArray[i] = (unsigned long) (codecs->data); codecs = codecs->next; } @@ -1947,12 +1947,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTy } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioCodecs(JNIEnv *env, jobject thiz, jlong lc, jlongArray jCodecs) { - MSList *pts = NULL; + bctbx_list_t *pts = NULL; int codecsCount = env->GetArrayLength(jCodecs); jlong *codecs = env->GetLongArrayElements(jCodecs, NULL); for (int i = 0; i < codecsCount; i++) { PayloadType *pt = (PayloadType *)codecs[i]; - pts = ms_list_append(pts, pt); + pts = bctbx_list_append(pts, pt); } linphone_core_set_audio_codecs((LinphoneCore *)lc, pts); env->ReleaseLongArrayElements(jCodecs, codecs, 0); @@ -2137,12 +2137,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriendList(JNIEnv* extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JNIEnv* env ,jobject thiz ,jlong lc) { - const MSList* friends = linphone_core_get_friend_list((LinphoneCore*)lc); - int friendsSize = ms_list_size(friends); + const bctbx_list_t* friends = linphone_core_get_friend_list((LinphoneCore*)lc); + size_t friendsSize = bctbx_list_size(friends); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc); jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendClass,NULL); - for (int i = 0; i < friendsSize; i++) { + for (size_t i = 0; i < friendsSize; i++) { LinphoneFriend* lfriend = (LinphoneFriend*)friends->data; jobject jfriend = getFriend(env,lfriend); if(jfriend != NULL){ @@ -2158,12 +2158,12 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JN extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendLists(JNIEnv* env ,jobject thiz ,jlong lc) { - const MSList* friends = linphone_core_get_friends_lists((LinphoneCore*)lc); - int friendsSize = ms_list_size(friends); + const bctbx_list_t* friends = linphone_core_get_friends_lists((LinphoneCore*)lc); + size_t friendsSize = bctbx_list_size(friends); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data((LinphoneCore *)lc); jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendListClass,NULL); - for (int i = 0; i < friendsSize; i++) { + for (size_t i = 0; i < friendsSize; i++) { LinphoneFriendList* lfriend = (LinphoneFriendList*)friends->data; jobject jfriend = getFriendList(env,lfriend); if(jfriend != NULL){ @@ -3117,12 +3117,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* en extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getCallLogs(JNIEnv* env ,jobject thiz ,jlong lc) { - const MSList *logs = linphone_core_get_call_logs((LinphoneCore *) lc); - int logsCount = ms_list_size(logs); + const bctbx_list_t *logs = linphone_core_get_call_logs((LinphoneCore *) lc); + size_t logsCount = bctbx_list_size(logs); jlongArray jLogs = env->NewLongArray(logsCount); jlong *jInternalArray = env->GetLongArrayElements(jLogs, NULL); - for (int i = 0; i < logsCount; i++) { + for (size_t i = 0; i < logsCount; i++) { jInternalArray[i] = (unsigned long) (logs->data); logs = logs->next; } @@ -3496,13 +3496,13 @@ extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_addLocalFriend(JNI } extern "C" jobjectArray Java_org_linphone_core_LinphoneFriendListImpl_getFriendList(JNIEnv* env, jobject thiz, jlong list) { - const MSList* friends = linphone_friend_list_get_friends((LinphoneFriendList *)list); - int friendsSize = ms_list_size(friends); + const bctbx_list_t* friends = linphone_friend_list_get_friends((LinphoneFriendList *)list); + size_t friendsSize = bctbx_list_size(friends); LinphoneCore *lc = linphone_friend_list_get_core((LinphoneFriendList *)list); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jobjectArray jFriends = env->NewObjectArray(friendsSize,ljb->friendClass,NULL); - for (int i = 0; i < friendsSize; i++) { + for (size_t i = 0; i < friendsSize; i++) { LinphoneFriend* lfriend = (LinphoneFriend*)friends->data; jobject jfriend = getFriend(env,lfriend); if(jfriend != NULL){ @@ -3526,16 +3526,16 @@ extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_updateSubscription extern "C" jlongArray Java_org_linphone_core_LinphoneFriendImpl_getAddresses(JNIEnv* env ,jobject thiz ,jlong ptr) { - MSList *addresses = linphone_friend_get_addresses((LinphoneFriend*)ptr); - MSList *list = addresses; - int size = ms_list_size(addresses); + bctbx_list_t *addresses = linphone_friend_get_addresses((LinphoneFriend*)ptr); + bctbx_list_t *list = addresses; + size_t size = bctbx_list_size(addresses); jlongArray jaddresses = env->NewLongArray(size); jlong *jInternalArray = env->GetLongArrayElements(jaddresses, NULL); - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { jInternalArray[i] = (unsigned long) (addresses->data); - addresses = ms_list_next(addresses); + addresses = bctbx_list_next(addresses); } - ms_list_free(list); + bctbx_list_free(list); env->ReleaseLongArrayElements(jaddresses, jInternalArray, 0); return jaddresses; } @@ -3557,16 +3557,16 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_removeAddress(JNIEnv* extern "C" jobjectArray Java_org_linphone_core_LinphoneFriendImpl_getPhoneNumbers(JNIEnv* env ,jobject thiz ,jlong ptr) { - MSList *phone_numbers = linphone_friend_get_phone_numbers((LinphoneFriend*)ptr); - MSList *list = phone_numbers; - int size = ms_list_size(phone_numbers); + bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers((LinphoneFriend*)ptr); + bctbx_list_t *list = phone_numbers; + size_t size = bctbx_list_size(phone_numbers); jobjectArray jphonenumbers = env->NewObjectArray(size, env->FindClass("java/lang/String"), env->NewStringUTF("")); - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { const char *phone = (const char *)phone_numbers->data; env->SetObjectArrayElement(jphonenumbers, i, env->NewStringUTF(phone)); - phone_numbers = ms_list_next(phone_numbers); + phone_numbers = bctbx_list_next(phone_numbers); } - ms_list_free(list); + bctbx_list_free(list); return jphonenumbers; } @@ -3761,15 +3761,15 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JN } } -extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject thiz, jlong ptr, MSList* history) { +extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject thiz, jlong ptr, bctbx_list_t* history) { LinphoneChatRoom *room = (LinphoneChatRoom *)ptr; LinphoneCore *lc = linphone_chat_room_get_core(room); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); - MSList *list = history; - int historySize = ms_list_size(history); + bctbx_list_t *list = history; + size_t historySize = bctbx_list_size(history); jobjectArray jHistory = env->NewObjectArray(historySize, ljb->chatMessageClass, NULL); - for (int i = 0; i < historySize; i++) { + for (size_t i = 0; i < historySize; i++) { LinphoneChatMessage *msg = (LinphoneChatMessage *)history->data; jobject jmsg = getChatMessage(env, msg); if (jmsg != NULL) { @@ -3781,7 +3781,7 @@ extern "C" jobjectArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env, jobject th } /*getChatMessage() acquired a ref that is "transfered" to the java object. We must drop * the reference given by linphone_chat_room_get_history_range()*/ - ms_list_free_with_data(list, (void (*)(void*))linphone_chat_message_unref); + bctbx_list_free_with_data(list, (void (*)(void*))linphone_chat_message_unref); return jHistory; } extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistoryRange(JNIEnv* env @@ -3789,14 +3789,14 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistoryRa ,jlong ptr ,jint start ,jint end) { - MSList* history = linphone_chat_room_get_history_range((LinphoneChatRoom*)ptr, start, end); + bctbx_list_t* history = linphone_chat_room_get_history_range((LinphoneChatRoom*)ptr, start, end); return _LinphoneChatRoomImpl_getHistory(env, thiz, ptr, history); } extern "C" jobjectArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistory(JNIEnv* env ,jobject thiz ,jlong ptr ,jint limit) { - MSList* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, limit); + bctbx_list_t* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, limit); return _LinphoneChatRoomImpl_getHistory(env, thiz, ptr, history); } extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env @@ -4191,12 +4191,12 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getChatRooms(JNI ,jobject thiz ,jlong ptr) { LinphoneCore *lc = (LinphoneCore*)ptr; - const MSList* chats = linphone_core_get_chat_rooms(lc); + const bctbx_list_t* chats = linphone_core_get_chat_rooms(lc); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); - int chatsSize = ms_list_size(chats); + size_t chatsSize = bctbx_list_size(chats); jobjectArray jChats = env->NewObjectArray(chatsSize, ljb->chatRoomClass, NULL); - for (int i = 0; i < chatsSize; i++) { + for (size_t i = 0; i < chatsSize; i++) { LinphoneChatRoom *room = (LinphoneChatRoom *)chats->data; jobject jroom = getChatRoom(env, room); if (jroom != NULL) { @@ -4901,11 +4901,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv linphone_core_terminate_all_calls((LinphoneCore *) pCore); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) { - LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position); + LinphoneCall* lCall = (LinphoneCall*) bctbx_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position); return getCall(env,lCall); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) { - return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); + return (jint)bctbx_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { @@ -5088,11 +5088,11 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_tunnelGetServers jobjectArray tunnelConfigArray = NULL; if(tunnel != NULL) { - const MSList *servers = linphone_tunnel_get_servers(tunnel); - const MSList *it; + const bctbx_list_t *servers = linphone_tunnel_get_servers(tunnel); + const bctbx_list_t *it; int i; - tunnelConfigArray = env->NewObjectArray(ms_list_size(servers), tunnelConfigClass, NULL); + tunnelConfigArray = env->NewObjectArray(bctbx_list_size(servers), tunnelConfigClass, NULL); for(it = servers, i=0; it != NULL; it = it->next, i++) { LinphoneTunnelConfig *conf = (LinphoneTunnelConfig *)it->data; jobject elt = getTunnelConfig(env, conf); @@ -7029,7 +7029,7 @@ extern "C" jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_videoMultica } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNIEnv *env, jobject thiz, jlong lc, jobjectArray servers){ - MSList *l = NULL; + bctbx_list_t *l = NULL; if (servers != NULL){ int count = env->GetArrayLength(servers); @@ -7038,13 +7038,13 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNI jstring server = (jstring) env->GetObjectArrayElement(servers, i); const char *str = GetStringUTFChars(env, server); if (str){ - l = ms_list_append(l, ms_strdup(str)); + l = bctbx_list_append(l, ms_strdup(str)); ReleaseStringUTFChars(env, server, str); } } } linphone_core_set_dns_servers((LinphoneCore*)lc, l); - ms_list_free_with_data(l, ms_free); + bctbx_list_free_with_data(l, ms_free); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_enableDnsSrv(JNIEnv *env, jobject thiz, jlong lc, jboolean yesno) { @@ -7365,20 +7365,20 @@ extern "C" jboolean Java_org_linphone_core_LinphoneConferenceParamsImpl_isVideoR extern "C" jobjectArray Java_org_linphone_core_LinphoneConferenceImpl_getParticipants(JNIEnv *env, jobject thiz, jlong pconference) { - MSList *participants, *it; + bctbx_list_t *participants, *it; jclass addr_class = env->FindClass("org/linphone/core/LinphoneAddressImpl"); jmethodID addr_constructor = env->GetMethodID(addr_class, "", "(J)V"); jobjectArray jaddr_list; int i; participants = linphone_conference_get_participants((LinphoneConference *)pconference); - jaddr_list = env->NewObjectArray(ms_list_size(participants), addr_class, NULL); - for(it=participants, i=0; it; it=ms_list_next(it), i++) { + jaddr_list = env->NewObjectArray(bctbx_list_size(participants), addr_class, NULL); + for(it=participants, i=0; it; it=bctbx_list_next(it), i++) { LinphoneAddress *addr = (LinphoneAddress *)it->data; jobject jaddr = env->NewObject(addr_class, addr_constructor, (jlong)addr); env->SetObjectArrayElement(jaddr_list, i, jaddr); } - ms_list_free(participants); + bctbx_list_free(participants); return jaddr_list; } From c979886e1f6daf89699aefea714aab5a99c0ee16 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 8 Jul 2016 16:43:32 +0200 Subject: [PATCH 17/30] Add NAT policy JNI wrapper. --- coreapi/linphonecore_jni.cc | 126 +++++++++++++++++- coreapi/nat_policy.h | 2 +- java/CMakeLists.txt | 19 ++- .../org/linphone/core/LinphoneCore.java | 33 ++++- .../org/linphone/core/LinphoneNatPolicy.java | 113 ++++++++++++++++ .../org/linphone/core/LinphoneCoreImpl.java | 18 ++- .../linphone/core/LinphoneNatPolicyImpl.java | 125 +++++++++++++++++ 7 files changed, 421 insertions(+), 15 deletions(-) create mode 100644 java/common/org/linphone/core/LinphoneNatPolicy.java create mode 100644 java/impl/org/linphone/core/LinphoneNatPolicyImpl.java diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index ef27f4966..0d3a90472 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -282,16 +282,19 @@ public: chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl")); chatRoomCtrId = env->GetMethodID(chatRoomClass,"", "(J)V"); - friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));; + friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl")); friendCtrId = env->GetMethodID(friendClass,"", "(J)V"); - friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl"));; + friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl")); friendListCtrId = env->GetMethodID(friendListClass,"", "(J)V"); friendListCreatedId = env->GetMethodID(listenerClass, "friendListCreated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V"); friendListRemovedId = env->GetMethodID(listenerClass, "friendListRemoved", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V"); friendListSyncStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendList$State")); friendListSyncStateFromIntId = env->GetStaticMethodID(friendListSyncStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneFriendList$State;"); + natPolicyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneNatPolicyImpl")); + natPolicyCtrId = env->GetMethodID(natPolicyClass, "", "(J)V"); + addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl")); addressCtrId = env->GetMethodID(addressClass,"", "(J)V"); @@ -412,6 +415,9 @@ public: jclass friendListSyncStateClass; jmethodID friendListSyncStateFromIntId; + jclass natPolicyClass; + jmethodID natPolicyCtrId; + jclass addressClass; jmethodID addressCtrId; @@ -599,6 +605,29 @@ jobject getFriendList(JNIEnv *env, LinphoneFriendList *lfriendList){ return jobj; } +jobject getNatPolicy(JNIEnv *env, LinphoneNatPolicy *lNatPolicy) { + jobject jobj = 0; + + if (lNatPolicy != NULL) { + LinphoneCore *lc = lNatPolicy->lc; + LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); + + void *up = linphone_nat_policy_get_user_data(lNatPolicy); + if (up == NULL) { + jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy); + linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj)); + linphone_nat_policy_ref(lNatPolicy); + } else { + jobj = env->NewLocalRef((jobject)up); + if (jobj == NULL) { + jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy); + linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj)); + } + } + } + return jobj; +} + jobject getEvent(JNIEnv *env, LinphoneEvent *lev){ if (lev==NULL) return NULL; jobject jev=(jobject)linphone_event_get_user_data(lev); @@ -4340,6 +4369,21 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc); } +JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createNatPolicy(JNIEnv *env, jobject thiz, jlong lc) { + LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy((LinphoneCore *)lc); + return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setNatPolicy(JNIEnv *env, jobject thiz, jlong lc, jlong jpolicy) { + linphone_core_set_nat_policy((LinphoneCore *)lc, (LinphoneNatPolicy *)jpolicy); +} + +JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_getNatPolicy(JNIEnv *env, jobject thiz, jlong lc) { + LinphoneNatPolicy *nat_policy = linphone_core_get_nat_policy((LinphoneCore *)lc); + return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL; +} + + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){ const char* server = GetStringUTFChars(env, jserver); linphone_core_set_stun_server((LinphoneCore*)lc,server); @@ -7417,3 +7461,81 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_reloadMsPlugins(J linphone_core_reload_ms_plugins((LinphoneCore*)pcore, path); ReleaseStringUTFChars(env, jpath, path); } + + +JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getCore(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneCore *lc = ((LinphoneNatPolicy *)jNatPolicy)->lc; + LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); + return ljb->getCore(); +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_clear(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + linphone_nat_policy_clear(nat_policy); +} + +JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_stunEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + return (linphone_nat_policy_stun_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableStun(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + linphone_nat_policy_enable_stun(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE); +} + +JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_turnEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + return (linphone_nat_policy_turn_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableTurn(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + linphone_nat_policy_enable_turn(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE); +} + +JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_iceEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + return (linphone_nat_policy_ice_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableIce(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + linphone_nat_policy_enable_ice(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE); +} + +JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_upnpEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + return (linphone_nat_policy_upnp_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableUpnp(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + linphone_nat_policy_enable_upnp(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE); +} + +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + const char *stun_server = linphone_nat_policy_get_stun_server(nat_policy); + return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServer) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + const char *stun_server = GetStringUTFChars(env, jStunServer); + linphone_nat_policy_set_stun_server(nat_policy, stun_server); + ReleaseStringUTFChars(env, jStunServer, stun_server); +} + +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + const char *stun_server = linphone_nat_policy_get_stun_server_username(nat_policy); + return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL; +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServerUsername) { + LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy; + const char *stun_server_username = GetStringUTFChars(env, jStunServerUsername); + linphone_nat_policy_set_stun_server_username(nat_policy, stun_server_username); + ReleaseStringUTFChars(env, jStunServerUsername, stun_server_username); +} diff --git a/coreapi/nat_policy.h b/coreapi/nat_policy.h index e122508aa..b80cd2c9e 100644 --- a/coreapi/nat_policy.h +++ b/coreapi/nat_policy.h @@ -156,7 +156,7 @@ LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *poli LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy); /** - * Seth the username used to authenticate with the STUN/TURN server. + * Set the username used to authenticate with the STUN/TURN server. * The authentication will search for a LinphoneAuthInfo with this username. * If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo. * @param[in] policy LinphoneNatPolicy object diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 69d7a265b..772e553d1 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -24,28 +24,35 @@ if(ANDROID) find_package(Java REQUIRED COMPONENTS Development) set(JNI_CLASSES + "org.linphone.core.ErrorInfoImpl" "org.linphone.core.LinphoneAddressImpl" "org.linphone.core.LinphoneAuthInfoImpl" + "org.linphone.core.LinphoneBufferImpl" "org.linphone.core.LinphoneCallImpl" "org.linphone.core.LinphoneCallLogImpl" "org.linphone.core.LinphoneCallParamsImpl" "org.linphone.core.LinphoneCallStatsImpl" "org.linphone.core.LinphoneChatMessageImpl" "org.linphone.core.LinphoneChatRoomImpl" + "org.linphone.core.LinphoneConferenceImpl" + "org.linphone.core.LinphoneConferenceParamsImpl" + "org.linphone.core.LinphoneContentImpl" "org.linphone.core.LinphoneCoreFactoryImpl" "org.linphone.core.LinphoneCoreImpl" - "org.linphone.core.LinphoneFriendImpl" - "org.linphone.core.LinphoneProxyConfigImpl" - "org.linphone.core.PayloadTypeImpl" - "org.linphone.core.LpConfigImpl" - "org.linphone.core.LinphoneInfoMessageImpl" "org.linphone.core.LinphoneEventImpl" + "org.linphone.core.LinphoneFriendImpl" + "org.linphone.core.LinphoneFriendListImpl" + "org.linphone.core.LinphoneInfoMessageImpl" + "org.linphone.core.LinphoneNatPolicyImpl" + "org.linphone.core.LinphonePlayerImpl" + "org.linphone.core.LinphoneProxyConfigImpl" + "org.linphone.core.LpConfigImpl" + "org.linphone.core.PayloadTypeImpl" "org.linphone.core.PresenceActivityImpl" "org.linphone.core.PresenceModelImpl" "org.linphone.core.PresenceNoteImpl" "org.linphone.core.PresencePersonImpl" "org.linphone.core.PresenceServiceImpl" - "org.linphone.core.ErrorInfoImpl" "org.linphone.core.TunnelConfigImpl" ) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index f75523317..f63c017ef 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -170,7 +170,7 @@ public interface LinphoneCore { } /** * Describes firewall policy. - * + * @deprecated */ static public class FirewallPolicy { @@ -1116,6 +1116,7 @@ public interface LinphoneCore { * **/ void enableVideo(boolean vcap_enabled, boolean display_enabled); + /** * Returns TRUE if video is enabled, FALSE otherwise. * @@ -1127,6 +1128,7 @@ public interface LinphoneCore { * @param stun_server Stun server address and port, such as stun.linphone.org or stun.linphone.org:3478 */ void setStunServer(String stun_server); + /** * Get STUN server * @return stun server address if previously set. @@ -1136,24 +1138,49 @@ public interface LinphoneCore { /** * Sets policy regarding workarounding NATs * @param pol one of the FirewallPolicy members. + * @deprecated **/ void setFirewallPolicy(FirewallPolicy pol); + /** * @return previously set firewall policy. + * @deprecated */ FirewallPolicy getFirewallPolicy(); + + /** + * Create a new LinphoneNatPolicy object with every policies being disabled. + * @return A new LinphoneNatPolicy object. + */ + LinphoneNatPolicy createNatPolicy(); + + /** + * Set the policy to use to pass through NATs/firewalls. + * It may be overridden by a NAT policy for a specific proxy config. + * @param policy LinphoneNatPolicy object + */ + void setNatPolicy(LinphoneNatPolicy policy); + + /** + * Get The policy that is used to pass through NATs/firewalls. + * It may be overridden by a NAT policy for a specific proxy config. + * @return LinphoneNatPolicy object in use. + */ + LinphoneNatPolicy getNatPolicy(); + /** * Initiates an outgoing call given a destination LinphoneAddress * * @param addr the destination of the call {@link #LinphoneAddress }. * @param params call parameters {@link #LinphoneCallParams } * - *
The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}. . + *
The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}. * * @return a {@link #LinphoneCall LinphoneCall} object * @throws LinphoneCoreException in case of failure **/ - LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException ; + LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException; + /** * Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore. * diff --git a/java/common/org/linphone/core/LinphoneNatPolicy.java b/java/common/org/linphone/core/LinphoneNatPolicy.java new file mode 100644 index 000000000..82bfce0c5 --- /dev/null +++ b/java/common/org/linphone/core/LinphoneNatPolicy.java @@ -0,0 +1,113 @@ +/* +LinphoneNatPolicy.java +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package org.linphone.core; + +/** + * Policy to use to pass through NATs/firewalls. + * + */ +public interface LinphoneNatPolicy { + /** + * Clear a NAT policy (deactivate all protocols and unset the STUN server). + */ + void clear(); + + /** + * Tell whether STUN is enabled. + * @return Boolean value telling whether STUN is enabled. + */ + boolean stunEnabled(); + + /** + * Enable STUN. + * If TURN is also enabled, TURN will be used instead of STUN. + * @param enable Boolean value telling whether to enable STUN. + */ + void enableStun(boolean enable); + + /** + * Tell whether TURN is enabled. + * @return Boolean value telling whether TURN is enabled. + */ + boolean turnEnabled(); + + /** + * Enable TURN. + * If STUN is also enabled, it is ignored and TURN is used. + * @param enable Boolean value telling whether to enable TURN. + */ + void enableTurn(boolean enable); + + /** + * Tell whether ICE is enabled. + * @return Boolean value telling whether ICE is enabled. + */ + boolean iceEnabled(); + + /** + * Enable ICE. + * ICE can be enabled without STUN/TURN, in which case only the local candidates will be used. + * @param enable Boolean value telling whether to enable ICE. + */ + void enableIce(boolean enable); + + /** + * Tell whether uPnP is enabled. + * @return Boolean value telling whether uPnP is enabled. + */ + boolean upnpEnabled(); + + /** + * Enable uPnP. + * This has the effect to disable every other policies (ICE, STUN and TURN). + * @param enable Boolean value telling whether to enable uPnP. + */ + void enableUpnp(boolean enable); + + /** + * Get the STUN/TURN server to use with this NAT policy. + * Used when STUN or TURN are enabled. + * @return The STUN server used by this NAT policy. + */ + String getStunServer(); + + /** + * Set the STUN/TURN server to use with this NAT policy. + * Used when STUN or TURN are enabled. + * @param stun_server The STUN server to use with this NAT policy. + */ + void setStunServer(String stun_server); + + /** + * Get the username used to authenticate with the STUN/TURN server. + * The authentication will search for a LinphoneAuthInfo with this username. + * If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo. + * @return The username used to authenticate with the STUN/TURN server. + */ + String getStunServerUsername(); + + /** + * Set the username used to authenticate with the STUN/TURN server. + * The authentication will search for a LinphoneAuthInfo with this username. + * If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo. + * @param username The username used to authenticate with the STUN/TURN server. + */ + void setStunServerUsername(String username); +} diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index c2df92a72..267f0b7b8 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -111,6 +111,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native boolean isVideoSupported(long nativePtr); private native void setFirewallPolicy(long nativePtr, int enum_value); private native int getFirewallPolicy(long nativePtr); + private native Object createNatPolicy(long nativePtr); + private native void setNatPolicy(long nativePtr, long policyPtr); + private native Object getNatPolicy(long nativePtr); private native void setStunServer(long nativePtr, String stun_server); private native String getStunServer(long nativePtr); private native int updateCall(long ptrLc, long ptrCall, long ptrParams); @@ -524,12 +527,21 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized FirewallPolicy getFirewallPolicy() { return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr)); } - public synchronized String getStunServer() { - return getStunServer(nativePtr); - } public synchronized void setFirewallPolicy(FirewallPolicy pol) { setFirewallPolicy(nativePtr,pol.value()); } + public synchronized LinphoneNatPolicy createNatPolicy() { + return (LinphoneNatPolicy)createNatPolicy(nativePtr); + } + public synchronized void setNatPolicy(LinphoneNatPolicy policy) { + setNatPolicy(nativePtr, ((LinphoneNatPolicyImpl)policy).mNativePtr); + } + public synchronized LinphoneNatPolicy getNatPolicy() { + return (LinphoneNatPolicy)getNatPolicy(nativePtr); + } + public synchronized String getStunServer() { + return getStunServer(nativePtr); + } public synchronized void setStunServer(String stunServer) { setStunServer(nativePtr, stunServer); } diff --git a/java/impl/org/linphone/core/LinphoneNatPolicyImpl.java b/java/impl/org/linphone/core/LinphoneNatPolicyImpl.java new file mode 100644 index 000000000..302bda306 --- /dev/null +++ b/java/impl/org/linphone/core/LinphoneNatPolicyImpl.java @@ -0,0 +1,125 @@ +/* +LinphoneNatPolicyImpl.java +Copyright (C) 2015 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package org.linphone.core; + +public class LinphoneNatPolicyImpl implements LinphoneNatPolicy { + protected final long mNativePtr; + + private native Object getCore(long nativePtr); + private native void clear(long nativePtr); + private native boolean stunEnabled(long nativePtr); + private native void enableStun(long nativePtr, boolean enable); + private native boolean turnEnabled(long nativePtr); + private native void enableTurn(long nativePtr, boolean enable); + private native boolean iceEnabled(long nativePtr); + private native void enableIce(long nativePtr, boolean enable); + private native boolean upnpEnabled(long nativePtr); + private native void enableUpnp(long nativePtr, boolean enable); + private native String getStunServer(long nativePtr); + private native void setStunServer(long nativePtr, String stun_server); + private native String getStunServerUsername(long nativePtr); + private native void setStunServerUsername(long nativePtr, String username); + + protected LinphoneNatPolicyImpl(long nativePtr) { + mNativePtr = nativePtr; + } + + private synchronized LinphoneCore getCore() { + return (LinphoneCore)getCore(mNativePtr); + } + + public void clear() { + synchronized(getCore()) { + clear(mNativePtr); + } + } + + public boolean stunEnabled() { + synchronized(getCore()) { + return stunEnabled(mNativePtr); + } + } + + public void enableStun(boolean enable) { + synchronized(getCore()) { + enableStun(mNativePtr, enable); + } + } + + public boolean turnEnabled() { + synchronized(getCore()) { + return turnEnabled(mNativePtr); + } + } + + public void enableTurn(boolean enable) { + synchronized(getCore()) { + enableTurn(mNativePtr, enable); + } + } + + public boolean iceEnabled() { + synchronized(getCore()) { + return iceEnabled(mNativePtr); + } + } + + public void enableIce(boolean enable) { + synchronized(getCore()) { + enableIce(mNativePtr, enable); + } + } + + public boolean upnpEnabled() { + synchronized(getCore()) { + return upnpEnabled(mNativePtr); + } + } + + public void enableUpnp(boolean enable) { + synchronized(getCore()) { + enableUpnp(mNativePtr, enable); + } + } + + public String getStunServer() { + synchronized(getCore()) { + return getStunServer(mNativePtr); + } + } + + public void setStunServer(String stun_server) { + synchronized(getCore()) { + setStunServer(mNativePtr, stun_server); + } + } + + public String getStunServerUsername() { + synchronized(getCore()) { + return getStunServerUsername(mNativePtr); + } + } + + public void setStunServerUsername(String username) { + synchronized(getCore()) { + setStunServerUsername(mNativePtr, username); + } + } +} From eb27b8d930fb84899ebbacf7b26b89fe80c197a0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 11 Jul 2016 10:00:13 +0200 Subject: [PATCH 18/30] Add comment about non-existing _LinphoneConference struct. --- coreapi/conference.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coreapi/conference.h b/coreapi/conference.h index b1867adee..269e442f1 100644 --- a/coreapi/conference.h +++ b/coreapi/conference.h @@ -39,12 +39,15 @@ extern "C" { /** * LinphoneConference class + * The _LinphoneConference struct does not exists, it's the Conference C++ class that is used behind */ typedef struct _LinphoneConference LinphoneConference; + /** * Parameters for initialization of conferences + * The _LinphoneConferenceParams struct does not exists, it's the ConferenceParams C++ class that is used behind */ -typedef struct _LinphoneCorferenceParams LinphoneConferenceParams; +typedef struct _LinphoneConferenceParams LinphoneConferenceParams; From fd25dd44ce3a2c2a16db0273c86446b3bf19d2d1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 11 Jul 2016 10:25:44 +0200 Subject: [PATCH 19/30] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 47fad95d1..802950d57 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 47fad95d1b25b19ca2cb0db822f46d0098fc5461 +Subproject commit 802950d57e7c709a10fdc9dfef21d4031657ed60 From cad62d59a0532cfa564057cdb657c1d76645f73f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 11 Jul 2016 13:37:08 +0200 Subject: [PATCH 20/30] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 802950d57..2204eb636 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 802950d57e7c709a10fdc9dfef21d4031657ed60 +Subproject commit 2204eb636cbc05aea0da923881e2ea3bdd795587 From 489c03a89c4c28041c3cda8596f5c4fb8af8eed0 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 11 Jul 2016 15:22:07 +0200 Subject: [PATCH 21/30] Fix issue with trim function --- coreapi/sal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/coreapi/sal.c b/coreapi/sal.c index 05b472fd1..49cc2f153 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -853,12 +853,13 @@ const char* sal_privacy_to_string(SalPrivacy privacy) { } } -static void remove_trailing_spaces(char *line){ - size_t i; - for(i=strlen(line)-1;i>=0;--i){ - if (isspace(line[i])) line[i]='\0'; - else break; +static void remove_trailing_spaces(char *line) { + size_t size = size = strlen(line); + char *end = line + size - 1; + while (end >= line && isspace(*end)) { + end--; } + *(end + 1) = '\0'; } static int line_get_value(const char *input, const char *key, char *value, size_t value_size, size_t *read){ From bd503ea8521903376f0ee5af0dbb24052c17f6ea Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 11 Jul 2016 15:37:02 +0200 Subject: [PATCH 22/30] frienlist.c: fix sort (use display name when available) --- gtk/friendlist.c | 20 +++++++++++++------- mediastreamer2 | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 2128ace66..f0b53b8e6 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -611,7 +611,7 @@ static int get_friend_weight(const LinphoneFriend *lf){ } static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *lf2){ - int w1,w2; + int w1,w2,ret; w1=get_friend_weight(lf1); w2=get_friend_weight(lf2); if (w1==w2){ @@ -619,13 +619,19 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend * const LinphoneAddress *addr1,*addr2; addr1=linphone_friend_get_address(lf1); addr2=linphone_friend_get_address(lf2); - u1=linphone_address_get_username(addr1); - u2=linphone_address_get_username(addr2); - if (u1 && u2) return strcasecmp(u1,u2); - if (u1) return 1; - else return -1; + u1=linphone_address_get_display_name(addr1) ? linphone_address_get_display_name(addr1) : linphone_address_get_username(addr1); + u2=linphone_address_get_display_name(addr2) ? linphone_address_get_display_name(addr2) : linphone_address_get_username(addr2); + if (u1 && u2) { + ret = strcasecmp(u1,u2); + } else if (u1) { + ret = 1; + } else { + ret = -1; + } + } else { + ret = w2-w1; } - return w2-w1; + return ret; } static bctbx_list_t *sort_friend_list(const bctbx_list_t *friends){ diff --git a/mediastreamer2 b/mediastreamer2 index 2204eb636..2f39b407c 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2204eb636cbc05aea0da923881e2ea3bdd795587 +Subproject commit 2f39b407c0291b7b36e8cd061f33d057bf2e1178 From 9ed5462f9041a5533aa4863bcb829357f57ad20b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 11 Jul 2016 18:23:01 +0200 Subject: [PATCH 23/30] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 2f39b407c..4763aeb32 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2f39b407c0291b7b36e8cd061f33d057bf2e1178 +Subproject commit 4763aeb323efe6bf79974cbaf227f80b7aad92a9 From 2e13870a546aab079d3cb79c754115b26a23db64 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 12 Jul 2016 13:43:41 +0200 Subject: [PATCH 24/30] tester: do not gather logs when creating test account, that pollute output too much for something we don't care about This reduces logs from 800K lines to 300K lines for the whole suite. Fair enough. --- tester/liblinphone_tester.c | 1 + tester/presence_server_tester.c | 2 +- tester/rcfiles/pauline_rc | 1 + tester/rcfiles/pauline_tcp_rc | 1 + tester/tester.c | 12 +++++++++++- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 17503ac0a..45f91fbed 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -229,6 +229,7 @@ int main (int argc, char *argv[]) #endif liblinphone_tester_init(NULL); + linphone_core_set_log_level(ORTP_FATAL); for(i = 1; i < argc; ++i) { if (strcmp(argv[i], "--verbose") == 0) { diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c index 25034f834..43c2cd326 100644 --- a/tester/presence_server_tester.c +++ b/tester/presence_server_tester.c @@ -685,7 +685,7 @@ static void long_term_presence_list(void) { LinphoneFriend *f1, *f2; LinphoneFriendList* friends; LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - enable_publish(pauline, TRUE); + enable_publish(pauline, FALSE); enable_deflate_content_encoding(pauline, FALSE); friends = linphone_core_create_friend_list(pauline->lc); diff --git a/tester/rcfiles/pauline_rc b/tester/rcfiles/pauline_rc index f2f2c94d5..c5f1fed4d 100644 --- a/tester/rcfiles/pauline_rc +++ b/tester/rcfiles/pauline_rc @@ -15,6 +15,7 @@ realm=sip.example.org [proxy_0] +realm=sip.example.org reg_proxy=sip2.linphone.org;transport=tls reg_route=sip2.linphone.org;transport=tls reg_identity=sip:pauline@sip.example.org diff --git a/tester/rcfiles/pauline_tcp_rc b/tester/rcfiles/pauline_tcp_rc index ff36234b1..5c6b183bd 100644 --- a/tester/rcfiles/pauline_tcp_rc +++ b/tester/rcfiles/pauline_tcp_rc @@ -15,6 +15,7 @@ realm=sip.example.org [proxy_0] +realm=sip.example.org reg_proxy=sip2.linphone.org;transport=tcp reg_route=sip2.linphone.org;transport=tcp reg_identity=sip:pauline@sip.example.org diff --git a/tester/tester.c b/tester/tester.c index 5c5f8c97a..416cb7705 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -390,19 +390,26 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies /*now that stun server resolution is done, we can start registering*/ linphone_core_set_network_reachable(mgr->lc, TRUE); } + } LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) { + int old_log_level = ortp_get_log_level_mask(NULL); LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); + linphone_core_set_log_level(ORTP_ERROR); linphone_core_manager_init(manager, rc_file); linphone_core_manager_start(manager, TRUE); + linphone_core_set_log_level(old_log_level); return manager; } LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies) { + int old_log_level = ortp_get_log_level_mask(NULL); LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); + linphone_core_set_log_level(ORTP_ERROR); linphone_core_manager_init(manager, rc_file); linphone_core_manager_start(manager, check_for_proxies); + linphone_core_set_log_level(old_log_level); return manager; } @@ -414,6 +421,8 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){ } void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { + int old_log_level = ortp_get_log_level_mask(NULL); + linphone_core_set_log_level(ORTP_ERROR); if (mgr->stat.last_received_chat_message) { linphone_chat_message_unref(mgr->stat.last_received_chat_message); } @@ -423,7 +432,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { char *chatdb = ms_strdup(linphone_core_get_chat_database_path(mgr->lc)); if (!liblinphone_tester_keep_record_files && record_file){ if ((bc_get_number_of_failures()-mgr->number_of_bcunit_error_at_creation)>0) { - ms_message ("Test has failed, keeping recorded file [%s]",record_file); + ms_error("Test has failed, keeping recorded file [%s]",record_file); } else { unlink(record_file); } @@ -439,6 +448,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { } manager_count--; + linphone_core_set_log_level(old_log_level); } void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr) { From e45b4fe4eb58eed27ece1ca9c33c08be35a7d993 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 12 Jul 2016 14:38:10 +0200 Subject: [PATCH 25/30] Updated ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 4763aeb32..81c125798 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 4763aeb323efe6bf79974cbaf227f80b7aad92a9 +Subproject commit 81c1257984719a42bfc81dfe443339502b38e40b From 02e1a3fcb15419693ac6b39ab7a0cbcf27c992e0 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 12 Jul 2016 15:46:29 +0200 Subject: [PATCH 26/30] tester: install missing stuff --- tester/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 08d8950e8..057592c30 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -129,6 +129,7 @@ set(VCARD_FILES set(OTHER_FILES tester_hosts + local_tester_hosts messages.db ) From 5dc6c5cb105a73e9a34bbad5e75fe6b2eda36187 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 13 Jul 2016 13:45:05 +0200 Subject: [PATCH 27/30] Add API and config parameter to enable/disable DNS search. --- coreapi/bellesip_sal/sal_impl.c | 8 ++++++++ coreapi/linphonecore.c | 12 ++++++++++++ coreapi/linphonecore.h | 16 ++++++++++++++++ include/sal/sal.h | 2 ++ 4 files changed, 38 insertions(+) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index aabee27f7..e9f0a7b23 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -877,6 +877,14 @@ bool_t sal_dns_srv_enabled(const Sal *sal) { return (bool_t)belle_sip_stack_dns_srv_enabled(sal->stack); } +void sal_enable_dns_search(Sal *sal, bool_t enable) { + belle_sip_stack_enable_dns_search(sal->stack, (unsigned char)enable); +} + +bool_t sal_dns_search_enabled(const Sal *sal) { + return (bool_t)belle_sip_stack_dns_search_enabled(sal->stack); +} + void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file) { belle_sip_stack_set_dns_user_hosts_file(sal->stack, hosts_file); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 1e142de88..e8a22387a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -790,6 +790,8 @@ static void net_config_read (LinphoneCore *lc) } tmp = lp_config_get_int(lc->config, "net", "dns_srv_enabled", 1); linphone_core_enable_dns_srv(lc, tmp); + tmp = lp_config_get_int(lc->config, "net", "dns_search_enabled", 1); + linphone_core_enable_dns_search(lc, tmp); /* This is to filter out unsupported firewall policies */ if (nat_policy_ref == NULL) @@ -1523,6 +1525,16 @@ bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc) { return sal_dns_srv_enabled(lc->sal); } +void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable) { + sal_enable_dns_search(lc->sal, enable); + if (linphone_core_ready(lc)) + lp_config_set_int(lc->config, "net", "dns_search_enabled", enable ? 1 : 0); +} + +bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc) { + return sal_dns_search_enabled(lc->sal); +} + int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ return lc->net_conf.download_bw; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index eafc3512d..8adc07c7e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -2754,6 +2754,22 @@ LINPHONE_PUBLIC void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enabl */ LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc); +/** + * Enable or disable DNS search (use of local domain if the fully qualified name did return results). + * @param[in] lc #LinphoneCore object. + * @param[in] enable TRUE to enable DNS search, FALSE to disable it. + * @ingroup media_parameters + */ +LINPHONE_PUBLIC void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable); + +/** + * Tells whether DNS search (use of local domain if the fully qualified name did return results) is enabled. + * @param[in] lc #LinphoneCore object. + * @return TRUE if DNS search is enabled, FALSE if disabled. + * @ingroup media_parameters + */ +LINPHONE_PUBLIC bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc); + /** * Forces liblinphone to use the supplied list of dns servers, instead of system's ones. * @param[in] lc #LinphoneCore object. diff --git a/include/sal/sal.h b/include/sal/sal.h index b885cf6a1..8d35a621d 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -870,6 +870,8 @@ LINPHONE_PUBLIC int sal_get_transport_timeout(const Sal* sal); void sal_set_dns_servers(Sal *sal, const MSList *servers); LINPHONE_PUBLIC void sal_enable_dns_srv(Sal *sal, bool_t enable); LINPHONE_PUBLIC bool_t sal_dns_srv_enabled(const Sal *sal); +LINPHONE_PUBLIC void sal_enable_dns_search(Sal *sal, bool_t enable); +LINPHONE_PUBLIC bool_t sal_dns_search_enabled(const Sal *sal); LINPHONE_PUBLIC void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file); LINPHONE_PUBLIC const char *sal_get_dns_user_hosts_file(const Sal *sal); unsigned int sal_get_random(void); From d3e8feeb605b087e33c628ebfd0c79e84d598120 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 15 Jul 2016 10:55:24 +0200 Subject: [PATCH 28/30] JNI wrapper for lime methods --- coreapi/linphonecore_jni.cc | 21 ++++++++++ .../org/linphone/core/LinphoneCore.java | 42 +++++++++++++++++++ .../org/linphone/core/LinphoneCoreImpl.java | 15 +++++++ 3 files changed, 78 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 0d3a90472..94d92503a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2475,6 +2475,27 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandat linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno); } +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isLimeEncryptionAvailable (JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return (jboolean) linphone_core_lime_available((LinphoneCore*)lc); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getLimeEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return (jint)linphone_core_lime_enabled((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setLimeEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jint menc) { + linphone_core_enable_lime((LinphoneCore*)lc,(LinphoneLimeState)menc); +} + /* * Class: org_linphone_core_LinphoneCoreImpl * Method: disableChat diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index f63c017ef..e13e75a28 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -561,6 +561,42 @@ public interface LinphoneCore { return mStringValue; } } + static public final class LinphoneLimeState { + + static private Vector values = new Vector(); + /** + * Disabled + */ + static public final LinphoneLimeState Disabled = new LinphoneLimeState(0, "None"); + /** + * Mandatory + */ + static public final LinphoneLimeState Mandatory = new LinphoneLimeState(1,"Mandatory"); + /** + * Preferred + */ + static public final LinphoneLimeState Preferred = new LinphoneLimeState(2,"Preferred"); + protected final int mValue; + private final String mStringValue; + + + private LinphoneLimeState(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + public static LinphoneLimeState fromInt(int value) { + + for (int i=0; i Date: Fri, 15 Jul 2016 14:26:05 +0200 Subject: [PATCH 29/30] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 81c125798..bddafa836 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 81c1257984719a42bfc81dfe443339502b38e40b +Subproject commit bddafa836a00c848442670af6fd50c934a1e669f From 554635c53bc22ca449b8f74f50836afffe9cbdb9 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 15 Jul 2016 17:03:16 +0200 Subject: [PATCH 30/30] Fix crash when downloading chat message encrypted with lime using file body handler --- coreapi/chat.c | 2 +- coreapi/chat_file_transfer.c | 42 ++++++++++++++++++++++++++---------- coreapi/message_storage.c | 4 ++-- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index cf8e8cb48..df2c5a0fb 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -590,7 +590,7 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength); linphone_content_set_key( msg->file_transfer_information, (char *)keyBuffer, - keyLength); /* duplicate key value into the linphone content private structure */ + strlen((char *)keyBuffer)); /* duplicate key value into the linphone content private structure */ xmlFree(keyb64); free(keyBuffer); } diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 1d6eade51..2351aa59c 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -441,18 +441,38 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle int code = belle_http_response_get_status_code(event->response); if (code == 200) { LinphoneCore *lc = msg->chat_room->lc; - /* if the file was encrypted, finish the decryption and free context */ - if (linphone_content_get_key(msg->file_transfer_information) != NULL) { - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, - NULL, NULL); - } - /* file downloaded succesfully, call again the callback with size at zero */ - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new(); - linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, - lb); - linphone_buffer_unref(lb); + if (msg->file_transfer_filepath == NULL) { + /* if the file was encrypted, finish the decryption and free context */ + if (linphone_content_get_key(msg->file_transfer_information) != NULL) { + lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + } + if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { + LinphoneBuffer *lb = linphone_buffer_new(); + linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); + linphone_buffer_unref(lb); + } else { + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); + } } else { + if (linphone_content_get_key(msg->file_transfer_information) != NULL) { + bctbx_vfs_t *vfs = bctbx_vfs_get_default(); + bctbx_vfs_file_t *decrypted_file; + bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); + int64_t encrypted_file_size = bctbx_file_size(encrypted_file); + char *encrypted_content = bctbx_malloc(encrypted_file_size); + char *decrypted_content = bctbx_malloc(encrypted_file_size); + bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); + bctbx_file_close(encrypted_file); + lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), + (unsigned char *)linphone_content_get_key(msg->file_transfer_information), + encrypted_file_size, decrypted_content, encrypted_content); + lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); + bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); + bctbx_file_close(decrypted_file); + bctbx_free(encrypted_content); + bctbx_free(decrypted_content); + } linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); } linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 2fd76e053..ce55ddf85 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -138,8 +138,8 @@ static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* * | 4 | encoding * | 5 | size * | 6 | data (currently not stored) - * | 7 | size - * | 8 | size + * | 7 | key size + * | 8 | key */ // Callback for sql request when getting linphone content static int callback_content(void *data, int argc, char **argv, char **colName) {