Merge branch 'master' of git.linphone.org:linphone

This commit is contained in:
François Grisez 2017-01-13 14:43:54 +01:00
commit 6160b6dbe1
7 changed files with 73 additions and 41 deletions

View file

@ -392,6 +392,23 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
}
}
if (!identity) {
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(cr->lc, cr->peer_url);
if (proxy) {
identity = linphone_proxy_config_get_identity(proxy);
} else {
identity = linphone_core_get_primary_contact(cr->lc);
}
}
if (msg->from){
/*
* BUG
* the file transfer message constructor sets the from, but doesn't do it as well as here.
*/
linphone_address_destroy(msg->from);
}
msg->from = linphone_address_new(identity);
if (imee) {
LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee);
LinphoneImEncryptionEngineCbsOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs);
@ -401,11 +418,6 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
}
if (op == NULL) {
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(cr->lc, cr->peer_url);
if (proxy) {
identity = linphone_proxy_config_get_identity(proxy);
} else
identity = linphone_core_get_primary_contact(cr->lc);
/*sending out of calls*/
msg->op = op = sal_op_new(cr->lc->sal);
linphone_configure_op(cr->lc, op, cr->peer_url, msg->custom_headers,
@ -435,19 +447,11 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
ms_free(peer_uri);
}
if (msg->from){
/*
* BUG
* the file transfer message constructor sets the from, but doesn't do it as well as here.
*/
linphone_address_destroy(msg->from);
}
if (msg->message && message_not_encrypted && strcmp(msg->message, message_not_encrypted) != 0) {
// We replace the encrypted message by the original one so it can be correctly stored and displayed by the application
ms_free(msg->message);
msg->message = ms_strdup(message_not_encrypted);
}
msg->from = linphone_address_new(identity);
msg->message_id = ms_strdup(sal_op_get_call_id(op)); /* must be known at that time */
msg->storage_id = linphone_chat_message_store(msg);

View file

@ -1009,8 +1009,10 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
xmlFreeDoc(cacheXml);
}
} else {
ms_warning("Unable to access ZRTP ZID cache to encrypt message");
errcode = 488;
if (linphone_core_lime_enabled(lc) == LinphoneLimeMandatory) {
ms_warning("Unable to access ZRTP ZID cache to encrypt message");
errcode = 488;
}
}
}
return errcode;

View file

@ -3097,7 +3097,8 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, const Linph
barmsg=ortp_strdup_printf("%s %s", _("Contacting"), real_url);
linphone_core_notify_display_status(lc,barmsg);
ms_free(barmsg);
linphone_call_ref(call); /* Take a ref because sal_call() may destroy the call if no SIP transport is available */
err=sal_call(call->op,from,real_url);
if (err < 0){
@ -3120,6 +3121,7 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, const Linph
linphone_call_set_state(call,LinphoneCallOutgoingProgress,"Outgoing call in progress");
end:
linphone_call_unref(call); /* Revert the ref taken before calling sal_call() */
ms_free(real_url);
ms_free(from);
return err;

View file

@ -537,7 +537,7 @@ bool_t linphone_proxy_config_quality_reporting_enabled(LinphoneProxyConfig *cfg)
return cfg->quality_reporting_enabled;
}
void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, uint8_t interval) {
void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, int interval) {
cfg->quality_reporting_interval = interval;
}

View file

@ -202,7 +202,7 @@ LINPHONE_PUBLIC const char *linphone_proxy_config_get_quality_reporting_collecto
* @param[in] cfg #LinphoneProxyConfig object.
* @param[in] interval The interval in seconds, 0 means interval reports are disabled.
*/
LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, uint8_t interval);
LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, int interval);
/**
* Get the interval between interval reports when using quality reporting.

View file

@ -147,6 +147,7 @@ Platform::String^ NativeTester::testName(Platform::String^ suiteName, int testIn
char csuitename[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(csuitename, suitename.c_str(), sizeof(csuitename));
const char *cname = bc_tester_test_name(csuitename, testIndex);
if (cname == NULL) return ref new String();
wchar_t wcname[MAX_SUITE_NAME_SIZE];
mbstowcs(wcname, cname, sizeof(wcname));
return ref new String(wcname);

View file

@ -647,8 +647,8 @@ static void file_transfer_using_external_body_url(void) {
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
/* make sure lime is disabled */
linphone_core_enable_lime(marie->lc, FALSE);
linphone_core_enable_lime(pauline->lc, FALSE);
linphone_core_enable_lime(marie->lc, LinphoneLimeDisabled);
linphone_core_enable_lime(pauline->lc, LinphoneLimeDisabled);
/* create a chatroom on pauline's side */
chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
@ -854,8 +854,8 @@ static void _is_composing_notification(bool_t lime_enabled) {
goto end;
}
/* make sure lime is enabled */
linphone_core_enable_lime(marie->lc, 1);
linphone_core_enable_lime(pauline->lc, 1);
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
linphone_core_enable_lime(pauline->lc, LinphoneLimeMandatory);
/* set the zid caches files : create two ZID cache from this valid one inserting the auto-generated sip URI for the peer account as keys in ZID cache are indexed by peer sip uri */
ZIDCacheMarieFD = fopen_from_write_dir("tmpZIDCacheMarie.xml", "w");
@ -1032,8 +1032,8 @@ static void _im_error_delivery_notification(bool_t online) {
}
/* Make sure lime is enabled */
linphone_core_enable_lime(marie->lc, 1);
linphone_core_enable_lime(pauline->lc, 1);
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
linphone_core_enable_lime(pauline->lc, LinphoneLimeMandatory);
/* Set the zid cache files : create two ZID cache from this valid one inserting the auto-generated sip URI for the peer account as keys in ZID cache are indexed by peer sip uri. */
ZIDCacheMarieFD = fopen_from_write_dir("tmpZIDCacheMarie.xml", "w");
@ -1112,8 +1112,8 @@ static void lime_text_message(void) {
goto end;
}
/* make sure lime is enabled */
linphone_core_enable_lime(marie->lc, 1);
linphone_core_enable_lime(pauline->lc, 1);
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
linphone_core_enable_lime(pauline->lc, LinphoneLimeMandatory);
/* set the zid caches files : create two ZID cache from this valid one inserting the auto-generated sip URI for the peer account as keys in ZID cache are indexed by peer sip uri */
ZIDCacheMarieFD = fopen_from_write_dir("tmpZIDCacheMarie.xml", "w");
@ -1150,7 +1150,7 @@ end:
linphone_core_manager_destroy(pauline);
}
static void lime_text_message_to_non_lime(void) {
static void lime_text_message_to_non_lime(bool_t sender_policy_mandatory, bool_t lime_key_available) {
FILE *ZIDCachePaulineFD;
LinphoneChatRoom* chat_room;
char* filepath;
@ -1162,24 +1162,32 @@ static void lime_text_message_to_non_lime(void) {
goto end;
}
/* make sure lime is enabled */
linphone_core_enable_lime(marie->lc, 0);
linphone_core_enable_lime(pauline->lc, 1);
linphone_core_enable_lime(marie->lc, LinphoneLimeDisabled);
linphone_core_enable_lime(pauline->lc, sender_policy_mandatory ? LinphoneLimeMandatory : LinphoneLimePreferred);
/* set the zid caches files : create two ZID cache from this valid one inserting the auto-generated sip URI for the peer account as keys in ZID cache are indexed by peer sip uri */
ZIDCachePaulineFD = fopen_from_write_dir("tmpZIDCachePauline.xml", "w");
fprintf(ZIDCachePaulineFD, pauline_zid_cache, linphone_address_as_string_uri_only(marie->identity), linphone_address_as_string_uri_only(marie->identity));
fclose(ZIDCachePaulineFD);
if (lime_key_available) {
/* set the zid caches files : create two ZID cache from this valid one inserting the auto-generated sip URI for the peer account as keys in ZID cache are indexed by peer sip uri */
ZIDCachePaulineFD = fopen_from_write_dir("tmpZIDCachePauline.xml", "w");
fprintf(ZIDCachePaulineFD, pauline_zid_cache, linphone_address_as_string_uri_only(marie->identity), linphone_address_as_string_uri_only(marie->identity));
fclose(ZIDCachePaulineFD);
filepath = bc_tester_file("tmpZIDCachePauline.xml");
linphone_core_set_zrtp_secrets_file(pauline->lc, filepath);
bc_free(filepath);
filepath = bc_tester_file("tmpZIDCachePauline.xml");
linphone_core_set_zrtp_secrets_file(pauline->lc, filepath);
bc_free(filepath);
}
chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
linphone_chat_room_send_message(chat_room,"Bla bla bla bla");
//since we cannot decrypt message, we should not receive any message
BC_ASSERT_FALSE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,0, int, "%d");
if (sender_policy_mandatory || lime_key_available) {
BC_ASSERT_FALSE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_FALSE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageNotDelivered,1));
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy, 0, int, "%d");
} else {
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy, 1, int, "%d");
}
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity));
end:
@ -1187,6 +1195,19 @@ end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void lime_text_message_to_non_lime_mandatory_policy(void) {
lime_text_message_to_non_lime(TRUE, TRUE);
}
static void lime_text_message_to_non_lime_preferred_policy(void) {
lime_text_message_to_non_lime(FALSE, TRUE);
}
static void lime_text_message_to_non_lime_preferred_policy_2(void) {
lime_text_message_to_non_lime(FALSE, FALSE);
}
void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download) {
FILE *ZIDCacheMarieFD, *ZIDCachePaulineFD;
LinphoneCoreManager *marie, *pauline;
@ -1209,8 +1230,8 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st
goto end;
}
/* make sure lime is enabled */
linphone_core_enable_lime(marie->lc, 1);
linphone_core_enable_lime(pauline->lc, 1);
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
linphone_core_enable_lime(pauline->lc, LinphoneLimeMandatory);
if (!encrypt_file) {
LpConfig *pauline_lp = linphone_core_get_config(pauline->lc);
lp_config_set_int(pauline_lp,"sip","lime_for_file_sharing",0);
@ -2271,7 +2292,9 @@ test_t message_tests[] = {
TEST_ONE_TAG("IM error delivery notification online", im_error_delivery_notification_online, "LIME"),
TEST_ONE_TAG("IM error delivery notification offline", im_error_delivery_notification_offline, "LIME"),
TEST_ONE_TAG("Lime text message", lime_text_message, "LIME"),
TEST_ONE_TAG("Lime text message to non lime", lime_text_message_to_non_lime, "LIME"),
TEST_ONE_TAG("Lime text message to non lime", lime_text_message_to_non_lime_mandatory_policy, "LIME"),
TEST_ONE_TAG("Lime text message to non lime with preferred policy", lime_text_message_to_non_lime_preferred_policy, "LIME"),
TEST_ONE_TAG("Lime text message to non lime with preferred policy 2", lime_text_message_to_non_lime_preferred_policy_2, "LIME"),
TEST_ONE_TAG("Lime transfer message", lime_transfer_message, "LIME"),
TEST_ONE_TAG("Lime transfer message 2", lime_transfer_message_2, "LIME"),
TEST_ONE_TAG("Lime transfer message 3", lime_transfer_message_3, "LIME"),