Improved use of linphone specifics default proxy config values

This commit is contained in:
Sylvain Berfini 2019-03-01 15:20:11 +01:00
parent c294a8ad1b
commit 1ee8e83621
6 changed files with 41 additions and 14 deletions

View file

@ -155,7 +155,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private final String mLPConfigXsd; private final String mLPConfigXsd;
private final String mLinphoneFactoryConfigFile; private final String mLinphoneFactoryConfigFile;
private final String mDynamicConfigFile; private final String mLinphoneDynamicConfigFile, mDefaultDynamicConfigFile;
private final String mChatDatabaseFile; private final String mChatDatabaseFile;
private final String mRingSoundFile; private final String mRingSoundFile;
private final String mCallLogDatabaseFile; private final String mCallLogDatabaseFile;
@ -205,7 +205,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
mLPConfigXsd = mBasePath + "/lpconfig.xsd"; mLPConfigXsd = mBasePath + "/lpconfig.xsd";
mLinphoneFactoryConfigFile = mBasePath + "/linphonerc"; mLinphoneFactoryConfigFile = mBasePath + "/linphonerc";
configFile = mBasePath + "/.linphonerc"; configFile = mBasePath + "/.linphonerc";
mDynamicConfigFile = mBasePath + "/assistant_create.rc"; mLinphoneDynamicConfigFile = mBasePath + "/linphone_assistant_create.rc";
mDefaultDynamicConfigFile = mBasePath + "/default_assistant_create.rc";
mChatDatabaseFile = mBasePath + "/linphone-history.db"; mChatDatabaseFile = mBasePath + "/linphone-history.db";
mCallLogDatabaseFile = mBasePath + "/linphone-log-history.db"; mCallLogDatabaseFile = mBasePath + "/linphone-log-history.db";
mFriendsDatabaseFile = mBasePath + "/linphone-friends.db"; mFriendsDatabaseFile = mBasePath + "/linphone-friends.db";
@ -839,7 +840,10 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
copyIfNotExist(R.raw.linphonerc_default, configFile); copyIfNotExist(R.raw.linphonerc_default, configFile);
copyFromPackage(R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName()); copyFromPackage(R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName());
copyIfNotExist(R.raw.lpconfig, mLPConfigXsd); copyIfNotExist(R.raw.lpconfig, mLPConfigXsd);
copyFromPackage(R.raw.assistant_create, new File(mDynamicConfigFile).getName()); copyFromPackage(
R.raw.default_assistant_create, new File(mDefaultDynamicConfigFile).getName());
copyFromPackage(
R.raw.linphone_assistant_create, new File(mLinphoneDynamicConfigFile).getName());
} }
private void copyIfNotExist(int ressourceId, String target) throws IOException { private void copyIfNotExist(int ressourceId, String target) throws IOException {
@ -1551,8 +1555,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
dialog.show(); dialog.show();
} }
public String getmDynamicConfigFile() { public String getDefaultDynamicConfigFile() {
return mDynamicConfigFile; return mDefaultDynamicConfigFile;
}
public String getLinphoneDynamicConfigFile() {
return mLinphoneDynamicConfigFile;
} }
public boolean getCallGsmON() { public boolean getCallGsmON() {

View file

@ -503,8 +503,11 @@ public class AssistantActivity extends Activity
public void linphoneLogIn(AccountCreator accountCreator) { public void linphoneLogIn(AccountCreator accountCreator) {
LinphoneManager.getLc() LinphoneManager.getLc()
.loadConfigFromXml(LinphoneManager.getInstance().getmDynamicConfigFile()); .loadConfigFromXml(LinphoneManager.getInstance().getLinphoneDynamicConfigFile());
configureProxyConfig(accountCreator); configureProxyConfig(accountCreator);
// Restore default values for proxy config
LinphoneManager.getLc()
.loadConfigFromXml(LinphoneManager.getInstance().getDefaultDynamicConfigFile());
} }
public void genericLogIn( public void genericLogIn(

View file

@ -96,6 +96,7 @@ public class CreateAccountFragment extends Fragment
LinphoneManager.getLc() LinphoneManager.getLc()
.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl()); .createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
mAccountCreator.setListener(this); mAccountCreator.setListener(this);
mAccountCreator.setDomain(getString(R.string.default_domain));
mInstruction = view.findViewById(R.id.message_create_account); mInstruction = view.findViewById(R.id.message_create_account);
@ -339,9 +340,6 @@ public class CreateAccountFragment extends Fragment
} else { } else {
if (mUseEmail.isChecked()) mAccountCreator.setPhoneNumber(null, null); if (mUseEmail.isChecked()) mAccountCreator.setPhoneNumber(null, null);
if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) { if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) {
LinphoneManager.getLc()
.loadConfigFromXml(
LinphoneManager.getInstance().getmDynamicConfigFile());
mAccountCreator.isAccountExist(); mAccountCreator.isAccountExist();
} else { } else {
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
@ -673,8 +671,6 @@ public class CreateAccountFragment extends Fragment
LinphoneUtils.displayErrorAlert( LinphoneUtils.displayErrorAlert(
LinphoneUtils.errorForStatus(status), AssistantActivity.instance()); LinphoneUtils.errorForStatus(status), AssistantActivity.instance());
} else { } else {
LinphoneManager.getLc()
.loadConfigFromXml(LinphoneManager.getInstance().getmDynamicConfigFile());
accountCreator.isAliasUsed(); accountCreator.isAliasUsed();
} }
} else { } else {

View file

@ -209,6 +209,7 @@ public class LinphoneLoginFragment extends Fragment
} }
mAccountCreator.setUsername(mLogin.getText().toString()); mAccountCreator.setUsername(mLogin.getText().toString());
mAccountCreator.setPassword(mPassword.getText().toString()); mAccountCreator.setPassword(mPassword.getText().toString());
mAccountCreator.setDomain(getString(R.string.default_domain));
mAccountCreator.isAccountExist(); mAccountCreator.isAccountExist();
} }
@ -276,8 +277,6 @@ public class LinphoneLoginFragment extends Fragment
int status = getPhoneNumberStatus(); int status = getPhoneNumberStatus();
boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt(); boolean isOk = status == AccountCreator.PhoneNumberStatus.Ok.toInt();
if (isOk) { if (isOk) {
LinphoneManager.getLc()
.loadConfigFromXml(LinphoneManager.getInstance().getmDynamicConfigFile());
mAccountCreator.isAliasUsed(); mAccountCreator.isAliasUsed();
} else { } else {
mApply.setEnabled(true); mApply.setEnabled(true);

View file

@ -0,0 +1,22 @@
<?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="proxy_default_values">
<entry name="avpf" overwrite="true">0</entry>
<entry name="dial_escape_plus" overwrite="true">0</entry>
<entry name="publish" overwrite="true">0</entry>
<entry name="quality_reporting_collector" overwrite="true"></entry>
<entry name="quality_reporting_enabled" overwrite="true">0</entry>
<entry name="quality_reporting_interval" overwrite="true">0</entry>
<entry name="reg_expires" overwrite="true">3600</entry>
<entry name="reg_identity" overwrite="true"></entry>
<entry name="reg_proxy" overwrite="true"></entry>
<entry name="reg_route" overwrite="true"></entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="nat_policy_ref" overwrite="true"></entry>
<entry name="realm" overwrite="true"></entry>
<entry name="conference_factory_uri" overwrite="true"></entry>
</section>
<section name="assistant">
<entry name="domain" overwrite="true"></entry>
</section>
</config>

View file

@ -24,7 +24,6 @@
<entry name="rls_uri" overwrite="true">sips:rls@sip.linphone.org</entry> <entry name="rls_uri" overwrite="true">sips:rls@sip.linphone.org</entry>
</section> </section>
<section name="assistant"> <section name="assistant">
<entry name="domain" overwrite="true">sip.linphone.org</entry>
<entry name="password_max_length" overwrite="true">-1</entry> <entry name="password_max_length" overwrite="true">-1</entry>
<entry name="password_min_length" overwrite="true">1</entry> <entry name="password_min_length" overwrite="true">1</entry>
<entry name="username_length" overwrite="true">-1</entry> <entry name="username_length" overwrite="true">-1</entry>