Commit 194bddc3 authored by Simon Morlat's avatar Simon Morlat
Browse files

Make liblinphone open its SIP sockets in linphone_core_start(), not immediately at core creation.

Fix test.
parent f95c7ec0
......@@ -156,6 +156,7 @@ static void linphone_core_run_hooks(LinphoneCore *lc);
static void linphone_core_zrtp_cache_close(LinphoneCore *lc);
void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName);
static void _linphone_core_stop_async_end(LinphoneCore *lc);
static LinphoneStatus _linphone_core_set_sip_transports(LinphoneCore *lc, const LinphoneSipTransports * tr_config, bool_t applyIt);
#include "enum.h"
#include "contact_providers_priv.h"
......@@ -1543,8 +1544,8 @@ static void sip_config_read(LinphoneCore *lc) {
certificates_config_read(lc);
/*setting the dscp must be done before starting the transports, otherwise it is not taken into effect*/
lc->sal->setDscp(linphone_core_get_sip_dscp(lc));
/*start listening on ports*/
linphone_core_set_sip_transports(lc,&tr);
/*set transport configuration, but do not apply it (do not open sockets). It will be done from linphone_core_start().*/
_linphone_core_set_sip_transports(lc, &tr, FALSE);
tmpstr=linphone_config_get_string(lc->config,"sip","contact",NULL);
if (tmpstr==NULL || linphone_core_set_primary_contact(lc,tmpstr)==-1) {
......@@ -2298,8 +2299,9 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState
belle_sip_object_unref(lc->provisioning_http_listener);
lc->provisioning_http_listener = NULL;
}
linphone_core_set_state(lc,LinphoneGlobalOn,"Ready");
_linphone_core_apply_transports(lc); // This will create SIP sockets.
L_GET_PRIVATE_FROM_C_OBJECT(lc)->initEphemeralMessages();
linphone_core_set_state(lc, LinphoneGlobalOn, "On");
}
......@@ -2818,7 +2820,7 @@ LinphoneStatus linphone_core_start (LinphoneCore *lc) {
}
linphone_core_set_state(lc, LinphoneGlobalStartup, "Starting up");
L_GET_PRIVATE_FROM_C_OBJECT(lc)->init();
//to give a chance to change uuid before starting
......@@ -2850,7 +2852,10 @@ LinphoneStatus linphone_core_start (LinphoneCore *lc) {
} else {
linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL);
}
L_GET_PRIVATE_FROM_C_OBJECT(lc)->initEphemeralMessages();
/* There should not be further actions below this line.
* Indeed, linphone_configuring_terminated() shall perform the actions that comes after configuration.
* It may be called directly, as above, or asynchronously after the remote provisioning is completed.
* */
return 0;
} catch (const CorePrivate::DatabaseConnectionFailure &e) {
bctbx_error("%s", e.what());
......@@ -3559,7 +3564,7 @@ void linphone_transports_set_dtls_port(LinphoneTransports *transports, int port)
transports->dtls_port = port;
}
LinphoneStatus linphone_core_set_sip_transports(LinphoneCore *lc, const LinphoneSipTransports * tr_config /*config to be saved*/){
static LinphoneStatus _linphone_core_set_sip_transports(LinphoneCore *lc, const LinphoneSipTransports * tr_config, bool_t applyIt){
LinphoneSipTransports tr=*tr_config;
if (linphone_config_get_int(lc->config,"sip","sip_random_port",0)==1) {
......@@ -3589,10 +3594,15 @@ LinphoneStatus linphone_core_set_sip_transports(LinphoneCore *lc, const Linphone
linphone_config_set_int(lc->config,"sip","sip_tls_port",tr_config->tls_port);
}
if (lc->sal==NULL) return 0;
if (lc->sal == NULL || !applyIt) return 0;
return _linphone_core_apply_transports(lc);
}
LinphoneStatus linphone_core_set_sip_transports(LinphoneCore *lc, const LinphoneSipTransports * tr_config /*config to be saved*/){
return _linphone_core_set_sip_transports(lc, tr_config, TRUE);
}
LinphoneStatus linphone_core_set_transports(LinphoneCore *lc, const LinphoneTransports * transports){
if (transports->udp_port == lc->sip_conf.transports.udp_port &&
transports->tcp_port == lc->sip_conf.transports.tcp_port &&
......@@ -6330,30 +6340,6 @@ void linphone_core_set_mtu(LinphoneCore *lc, int mtu){
}else ms_factory_set_mtu(lc->factory, 0);//use mediastreamer2 default value
}
void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneCoreWaitingCallback cb, void *user_context){
lc->wait_cb=cb;
lc->wait_ctx=user_context;
}
void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose){
if (lc->wait_cb){
lc->wait_ctx=lc->wait_cb(lc,lc->wait_ctx,LinphoneWaitingStart,purpose,0);
}
}
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progress){
if (lc->wait_cb){
lc->wait_ctx=lc->wait_cb(lc,lc->wait_ctx,LinphoneWaitingProgress,purpose,progress);
}else{
ms_usleep(50000);
}
}
void linphone_core_stop_waiting(LinphoneCore *lc){
if (lc->wait_cb){
lc->wait_ctx=lc->wait_cb(lc,lc->wait_ctx,LinphoneWaitingFinished,NULL,0);
}
}
void linphone_core_set_rtp_transport_factories(LinphoneCore* lc, LinphoneRtpTransportFactories *factories){
lc->rtptf=factories;
......
......@@ -655,8 +655,8 @@ static void group_chat_lime_x3dh_send_encrypted_file_with_or_without_text (bool_
bctbx_list_t *participantsAddresses = NULL;
char *sendFilepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv");
char *sendFilepath2 = NULL;
char *receivePaulineFilepath = bc_tester_file("receive_file_pauline.dump");
char *receiveChloeFilepath = bc_tester_file("receive_file_chloe.dump");
char *receivePaulineFilepath = bc_tester_file("receive_file_secure_pauline.dump");
char *receiveChloeFilepath = bc_tester_file("receive_file_secure_chloe.dump");
const char *text = "Hello Group !";
if (two_files) {
......
......@@ -414,7 +414,9 @@ void linphone_proxy_config_is_server_config_changed_test(void) {
LinphoneAddress *addr = linphone_address_new("sip:toto@titi");
linphone_proxy_config_set_identity_address(proxy_config,addr);
if (addr) linphone_address_unref(addr);
linphone_proxy_config_edit(proxy_config);
addr = linphone_address_new("sips:toto@titi");
linphone_proxy_config_set_identity_address(proxy_config,addr);
if (addr) linphone_address_unref(addr);
BC_ASSERT_EQUAL(linphone_proxy_config_is_server_config_changed(proxy_config), LinphoneProxyConfigAddressDifferent, int, "%d");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment