diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 149ebf18a..97f03e056 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7041,10 +7041,6 @@ void linphone_core_enable_conference_server (LinphoneCore *lc, bool_t enable) { lp_config_set_int(linphone_core_get_config(lc), "misc", "conference_server_enabled", enable); } -bool_t linphone_core_conference_server_enabled (const LinphoneCore *lc) { - return lp_config_get_int(linphone_core_get_config(lc), "misc", "conference_server_enabled", FALSE) ? TRUE : FALSE; -} - bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const LinphoneAddress *addr) { const char *uri = linphone_core_get_conference_factory_uri(lc); if (!uri) @@ -7063,6 +7059,10 @@ bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const Linp return result; } +bool_t linphone_core_conference_server_enabled (const LinphoneCore *lc) { + return lp_config_get_int(linphone_core_get_config(lc), "misc", "conference_server_enabled", FALSE) ? TRUE : FALSE; +} + void linphone_core_set_tls_cert(LinphoneCore *lc, const char *tls_cert) { if (lc->tls_cert) { ms_free(lc->tls_cert); diff --git a/coreapi/tester_utils.h b/coreapi/tester_utils.h index bc951b1b9..f65d62c62 100644 --- a/coreapi/tester_utils.h +++ b/coreapi/tester_utils.h @@ -152,6 +152,16 @@ LINPHONE_PUBLIC void sal_call_set_sdp_handling(SalOp *h, SalOpSDPHandling handli LINPHONE_PUBLIC SalMediaDescription * sal_call_get_final_media_description(SalOp *h); LINPHONE_PUBLIC belle_sip_resolver_context_t *sal_resolve_a(Sal *sal, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data); + +LINPHONE_PUBLIC Sal *sal_op_get_sal(SalOp *op); +LINPHONE_PUBLIC SalOp *sal_create_refer_op(Sal *sal); +LINPHONE_PUBLIC void sal_release_op(SalOp *op); +LINPHONE_PUBLIC void sal_op_set_from(SalOp *sal_refer_op, const char* from); +LINPHONE_PUBLIC void sal_op_set_to(SalOp *sal_refer_op, const char* to); +LINPHONE_PUBLIC void sal_op_send_refer(SalOp *sal_refer_op, SalAddress* refer_to); +LINPHONE_PUBLIC void sal_set_user_pointer(Sal *sal, void *user_pointer); +LINPHONE_PUBLIC void *sal_get_user_pointer(Sal *sal); +LINPHONE_PUBLIC void sal_set_call_refer_callback(Sal *sal, void (*OnReferCb)(SalOp *op, const SalAddress *referto)); #endif #ifdef __cplusplus diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index c87b5e95c..36674fd76 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -1020,4 +1020,45 @@ belle_sip_resolver_context_t *sal_resolve_a(Sal *sal, const char *name, int port return sal->resolve_a(name, port, family, cb, data); } +Sal *sal_op_get_sal(SalOp *op) { + return op->get_sal(); +} + +SalOp *sal_create_refer_op(Sal *sal) { + return new SalReferOp(sal); +} + +void sal_release_op(SalOp *op) { + op->release(); +} + +void sal_op_set_from(SalOp *sal_refer_op, const char* from) { + auto referOp = dynamic_cast(sal_refer_op); + referOp->set_from(from); +} + +void sal_op_set_to(SalOp *sal_refer_op, const char* to) { + auto referOp = dynamic_cast(sal_refer_op); + referOp->set_to(to); +} + +void sal_op_send_refer(SalOp *sal_refer_op, SalAddress* refer_to) { + auto referOp = dynamic_cast(sal_refer_op); + referOp->send_refer(refer_to); +} + +void sal_set_user_pointer(Sal *sal, void *user_pointer) { + sal->set_user_pointer(user_pointer); +} + +void *sal_get_user_pointer(Sal *sal) { + return sal->get_user_pointer(); +} + +void sal_set_call_refer_callback(Sal *sal, void (*OnReferCb)(SalOp *op, const SalAddress *referto)) { + struct Sal::Callbacks cbs = {NULL}; + cbs.refer_received = OnReferCb; + sal->set_callbacks(&cbs); +} + } diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index a3ad65ff9..b46779385 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -85,6 +85,7 @@ set(RC_FILES rcfiles/account_creator_rc rcfiles/assistant_create.rc rcfiles/carddav_rc + rcfiles/chloe_rc rcfiles/conference_focus_rc rcfiles/empty_rc rcfiles/friends_rc diff --git a/tester/accountmanager.c b/tester/accountmanager.c index a26f3f94f..70e7e63a4 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -97,6 +97,20 @@ Account *account_manager_get_account(AccountManager *m, const LinphoneAddress *i return NULL; } +LinphoneAddress *account_manager_get_identity_with_modified_identity(const LinphoneAddress *modified_identity){ + AccountManager *m = account_manager_get(); + bctbx_list_t *it; + + for(it=m->accounts;it!=NULL;it=it->next){ + Account *a=(Account*)it->data; + if (linphone_address_weak_equal(a->modified_identity,modified_identity)){ + return a->identity; + } + } + return NULL; +} + + static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *info){ Account *account=(Account*)linphone_core_get_user_data(lc); switch(state){ diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 9522c8038..805c1951e 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1390,6 +1390,76 @@ void test_removing_old_tport(void) { bctbx_list_free(lcs); } +static const char* get_laure_rc(void) { + if (liblinphone_tester_ipv6_available()) { + return "laure_tcp_rc"; + } else { + return "laure_rc_udp"; + } +} + +static void on_refer_received(SalOp *op, const SalAddress *refer_to) { + Sal *sal = sal_op_get_sal(op); + LinphoneCoreManager *receiver = (LinphoneCoreManager*)sal_get_user_pointer(sal); + receiver->stat.number_of_LinphoneCallRefered++; + sal_release_op(op); +} + +void resend_refer_other_devices(void) { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( get_laure_rc()); + LinphoneCoreManager* pauline2; + bctbx_list_t* lcs = NULL; + + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); + + /* We set Pauline's Sal callback and pass the core manager to access stats */ + Sal *pauline_sal = linphone_core_get_sal(pauline->lc); + sal_set_user_pointer(pauline_sal, (void*)pauline); + sal_set_call_refer_callback(pauline_sal, on_refer_received); + + + char *marie_address = linphone_address_as_string(marie->identity); + char *pauline_address = linphone_address_as_string(pauline->identity); + char *laure_address = linphone_address_as_string(laure->identity); + + /* Then we create a refer from marie to pauline that refers to laure */ + SalOp *op = sal_create_refer_op(linphone_core_get_sal(marie->lc)); + sal_op_set_from(op, marie_address); + sal_op_set_to(op, pauline_address); + + SalAddress *address = sal_address_new(laure_address); + sal_address_set_param(address, "text", NULL); + sal_op_send_refer(op, address); + + ms_free(marie_address); + ms_free(pauline_address); + ms_free(laure_address); + + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallRefered,1,5000)); + + /* We create another pauline and check if it has received a refer */ + pauline2 = linphone_core_manager_new( "pauline_rc"); + lcs=bctbx_list_append(lcs,pauline2->lc); + + Sal *pauline2_sal = linphone_core_get_sal(pauline2->lc); + sal_set_user_pointer(pauline2_sal, (void*)pauline2); + sal_set_call_refer_callback(pauline2_sal, on_refer_received); + + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_LinphoneCallRefered,1,5000)); + + sal_address_unref(address); + sal_release_op(op); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(laure); + linphone_core_manager_destroy(pauline2); + bctbx_list_free(lcs); +} + test_t flexisip_tests[] = { TEST_ONE_TAG("Subscribe forking", subscribe_forking, "LeaksMemory"), TEST_NO_TAG("Message forking", message_forking), @@ -1427,7 +1497,8 @@ test_t flexisip_tests[] = { TEST_NO_TAG("TLS authentication - client rejected due to CN mismatch", tls_client_auth_bad_certificate_cn), TEST_NO_TAG("TLS authentication - client rejected due to unrecognized certificate chain", tls_client_auth_bad_certificate), TEST_NO_TAG("Transcoder", transcoder_tester), - TEST_NO_TAG("Removing old tport on flexisip for the same client", test_removing_old_tport) + TEST_NO_TAG("Removing old tport on flexisip for the same client", test_removing_old_tport), + TEST_NO_TAG("Resend of REFER with other devices", resend_refer_other_devices) }; diff --git a/tester/rcfiles/laure_tcp_rc b/tester/rcfiles/laure_tcp_rc index 6f19d7a5c..8ed5de984 100644 --- a/tester/rcfiles/laure_tcp_rc +++ b/tester/rcfiles/laure_tcp_rc @@ -11,16 +11,15 @@ userid=laure passwd=secret realm="sip.example.org" - [proxy_0] reg_proxy=sip.example.org;transport=tcp +reg_route=sip.example.org;transport=tcp reg_identity=sip:laure@sip.example.org reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 - [rtp] audio_rtp_port=9010-9390 video_rtp_port=9410-9910 diff --git a/tester/rcfiles/marie_rc b/tester/rcfiles/marie_rc index 64c454bb1..f6f46ff8d 100644 --- a/tester/rcfiles/marie_rc +++ b/tester/rcfiles/marie_rc @@ -14,7 +14,6 @@ userid=marie passwd=secret realm=sip.example.org - [proxy_0] reg_proxy=sip.example.org;transport=tcp reg_route=sip.example.org;transport=tcp;lr @@ -29,6 +28,8 @@ url="Paupoche" pol=accept subscribe=0 +[misc] +conference-factory-uri=sip:conference-factory@conf.example.org [rtp] audio_rtp_port=18070-28000 diff --git a/tester/rcfiles/pauline_rc b/tester/rcfiles/pauline_rc index 44bb1b6d5..6d1be2b7f 100644 --- a/tester/rcfiles/pauline_rc +++ b/tester/rcfiles/pauline_rc @@ -12,7 +12,6 @@ userid=pauline passwd=secret realm=sip.example.org - [proxy_0] realm=sip.example.org reg_proxy=sip2.linphone.org;transport=tls