Fix sip port and random port
This commit is contained in:
parent
18bd5b0185
commit
5c898ca323
4 changed files with 17 additions and 8 deletions
|
@ -4,7 +4,6 @@ upload_bw=512
|
|||
firewall_policy=0
|
||||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
contact=sip:unknown@unknown-host
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
|
|
|
@ -3,7 +3,6 @@ download_bw=380
|
|||
upload_bw=380
|
||||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
contact=sip:unknown@unknown-host
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
|
|
|
@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class LinphonePreferences {
|
||||
private static final int LINPHONE_CORE_RANDOM_PORT = -1;
|
||||
private static LinphonePreferences instance;
|
||||
private Context mContext;
|
||||
|
||||
|
@ -403,11 +404,19 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void useRandomPort(boolean enabled) {
|
||||
getConfig().setBool("sip", "sip_random_port", enabled); //FIXME
|
||||
getConfig().setBool("app", "random_port", enabled);
|
||||
if (enabled) {
|
||||
setSipPort(LINPHONE_CORE_RANDOM_PORT);
|
||||
} else {
|
||||
if (getTransport().equals(getString(R.string.pref_transport_tls)))
|
||||
setSipPort(5061);
|
||||
else
|
||||
setSipPort(5060);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUsingRandomPort() {
|
||||
return getConfig().getBool("sip", "sip_random_port", true); //FIXME
|
||||
return getConfig().getBool("app", "random_port", true);
|
||||
}
|
||||
|
||||
public String getSipPort() {
|
||||
|
@ -423,9 +432,6 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setSipPort(int port) {
|
||||
if (port <= 0)
|
||||
return;
|
||||
|
||||
Transports transports = getLc().getSignalingTransportPorts();
|
||||
if (transports.udp > 0)
|
||||
transports.udp = port;
|
||||
|
|
|
@ -466,7 +466,12 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
findPreference(getString(R.string.pref_sip_port_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mPrefs.setSipPort((Integer) newValue);
|
||||
int port = -1;
|
||||
try {
|
||||
port = Integer.parseInt(newValue.toString());
|
||||
} catch (NumberFormatException nfe) { }
|
||||
|
||||
mPrefs.setSipPort(port);
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue