Merge remote-tracking branch 'origin/master' into dev_continuous_bw_measurement

This commit is contained in:
Sylvain Berfini 2017-05-29 11:13:41 +02:00
commit f7dbe3ba78
14 changed files with 239 additions and 36 deletions

View file

@ -676,6 +676,10 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_exist_linphone(
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: is_account_exist (%s=%s, domain=%s)",
(creator->username) ? "username" : "phone number",
(creator->username) ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account",
LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number,
LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg),
@ -712,6 +716,12 @@ static LinphoneXmlRpcRequest * _create_account_with_phone_custom(LinphoneAccount
if (!creator->phone_number) {
return NULL;
}
ms_debug("Account creator: create_account_with_phone (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
(creator->username) ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg),
creator->language);
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_phone_account",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number,
@ -728,6 +738,11 @@ static LinphoneXmlRpcRequest * _create_account_with_email_custom(LinphoneAccount
if (!creator->username || !creator->email || !creator->password) {
return NULL;
}
ms_debug("Account creator: create_account_with_email (username=%s, email=%s, domain=%s)",
creator->username,
creator->email,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_email_account",
LinphoneXmlRpcArgString, creator->username,
LinphoneXmlRpcArgString, creator->email,
@ -787,13 +802,18 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_account_linphone(
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: activate_account_phone (phone number=%s, username=%s, activation code=%s, domain=%s)",
creator->phone_number,
creator->username ? creator->username : creator->phone_number,
creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_account",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number,
LinphoneXmlRpcArgString, creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg),
LinphoneXmlRpcArgNone);
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number,
LinphoneXmlRpcArgString, creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg),
LinphoneXmlRpcArgNone);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
@ -811,11 +831,16 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_email_account_lin
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: activate_account_email (username=%s, activation code=%s, domain=%s)",
creator->username,
creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_email_account",
LinphoneXmlRpcArgString, creator->username,
LinphoneXmlRpcArgString, creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg),
LinphoneXmlRpcArgNone);
LinphoneXmlRpcArgString, creator->username,
LinphoneXmlRpcArgString, creator->activation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg),
LinphoneXmlRpcArgNone);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom);
@ -847,6 +872,10 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated_linph
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: is_account_activated (username=%s, domain=%s)",
creator->username ? creator->username : creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_account_activated",
LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number,
LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg),
@ -885,6 +914,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used_linph
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: is_phone_number_used (phone number=%s, domain=%s)",
creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_phone_number_used",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg),
@ -920,6 +954,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: link_phone_number_with_account (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg),
creator->language);
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "link_phone_number_with_account",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, creator->username,
@ -952,6 +993,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked_linphone
if (!creator->username || !linphone_proxy_config_get_domain(creator->proxy_cfg)) {
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: is_account_linked (username=%s, domain=%s)",
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account",
LinphoneXmlRpcArgString, creator->username,
LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg),
@ -985,6 +1031,13 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: activate_phone_number_link (phone number=%s, username=%s, activation code=%s, domain=%s)",
creator->phone_number,
creator->username,
creator->acactivation_code,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_number_link",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, creator->username,
@ -1028,6 +1081,12 @@ LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account_linp
}
return LinphoneAccountCreatorStatusMissingArguments;
}
ms_debug("Account creator: recover_phone_account (phone number=%s, domain=%s, language=%s)",
creator->phone_number,
linphone_proxy_config_get_domain(creator->proxy_cfg),
creator->language);
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "recover_phone_account",
LinphoneXmlRpcArgString, creator->phone_number,
LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg),
@ -1080,6 +1139,10 @@ LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(L
const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) );
const char * new_ha1 = ms_strdup(ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), new_pwd));
ms_debug("Account creator: update_password (username=%s, domain=%s)",
creator->username,
linphone_proxy_config_get_domain(creator->proxy_cfg));
request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "update_hash",
LinphoneXmlRpcArgString, username,
LinphoneXmlRpcArgString, ha1,

View file

