Rework proxy config uses
Add realm in linphone account on wizzard
This commit is contained in:
parent
78b89a930f
commit
43d09414ff
7 changed files with 71 additions and 74 deletions
|
@ -33,7 +33,9 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedLis
|
|||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.CallDirection;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallLog;
|
||||
import org.linphone.core.LinphoneCallLog.CallStatus;
|
||||
|
@ -768,15 +770,25 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
getChatStorage().updateMessageStatus(to, id, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegistrationStateChanged(RegistrationState state) {
|
||||
if (statusFragment != null) {
|
||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message) {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null && lc.getDefaultProxyConfig() != null)
|
||||
if (statusFragment != null) {
|
||||
if (lc != null)
|
||||
if(lc.getDefaultProxyConfig() == null)
|
||||
statusFragment.registrationStateChanged(proxy.getState());
|
||||
else
|
||||
statusFragment.registrationStateChanged(lc.getDefaultProxyConfig().getState());
|
||||
else
|
||||
statusFragment.registrationStateChanged(RegistrationState.RegistrationNone);
|
||||
}
|
||||
|
||||
if(state.equals(RegistrationState.RegistrationCleared)){
|
||||
if(lc != null){
|
||||
LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
|
||||
if(authInfo != null)
|
||||
lc.removeAuthInfo(authInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayMissedCalls(final int missedCallsCount) {
|
||||
|
|
|
@ -795,9 +795,9 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
mListenerDispatcher.onGlobalStateChanged(state, message);
|
||||
}
|
||||
|
||||
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final RegistrationState state,final String message) {
|
||||
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig proxy,final RegistrationState state,final String message) {
|
||||
Log.i("new state ["+state+"]");
|
||||
mListenerDispatcher.onRegistrationStateChanged(state, message);
|
||||
mListenerDispatcher.onRegistrationStateChanged(proxy, state, message);
|
||||
}
|
||||
|
||||
private int savedMaxCallWhileGsmIncall;
|
||||
|
@ -1285,11 +1285,11 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
if (serviceListener != null) serviceListener.onGlobalStateChanged( state, message);
|
||||
}
|
||||
|
||||
public void onRegistrationStateChanged(RegistrationState state,
|
||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state,
|
||||
String message) {
|
||||
if (serviceListener != null) serviceListener.onRegistrationStateChanged(state, message);
|
||||
if (serviceListener != null) serviceListener.onRegistrationStateChanged(proxy, state, message);
|
||||
for (LinphoneOnRegistrationStateChangedListener listener : getSimpleListeners(LinphoneOnRegistrationStateChangedListener.class)) {
|
||||
listener.onRegistrationStateChanged(state);
|
||||
listener.onRegistrationStateChanged(proxy, state, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ public class LinphonePreferences {
|
|||
private String tempPassword;
|
||||
private String tempDomain;
|
||||
private String tempProxy;
|
||||
private String tempRealm;
|
||||
private boolean tempOutboundProxy;
|
||||
private String tempContactsParams;
|
||||
private String tempExpire;
|
||||
|
@ -245,6 +246,11 @@ public class LinphonePreferences {
|
|||
return this;
|
||||
}
|
||||
|
||||
public AccountBuilder setRealm(String realm) {
|
||||
tempRealm = realm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountBuilder setQualityReportingCollector(String collector) {
|
||||
tempQualityReportingCollector = collector;
|
||||
return this;
|
||||
|
@ -300,7 +306,7 @@ public class LinphonePreferences {
|
|||
|
||||
String route = tempOutboundProxy ? proxyAddr.asStringUriOnly() : null;
|
||||
|
||||
LinphoneProxyConfig prxCfg = LinphoneCoreFactory.instance().createProxyConfig(identityAddr.asString(), proxyAddr.asStringUriOnly(), route, tempEnabled);
|
||||
LinphoneProxyConfig prxCfg = lc.createProxyConfig(identityAddr.asString(), proxyAddr.asStringUriOnly(), route, tempEnabled);
|
||||
|
||||
if (tempContactsParams != null)
|
||||
prxCfg.setContactUriParameters(tempContactsParams);
|
||||
|
@ -315,7 +321,9 @@ public class LinphonePreferences {
|
|||
prxCfg.enableQualityReporting(tempQualityReportingEnabled);
|
||||
prxCfg.setQualityReportingCollector(tempQualityReportingCollector);
|
||||
prxCfg.setQualityReportingInterval(tempQualityReportingInterval);
|
||||
prxCfg.setRealm("sip.linphone.org");
|
||||
|
||||
if(tempRealm != null)
|
||||
prxCfg.setRealm(tempRealm);
|
||||
|
||||
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);
|
||||
|
||||
|
@ -327,11 +335,6 @@ public class LinphonePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isAccountDeleted(int n){
|
||||
LinphoneProxyConfig proxyConfig = getProxyConfig(n);
|
||||
return proxyConfig.getUserData() != null ? (Boolean) proxyConfig.getUserData() : false ;
|
||||
}
|
||||
|
||||
public void setAccountTransport(int n, String transport) {
|
||||
LinphoneProxyConfig proxyConfig = getProxyConfig(n);
|
||||
|
||||
|
@ -675,36 +678,17 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void deleteAccount(int n) {
|
||||
final LinphoneAuthInfo authInfo = getAuthInfo(n);
|
||||
final LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
||||
|
||||
proxyCfg.edit();
|
||||
proxyCfg.enableRegister(false);
|
||||
proxyCfg.done();
|
||||
|
||||
proxyCfg.setUserData(true);
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(proxyCfg.getState() != RegistrationState.RegistrationCleared
|
||||
&& proxyCfg.getState() != RegistrationState.RegistrationFailed
|
||||
&& proxyCfg.getState() != RegistrationState.RegistrationNone){
|
||||
}
|
||||
if (authInfo != null)
|
||||
getLc().removeAuthInfo(authInfo);
|
||||
if (proxyCfg != null)
|
||||
getLc().removeProxyConfig(proxyCfg);
|
||||
if (getLc().getProxyConfigList().length == 0) {
|
||||
// TODO: remove once issue http://bugs.linphone.org/view.php?id=984 will be fixed
|
||||
LinphoneActivity.instance().getStatusFragment().registrationStateChanged(RegistrationState.RegistrationNone);
|
||||
} else {
|
||||
resetDefaultProxyConfig();
|
||||
getLc().refreshRegisters();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
// End of accounts settings
|
||||
|
||||
// Audio settings
|
||||
|
|
|
@ -497,7 +497,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
}
|
||||
}
|
||||
|
||||
public void onRegistrationStateChanged(final RegistrationState state,
|
||||
public void onRegistrationStateChanged(final LinphoneProxyConfig proxy, final RegistrationState state,
|
||||
final String message) {
|
||||
// if (instance == null) {
|
||||
// Log.i("Service not ready, discarding registration state change to ",state.toString());
|
||||
|
@ -520,7 +520,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().onRegistrationStateChanged(state);
|
||||
LinphoneActivity.instance().onRegistrationStateChanged(proxy,state,message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.linphone;
|
|||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
|
@ -41,8 +42,8 @@ public interface LinphoneSimpleListener {
|
|||
void tryingNewOutgoingCallButCannotGetCallParameters();
|
||||
void tryingNewOutgoingCallButWrongDestinationAddress();
|
||||
void tryingNewOutgoingCallButAlreadyInCall();
|
||||
void onRegistrationStateChanged(RegistrationState state, String message);
|
||||
void onDisplayStatus(String message);
|
||||
void onRegistrationStateChanged(LinphoneProxyConfig proxy,RegistrationState state, String message);
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +69,7 @@ public interface LinphoneSimpleListener {
|
|||
}
|
||||
|
||||
public static interface LinphoneOnRegistrationStateChangedListener extends LinphoneSimpleListener {
|
||||
void onRegistrationStateChanged(RegistrationState state);
|
||||
void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message);
|
||||
}
|
||||
|
||||
public static interface ConnectivityChangedListener extends LinphoneSimpleListener {
|
||||
|
|
|
@ -278,7 +278,6 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
for (int i = 0; i < nbAccounts; i++) {
|
||||
final int accountId = i;
|
||||
// For each, add menus to configure it
|
||||
if(!mPrefs.isAccountDeleted(accountId)){
|
||||
String username = mPrefs.getAccountUsername(accountId);
|
||||
String domain = mPrefs.getAccountDomain(accountId);
|
||||
LedPreference account = new LedPreference(LinphoneService.instance());
|
||||
|
@ -304,7 +303,6 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
accounts.addPreference(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccountLed(final LedPreference me, final String username, final String domain, boolean enabled) {
|
||||
if (!enabled) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.linphone.R;
|
|||
import org.linphone.core.LinphoneAddress.TransportType;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
@ -201,7 +202,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
|
||||
|
||||
private LinphoneOnRegistrationStateChangedListener registrationListener = new LinphoneOnRegistrationStateChangedListener() {
|
||||
public void onRegistrationStateChanged(RegistrationState state) {
|
||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message) {
|
||||
if (state == RegistrationState.RegistrationOk) {
|
||||
LinphoneManager.removeListener(registrationListener);
|
||||
|
||||
|
@ -311,7 +312,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
.setAvpfRRInterval(3)
|
||||
.setQualityReportingCollector("sip:voip-metrics@sip.linphone.org")
|
||||
.setQualityReportingEnabled(true)
|
||||
.setQualityReportingInterval(180);
|
||||
.setQualityReportingInterval(180)
|
||||
.setRealm("sip.linphone.org");
|
||||
|
||||
|
||||
mPrefs.setStunServer(getString(R.string.default_stun));
|
||||
|
|
Loading…
Reference in a new issue