Fixed auth info not being removed when account is deleted + fixed previous proxy config not being unregistered when username is edited
This commit is contained in:
parent
21fc891fef
commit
ec35725474
1 changed files with 25 additions and 12 deletions
|
@ -446,16 +446,20 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
public void setAccountUsername(int n, String username) {
|
public void setAccountUsername(int n, String username) {
|
||||||
String identity = "sip:" + username + "@" + getAccountDomain(n);
|
String identity = "sip:" + username + "@" + getAccountDomain(n);
|
||||||
LinphoneAuthInfo info = getClonedAuthInfo(n); // Get the auth info before editing the proxy config to ensure to get the correct auth info
|
LinphoneAuthInfo old_info = getAuthInfo(n);
|
||||||
try {
|
try {
|
||||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||||
prxCfg.edit();
|
prxCfg.edit();
|
||||||
prxCfg.setIdentity(identity);
|
prxCfg.setIdentity(identity);
|
||||||
|
prxCfg.enableRegister(true);
|
||||||
prxCfg.done();
|
prxCfg.done();
|
||||||
|
|
||||||
if(info != null) {
|
if (old_info != null) {
|
||||||
info.setUsername(username);
|
// We have to remove the previous auth info after otherwise we can't unregister the previous proxy config
|
||||||
saveAuthInfo(info);
|
LinphoneAuthInfo new_info = old_info.clone();
|
||||||
|
getLc().removeAuthInfo(old_info);
|
||||||
|
new_info.setUsername(username);
|
||||||
|
saveAuthInfo(new_info);
|
||||||
}
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
|
@ -514,18 +518,21 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
public void setAccountDomain(int n, String domain) {
|
public void setAccountDomain(int n, String domain) {
|
||||||
String identity = "sip:" + getAccountUsername(n) + "@" + domain;
|
String identity = "sip:" + getAccountUsername(n) + "@" + domain;
|
||||||
|
LinphoneAuthInfo old_info = getAuthInfo(n);
|
||||||
try {
|
try {
|
||||||
LinphoneAuthInfo authInfo = getClonedAuthInfo(n);
|
|
||||||
if(authInfo != null) {
|
|
||||||
authInfo.setDomain(domain);
|
|
||||||
saveAuthInfo(authInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||||
prxCfg.edit();
|
prxCfg.edit();
|
||||||
prxCfg.setIdentity(identity);
|
prxCfg.setIdentity(identity);
|
||||||
|
prxCfg.enableRegister(true);
|
||||||
prxCfg.done();
|
prxCfg.done();
|
||||||
|
|
||||||
|
if (old_info != null) {
|
||||||
|
// We have to remove the previous auth info after otherwise we can't unregister the previous proxy config
|
||||||
|
LinphoneAuthInfo new_info = old_info.clone();
|
||||||
|
getLc().removeAuthInfo(old_info);
|
||||||
|
new_info.setDomain(domain);
|
||||||
|
saveAuthInfo(new_info);
|
||||||
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
|
@ -721,7 +728,7 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(int n) {
|
public void deleteAccount(int n) {
|
||||||
final LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
||||||
if (proxyCfg != null)
|
if (proxyCfg != null)
|
||||||
getLc().removeProxyConfig(proxyCfg);
|
getLc().removeProxyConfig(proxyCfg);
|
||||||
if (getLc().getProxyConfigList().length != 0) {
|
if (getLc().getProxyConfigList().length != 0) {
|
||||||
|
@ -729,6 +736,12 @@ public class LinphonePreferences {
|
||||||
} else {
|
} else {
|
||||||
getLc().setDefaultProxyConfig(null);
|
getLc().setDefaultProxyConfig(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinphoneAuthInfo authInfo = getAuthInfo(n);
|
||||||
|
if (authInfo != null) {
|
||||||
|
getLc().removeAuthInfo(authInfo);
|
||||||
|
}
|
||||||
|
|
||||||
getLc().refreshRegisters();
|
getLc().refreshRegisters();
|
||||||
}
|
}
|
||||||
// End of accounts settings
|
// End of accounts settings
|
||||||
|
|
Loading…
Reference in a new issue