@ -1015,8 +1015,9 @@ static void call_failure(SalOp *op){
}
/* Stop ringing */
bool_t ring_during_early_media = linphone_core_get_ring_during_incoming_early_media(lc);
while(calls) {
if (((LinphoneCall *)calls->data)->state == LinphoneCallIncomingReceived) {
if (((LinphoneCall *)calls->data)->state == LinphoneCallIncomingReceived || (ring_during_early_media && ((LinphoneCall *)calls->data)->state == LinphoneCallIncomingEarlyMedia)) {
stop_ringing = FALSE;
break;
}
@ -1138,7 +1139,6 @@ static void register_failure(SalOp *op){
if (cfg->long_term_event){
/*prevent publish to be sent now until registration gets successful*/
linphone_event_terminate(cfg->long_term_event);
linphone_event_unref(cfg->long_term_event);
cfg->long_term_event=NULL;
cfg->send_publish=cfg->publish;
}

View file

@ -459,8 +459,20 @@ const LinphoneAddress * linphone_friend_list_get_rls_address(const LinphoneFrien
const LinphoneAddress * _linphone_friend_list_get_rls_address(const LinphoneFriendList *list) {
if (list->rls_addr)
return list->rls_addr;
else if (list->lc)
else if (list->lc) {
const char* rls_uri = lp_config_get_string(list->lc->config, "sip", "rls_uri", NULL);
if (list->lc->default_rls_addr)
linphone_address_unref(list->lc->default_rls_addr);
list->lc->default_rls_addr=NULL;
if (rls_uri) {
/*to make sure changes in config are used if any*/
list->lc->default_rls_addr = linphone_address_new(rls_uri);
}
return list->lc->default_rls_addr;
}
else
return NULL;
}

View file

@ -1109,18 +1109,18 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
linphone_call_init_stats(call->audio_stats, LINPHONE_CALL_STATS_AUDIO);
linphone_call_init_stats(call->video_stats, LINPHONE_CALL_STATS_VIDEO);
linphone_call_init_stats(call->text_stats, LINPHONE_CALL_STATS_TEXT);
if (call->dest_proxy == NULL) {
/* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */
call->dest_proxy = linphone_core_lookup_known_proxy(call->core, call->log->to);
}
if (call->dest_proxy != NULL)
call->nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy);
if (call->nat_policy == NULL)
call->nat_policy = linphone_core_get_nat_policy(call->core);
linphone_nat_policy_ref(call->nat_policy);
}
@ -1580,6 +1580,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
}
}
nat_policy=call->nat_policy;
if ((nat_policy != NULL) && linphone_nat_policy_ice_enabled(nat_policy)) {
/* Create the ice session now if ICE is required */
if (md){
@ -3080,9 +3081,15 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m
up_ptime=params->up_ptime;
else up_ptime=linphone_core_get_upload_ptime(lc);
}
*used_pt=payload_type_get_number(pt);
first=FALSE;
}
if (*used_pt == -1){
/*don't select telephone-event as a payload type*/
if (strcasecmp(pt->mime_type, "telephone-event") != 0){
*used_pt = payload_type_get_number(pt);
}
}
if (pt->flags & PAYLOAD_TYPE_BITRATE_OVERRIDE){
ms_message("Payload type [%s/%i] has explicit bitrate [%i] kbit/s", pt->mime_type, pt->clock_rate, pt->normal_bitrate/1000);
pt->normal_bitrate=get_min_bandwidth(pt->normal_bitrate,bw*1000);
@ -3506,7 +3513,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, LinphoneCallSta
setup_ring_player(lc,call);
}
if (call->params->in_conference){
if (call->params->in_conference && lc->conf_ctx){
/*transform the graph to connect it to the conference filter */
mute = stream->dir==SalStreamRecvOnly;
linphone_conference_on_call_stream_starting(lc->conf_ctx, call, mute);
@ -5259,8 +5266,9 @@ static void terminate_call(LinphoneCall *call) {
}
/* Stop ringing */
bool_t ring_during_early_media = linphone_core_get_ring_during_incoming_early_media(lc);
while(calls) {
if (((LinphoneCall *)calls->data)->state == LinphoneCallIncomingReceived) {
if (((LinphoneCall *)calls->data)->state == LinphoneCallIncomingReceived || (ring_during_early_media && ((LinphoneCall *)calls->data)->state == LinphoneCallIncomingEarlyMedia)) {
stop_ringing = FALSE;
break;
}

View file

@ -1353,9 +1353,6 @@ static void sip_config_read(LinphoneCore *lc) {
linphone_core_set_sip_transport_timeout(lc, lp_config_get_int(lc->config, "sip", "transport_timeout", 63000));
sal_set_supported_tags(lc->sal,lp_config_get_string(lc->config,"sip","supported","replaces, outbound"));
lc->sip_conf.save_auth_info = lp_config_get_int(lc->config, "sip", "save_auth_info", 1);
if (lp_config_get_string(lc->config, "sip", "rls_uri", NULL))
lc->default_rls_addr = linphone_address_new(lp_config_get_string(lc->config, "sip", "rls_uri", NULL));
linphone_core_create_im_notif_policy(lc);
}
@ -5822,7 +5819,9 @@ void sip_config_uninit(LinphoneCore *lc)
}
if (i>=20) ms_warning("Cannot complete unregistration, giving up");
}
config->proxies=bctbx_list_free_with_data(config->proxies,(void (*)(void*)) _linphone_proxy_config_release);
elem = config->proxies;
config->proxies=NULL; /*to make sure proxies cannot be refferenced during deletion*/
bctbx_list_free_with_data(elem,(void (*)(void*)) _linphone_proxy_config_release);
config->deleted_proxies=bctbx_list_free_with_data(config->deleted_proxies,(void (*)(void*)) _linphone_proxy_config_release);
@ -7052,22 +7051,30 @@ static void _linphone_core_conference_state_changed(LinphoneConference *conf, Li
}
}
/*This function sets the "unique" conference object for the LinphoneCore - which is necessary as long as
* liblinphone is used in a client app. When liblinphone will be used in a server app, this shall not be done anymore.*/
static void linphone_core_set_conference(LinphoneCore *lc, LinphoneConference *conf){
lc->conf_ctx = linphone_conference_ref(conf);
}
LinphoneConference *linphone_core_create_conference_with_params(LinphoneCore *lc, const LinphoneConferenceParams *params) {
const char *conf_method_name;
LinphoneConference *conf;
if(lc->conf_ctx == NULL) {
LinphoneConferenceParams *params2 = linphone_conference_params_clone(params);
linphone_conference_params_set_state_changed_callback(params2, _linphone_core_conference_state_changed, lc);
conf_method_name = lp_config_get_string(lc->config, "misc", "conference_type", "local");
if(strcasecmp(conf_method_name, "local") == 0) {
lc->conf_ctx = linphone_local_conference_new_with_params(lc, params2);
conf = linphone_local_conference_new_with_params(lc, params2);
} else if(strcasecmp(conf_method_name, "remote") == 0) {
lc->conf_ctx = linphone_remote_conference_new_with_params(lc, params2);
conf = linphone_remote_conference_new_with_params(lc, params2);
} else {
ms_error("'%s' is not a valid conference method", conf_method_name);
linphone_conference_params_unref(params2);
return NULL;
}
linphone_conference_params_unref(params2);
linphone_core_set_conference(lc, conf);
} else {
ms_error("Could not create a conference: a conference instance already exists");
return NULL;
@ -7085,6 +7092,7 @@ LinphoneStatus linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *c
LinphoneConferenceParams *params = linphone_conference_params_new(lc);
conference = linphone_core_create_conference_with_params(lc, params);
linphone_conference_params_unref(params);
linphone_conference_unref(conference); /*actually linphone_core_create_conference_with_params() takes a ref for lc->conf_ctx */
}
if(conference) return linphone_conference_add_participant(lc->conf_ctx, call);
else return -1;

View file

@ -5101,6 +5101,16 @@ extern "C" jintArray Java_org_linphone_core_LinphoneCallParamsImpl_getReceivedVi
return arr;
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallParamsImpl_getSentFramerate(JNIEnv *env, jobject thiz, jlong lcp) {
const LinphoneCallParams *params = (LinphoneCallParams *) lcp;
return (jfloat)linphone_call_params_get_sent_framerate(params);
}
extern "C" jfloat Java_org_linphone_core_LinphoneCallParamsImpl_getReceivedFramerate(JNIEnv *env, jobject thiz, jlong lcp) {
const LinphoneCallParams *params = (LinphoneCallParams *) lcp;
return (jfloat)linphone_call_params_get_received_framerate(params);
}
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getAudioDirection(JNIEnv *env, jobject thiz, jlong ptr) {
return (jint)linphone_call_params_get_audio_direction((LinphoneCallParams *)ptr);
}
@ -7449,6 +7459,16 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_ErrorInfoImpl_getDetails(JNIEnv
return tmp ? env->NewStringUTF(tmp) : NULL;
}
/*
* Class: org_linphone_core_ErrorInfoImpl
* Method: getDetails
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_linphone_core_ErrorInfoImpl_getWarnings(JNIEnv *env, jobject jobj, jlong ei){
const char *tmp=linphone_error_info_get_warnings((const LinphoneErrorInfo*)ei);
return tmp ? env->NewStringUTF(tmp) : NULL;
}
/*
* Class: org_linphone_core_ErrorInfoImpl
* Method: ref

View file

@ -1783,7 +1783,7 @@ struct _LinphoneVideoActivationPolicy {
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneVideoActivationPolicy);
LinphoneVideoActivationPolicy *linphone_video_activation_policy_new(void);
LINPHONE_PUBLIC LinphoneVideoActivationPolicy *linphone_video_activation_policy_new(void);
/**
* The LinphoneCallStats objects carries various statistic informations regarding quality of audio or video streams.

View file

@ -417,8 +417,11 @@ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig * cfg){
}
if (cfg->long_term_event){ /*might probably do better*/
linphone_event_terminate(cfg->long_term_event);
linphone_event_unref(cfg->long_term_event);
cfg->long_term_event=NULL;
if (cfg->long_term_event) {
linphone_event_unref(cfg->long_term_event); /*probably useless as cfg->long_term_event is already unref in linphone_proxy_config_notify_publish_state_changed. To be check with Ghislain*/
cfg->long_term_event=NULL;
}
}
if (cfg->op){
sal_op_release(cfg->op);

View file

@ -25,7 +25,7 @@
#ifndef LINPHONE_CONFERENCE_H
#define LINPHONE_CONFERENCE_H
#include "linphone/types.h"
#ifdef __cplusplus
@ -54,7 +54,7 @@ LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_ref(Linphon
/**
* Release a #LinphoneConferenceParams.
* @param[in] params The #LinphoneConferenceParams to release.
*/
*/
LINPHONE_PUBLIC void linphone_conference_params_unref(LinphoneConferenceParams *params);
/**
@ -120,7 +120,7 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_conference_get_participants(const Linphon
/**
* Invite participants to the conference, by supplying a list of LinphoneAddress
* @param obj The conference.
* @param addresses bctbx_list_t of #LinphoneAddress object
* @param addresses \bctbx_list{LinphoneAddress}
* @param params #LinphoneCallParams to use for inviting the participants.
**/
LINPHONE_PUBLIC LinphoneStatus linphone_conference_invite_participants(LinphoneConference *conf, const bctbx_list_t *addresses, const LinphoneCallParams *params);

View file

@ -28,7 +28,7 @@ public interface ErrorInfo {
* Get additional error information, which is provided as a Reason header in SIP response.
**/
ErrorInfo getSubErrorInfo();
/**
* Set Reason enum.
*/
@ -39,12 +39,10 @@ public interface ErrorInfo {
void setProtocol(String protocol);
/**
* Set the protocol code corresponding to the error (typically a SIP status code).
* @return the code.
*/
void setProtocolCode(int code);
/**
* Set the reason-phrase provided by the protocol (typically a SIP reason-phrase).
* @return the reason phrase.
*/
void setPhrase(String phrase);
/**
@ -55,7 +53,7 @@ public interface ErrorInfo {
* Set additional error information, which is provided as a Reason header in SIP response.
**/
void setSubErrorInfo(ErrorInfo sub_ei);
/**
* Get details about the error, if provided by the protocol. For SIP it consists of the content of a Warning or Reason header.
* @return details about the error.

View file

@ -236,4 +236,16 @@ public interface LinphoneCallParams {
* @param dir The video stream direction associated with this call params.
**/
void setVideoDirection(MediaDirection dir);
/**
* Gets the FPS sent in a video call.
* @return the fps
*/
float getSentFramerate();
/**
* Gets the FPS received in a video call.
* @return the fps
*/
float getReceivedFramerate();
}

View file

@ -245,4 +245,16 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
public void setVideoDirection(MediaDirection direction) {
setVideoDirection(nativePtr, direction.mValue);
}
private native float getSentFramerate(long nativePtr);
@Override
public float getSentFramerate() {
return getSentFramerate(nativePtr);
}
private native float getReceivedFramerate(long nativePtr);
@Override
public float getReceivedFramerate() {
return getReceivedFramerate(nativePtr);
}
}

View file

@ -443,7 +443,7 @@ static void simple_conference_from_scratch(void){
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallReleased,1,1000));
}
linphone_conference_unref(conf);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(laure);
@ -452,6 +452,9 @@ static void simple_conference_from_scratch(void){
bctbx_list_free(lcs);
}
static void simple_encrypted_conference_with_ice(LinphoneMediaEncryption mode) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");

View file

@ -1101,6 +1101,69 @@ static void long_term_presence_with_crossed_references(void) {
}else ms_warning("Test skipped, no vcard support");
}
static void multiple_publish_aggregation(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphoneCoreManager* pauline2 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphonePresenceModel *pauline_presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityDinner, NULL);
LinphonePresenceModel *pauline_presence2 = linphone_presence_model_new_with_activity(LinphonePresenceActivityAway, NULL);
LinphoneFriend* f = linphone_core_create_friend_with_address(marie->lc, get_identity(pauline));
LinphonePresenceActivity *activity = NULL;
LinphoneCoreCbs *callbacks = linphone_factory_create_core_cbs(linphone_factory_get());
int nb_act = 0;
int i = 0;
bool_t eq = FALSE;
linphone_core_cbs_set_publish_state_changed(callbacks, linphone_publish_state_changed);
_linphone_core_add_callbacks(pauline->lc, callbacks, TRUE);
_linphone_core_add_callbacks(pauline2->lc, callbacks, TRUE);
linphone_core_cbs_unref(callbacks);
lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 40);
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
linphone_core_set_user_agent(pauline2->lc, "full-presence-support", NULL);
linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
enable_publish(pauline, TRUE);
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphonePublishOk,1));
enable_publish(pauline2, TRUE);
BC_ASSERT_TRUE(wait_for(marie->lc,pauline2->lc,&pauline2->stat.number_of_LinphonePublishOk,1));
linphone_friend_enable_subscribes(f, TRUE);
linphone_friend_set_inc_subscribe_policy(f,LinphoneSPAccept); /* Accept incoming subscription request for this friend*/
linphone_core_add_friend(marie->lc, f);
linphone_core_set_presence_model(pauline->lc, pauline_presence);
linphone_presence_model_unref(pauline_presence);
linphone_core_set_presence_model(pauline2->lc, pauline_presence2);
linphone_presence_model_unref(pauline_presence2);
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityDinner,1));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline2->lc,&marie->stat.number_of_LinphonePresenceActivityAway,1));
nb_act = linphone_presence_model_get_nb_activities(linphone_friend_get_presence_model(f));
BC_ASSERT_EQUAL(nb_act, 2, int, "%d");
for(i = 0; i < nb_act; i++) {
activity = linphone_presence_model_get_nth_activity(linphone_friend_get_presence_model(f),i);
eq = (linphone_presence_activity_get_type(activity) == LinphonePresenceActivityAway || linphone_presence_activity_get_type(activity) == LinphonePresenceActivityDinner);
BC_ASSERT_TRUE(eq);
}
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphonePublishOk,2));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline2->lc,&pauline2->stat.number_of_LinphonePublishOk,2));
linphone_friend_unref(f);
linphone_core_manager_destroy(marie);
linphone_core_manager_stop(pauline);
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePublishCleared,1,int,"%i");
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePublishOk,2,int,"%i");
linphone_core_manager_destroy(pauline);
linphone_core_manager_stop(pauline2);
BC_ASSERT_EQUAL(pauline2->stat.number_of_LinphonePublishCleared,1,int,"%i");
BC_ASSERT_EQUAL(pauline2->stat.number_of_LinphonePublishOk,2,int,"%i");
linphone_core_manager_destroy(pauline2);
}
test_t presence_server_tests[] = {
TEST_NO_TAG("Simple", simple),
TEST_NO_TAG("Fast activity change", fast_activity_change),
@ -1121,6 +1184,7 @@ test_t presence_server_tests[] = {
TEST_ONE_TAG("Long term presence with cross references", long_term_presence_with_crossed_references,"longtern"),
TEST_NO_TAG("Subscriber no longer reachable using server",subscriber_no_longer_reachable),
TEST_NO_TAG("Subscribe with late publish", subscribe_with_late_publish),
TEST_NO_TAG("Multiple publish aggregation", multiple_publish_aggregation),
};
test_suite_t presence_server_test_suite = {"Presence using server", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,