Fix setup with several address
This commit is contained in:
parent
39d595d2da
commit
438ea0ee25
1 changed files with 21 additions and 9 deletions
|
@ -21,10 +21,12 @@ import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphonePreferences.AccountBuilder;
|
import org.linphone.LinphonePreferences.AccountBuilder;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAddress.TransportType;
|
import org.linphone.core.LinphoneAddress.TransportType;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
|
||||||
|
@ -53,6 +55,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
private boolean accountCreated = false;
|
private boolean accountCreated = false;
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
private LinphoneAddress address;
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -78,6 +81,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
@Override
|
@Override
|
||||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
|
if(accountCreated){
|
||||||
|
if(address != null && address.asString().equals(cfg.getIdentity()) ) {
|
||||||
if (state == RegistrationState.RegistrationOk) {
|
if (state == RegistrationState.RegistrationOk) {
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
launchEchoCancellerCalibration(true);
|
launchEchoCancellerCalibration(true);
|
||||||
|
@ -86,6 +91,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -298,6 +305,12 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
if (accountCreated)
|
if (accountCreated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
String identity = "sip:" + username + "@" + domain;
|
||||||
|
try {
|
||||||
|
address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
boolean isMainAccountLinphoneDotOrg = domain.equals(getString(R.string.default_domain));
|
boolean isMainAccountLinphoneDotOrg = domain.equals(getString(R.string.default_domain));
|
||||||
boolean useLinphoneDotOrgCustomPorts = getResources().getBoolean(R.bool.use_linphone_server_ports);
|
boolean useLinphoneDotOrgCustomPorts = getResources().getBoolean(R.bool.use_linphone_server_ports);
|
||||||
AccountBuilder builder = new AccountBuilder(LinphoneManager.getLc())
|
AccountBuilder builder = new AccountBuilder(LinphoneManager.getLc())
|
||||||
|
@ -327,7 +340,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
|
|
||||||
mPrefs.setStunServer(getString(R.string.default_stun));
|
mPrefs.setStunServer(getString(R.string.default_stun));
|
||||||
mPrefs.setIceEnabled(true);
|
mPrefs.setIceEnabled(true);
|
||||||
mPrefs.setPushNotificationEnabled(true);
|
|
||||||
} else {
|
} else {
|
||||||
String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
|
String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
|
||||||
if (!TextUtils.isEmpty(forcedProxy)) {
|
if (!TextUtils.isEmpty(forcedProxy)) {
|
||||||
|
|
Loading…
Reference in a new issue