Commit 47d3fdc7 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added method in core to update config and reload it from xml file

parent 9c75cdaa
......@@ -2077,6 +2077,20 @@ static void _linphone_core_read_config(LinphoneCore * lc) {
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
}
void linphone_core_load_config_from_xml(LinphoneCore *lc, const char * xml_uri) {
// As for today assume the URI is a local file
const char *error = linphone_config_load_from_xml_file(lc->config, xml_uri);
if (error) {
bctbx_error("Couldn't load config from xml: %s", error);
return;
}
// We should call _linphone_core_read_config(lc); in the future but currently this is dangerous
if (linphone_core_lime_x3dh_available(lc)) {
linphone_core_enable_lime_x3dh(lc, true);
}
}
void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState state, const char *message) {
linphone_core_notify_configuring_status(lc, state, message);
......
......@@ -5852,6 +5852,14 @@ LINPHONE_PUBLIC LinphoneAccountCreator * linphone_core_create_account_creator(Li
**/
LINPHONE_PUBLIC LinphoneXmlRpcSession * linphone_core_create_xml_rpc_session(LinphoneCore *lc, const char *url);
/**
* Update current config with the content of a xml config file
* @param[in] lc The #LinphoneCore to update
* @param[in] xml_uri the path to the xml file
* @ingroup misc
**/
LINPHONE_PUBLIC void linphone_core_load_config_from_xml(LinphoneCore *lc, const char * xml_uri);
#ifdef __cplusplus
}
......
......@@ -240,6 +240,7 @@ void Core::enableLimeX3dh (bool enable) {
LinphoneConfig *lpconfig = linphone_core_get_config(getCCore());
string serverUrl = lp_config_get_string(lpconfig, "lime", "x3dh_server_url", "");
if (serverUrl.empty()) {
lError() << "Lime X3DH server URL not set, can't enable";
//Do not enable encryption engine if url is undefined
return;
}
......
......@@ -97,6 +97,7 @@ set(RC_FILES
rcfiles/laure_lime_x3dh_rc
rcfiles/laure_rc_udp
rcfiles/laure_tcp_rc
rcfiles/lime_x3dh_xml_rc
rcfiles/marie_early_rc
rcfiles/marie_h264_rc
rcfiles/marie_lime_x3dh_rc
......
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.linphone.org/xsds/lpconfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd">
<section name="lime">
<entry name="x3dh_server_url" overwrite="true">http://sip-staging.linphone.org:8083/flexisip-account-manager/x3dh-25519.php</entry>
</section>
</config>
\ No newline at end of file
......@@ -453,6 +453,20 @@ static void custom_tones_setup(void){
linphone_core_manager_destroy(mgr);
}
static void lime_x3dh_setup(void) {
LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE);
char* xml_path = bc_tester_res("rcfiles/lime_x3dh_xml_rc");
if (linphone_core_lime_x3dh_available(mgr->lc)) {
BC_ASSERT_FALSE(linphone_core_lime_x3dh_enabled(mgr->lc));
linphone_core_load_config_from_xml(mgr->lc, xml_path);
BC_ASSERT_TRUE(linphone_core_lime_x3dh_enabled(mgr->lc));
}
ms_free(xml_path);
linphone_core_manager_destroy(mgr);
}
static void search_friend_in_alphabetical_order(void) {
LinphoneMagicSearch *magicSearch = NULL;
bctbx_list_t *resultList = NULL;
......@@ -1483,6 +1497,7 @@ test_t setup_tests[] = {
TEST_NO_TAG("Codec usability", codec_usability_test),
TEST_NO_TAG("Codec setup", codec_setup),
TEST_NO_TAG("Custom tones setup", custom_tones_setup),
TEST_NO_TAG("Lime X3DH setup", lime_x3dh_setup),
TEST_NO_TAG("Appropriate software echo canceller check", echo_canceller_check),
TEST_ONE_TAG("Return friend list in alphabetical order", search_friend_in_alphabetical_order, "MagicSearch"),
TEST_ONE_TAG("Search friend without filter and domain", search_friend_without_filter, "MagicSearch"),
......
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