Fix auth infos edition + updated belle-sip/linphone (needed for fix)
This commit is contained in:
parent
fdbe0e935c
commit
a43380181e
3 changed files with 50 additions and 18 deletions
|
@ -106,23 +106,45 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
private LinphoneAuthInfo getAuthInfo(int n) {
|
||||
LinphoneAuthInfo[] authsInfos = getLc().getAuthInfosList();
|
||||
// In case you have multiple proxy configs with same auth info
|
||||
if (n > 0 && n >= authsInfos.length) {
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
try {
|
||||
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
|
||||
return getLc().findAuthInfo(addr.getUserName(), null);
|
||||
} catch (LinphoneCoreException e) { }
|
||||
return null;
|
||||
}
|
||||
else if (n < 0 || n >= authsInfos.length) {
|
||||
return null;
|
||||
LinphoneAuthInfo authInfo = getLc().findAuthInfo(addr.getUserName(), null, addr.getDomain());
|
||||
return authInfo;
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a authInfo from the core and returns a copy of it.
|
||||
* Useful to edit a authInfo (you should call saveAuthInfo after the modifications to save them).
|
||||
*/
|
||||
private LinphoneAuthInfo getClonedAuthInfo(int n) {
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
try {
|
||||
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
|
||||
LinphoneAuthInfo authInfo = getLc().findAuthInfo(addr.getUserName(), null, addr.getDomain());
|
||||
LinphoneAuthInfo cloneAuthInfo = authInfo.clone();
|
||||
getLc().removeAuthInfo(authInfo);
|
||||
return cloneAuthInfo;
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a authInfo into the core.
|
||||
* Useful to save the changes made to a cloned authInfo.
|
||||
*/
|
||||
private void saveAuthInfo(LinphoneAuthInfo authInfo) {
|
||||
getLc().addAuthInfo(authInfo);
|
||||
}
|
||||
|
||||
private String tempUsername;
|
||||
private String tempUserId;
|
||||
private String tempPassword;
|
||||
|
@ -151,7 +173,7 @@ public class LinphonePreferences {
|
|||
} catch (NumberFormatException nfe) { }
|
||||
}
|
||||
|
||||
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null);
|
||||
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);
|
||||
|
||||
getLc().addProxyConfig(prxCfg);
|
||||
getLc().addAuthInfo(authInfo);
|
||||
|
@ -175,12 +197,14 @@ public class LinphonePreferences {
|
|||
|
||||
public void setAccountUsername(int n, String username) {
|
||||
String identity = "sip:" + username + "@" + getAccountDomain(n);
|
||||
LinphoneAuthInfo info = getAuthInfo(n); // Get the auth info before editing the proxy config to ensure to get the correct auth info
|
||||
LinphoneAuthInfo info = getClonedAuthInfo(n); // Get the auth info before editing the proxy config to ensure to get the correct auth info
|
||||
try {
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
prxCfg.setIdentity(identity);
|
||||
prxCfg.done();
|
||||
|
||||
info.setUsername(username);
|
||||
saveAuthInfo(info);
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -196,7 +220,9 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setAccountUserId(int n, String userId) {
|
||||
getAuthInfo(n).setUserId(userId);
|
||||
LinphoneAuthInfo info = getClonedAuthInfo(n);
|
||||
info.setUserId(userId);
|
||||
saveAuthInfo(info);
|
||||
}
|
||||
|
||||
public String getAccountUserId(int n) {
|
||||
|
@ -209,7 +235,9 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setAccountPassword(int n, String password) {
|
||||
getAuthInfo(n).setPassword(password);
|
||||
LinphoneAuthInfo info = getClonedAuthInfo(n);
|
||||
info.setPassword(password);
|
||||
saveAuthInfo(info);
|
||||
}
|
||||
|
||||
public String getAccountPassword(int n) {
|
||||
|
@ -226,6 +254,10 @@ public class LinphonePreferences {
|
|||
String proxy = "sip:" + domain;
|
||||
|
||||
try {
|
||||
LinphoneAuthInfo authInfo = getClonedAuthInfo(n);
|
||||
authInfo.setDomain(domain);
|
||||
saveAuthInfo(authInfo);
|
||||
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
prxCfg.setIdentity(identity);
|
||||
prxCfg.setProxy(proxy);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 38b76142a0186d393bea57a7f3e7886652900a91
|
||||
Subproject commit 2eb17045f1aaf99efe5b5447b2c76a8b7dab8434
|
|
@ -1 +1 @@
|
|||
Subproject commit 74e889fcc4ae3b61a3d632b108d8493590ccec9d
|
||||
Subproject commit 50f9d358046b1950e9d0aa3bf1f4527faa79697e
|
Loading…
Reference in a new issue