Preference Helper functions in Manager
This commit is contained in:
parent
25f6a5445c
commit
81a6fa2a93
1 changed files with 45 additions and 42 deletions
|
@ -319,7 +319,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
if (Version.isVideoCapable()) {
|
if (Version.isVideoCapable()) {
|
||||||
boolean prefVideoEnable = isVideoEnabled();
|
boolean prefVideoEnable = isVideoEnabled();
|
||||||
int key = R.string.pref_video_initiate_call_with_video_key;
|
int key = R.string.pref_video_initiate_call_with_video_key;
|
||||||
boolean prefInitiateWithVideo = mPref.getBoolean(mR.getString(key), false);
|
boolean prefInitiateWithVideo = getPrefBoolean(key, false);
|
||||||
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo);
|
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo);
|
||||||
} else {
|
} else {
|
||||||
CallManager.getInstance().inviteAddress(lAddress, false);
|
CallManager.getInstance().inviteAddress(lAddress, false);
|
||||||
|
@ -333,7 +333,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCameraFromPreferences() {
|
public void resetCameraFromPreferences() {
|
||||||
boolean useFrontCam = mPref.getBoolean(mR.getString(R.string.pref_video_use_front_camera_key), false);
|
boolean useFrontCam = getPrefBoolean(R.string.pref_video_use_front_camera_key, false);
|
||||||
|
|
||||||
int camId = 0;
|
int camId = 0;
|
||||||
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
|
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
|
||||||
|
@ -404,7 +404,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(
|
mLc = LinphoneCoreFactory.instance().createLinphoneCore(
|
||||||
this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
||||||
|
|
||||||
mLc.enableIpv6(mPref.getBoolean(getString(R.string.pref_ipv6_key), false));
|
mLc.enableIpv6(getPrefBoolean(R.string.pref_ipv6_key, false));
|
||||||
mLc.setZrtpSecretsCache(basePath+"/zrtp_secrets");
|
mLc.setZrtpSecretsCache(basePath+"/zrtp_secrets");
|
||||||
|
|
||||||
mLc.setPlaybackGain(3);
|
mLc.setPlaybackGain(3);
|
||||||
|
@ -475,7 +475,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMediaEncryption(){
|
void initMediaEncryption(){
|
||||||
String pref = mPref.getString(getString(R.string.pref_media_encryption_key),
|
String pref = getPrefString(R.string.pref_media_encryption_key,
|
||||||
getString(R.string.pref_media_encryption_key_none));
|
getString(R.string.pref_media_encryption_key_none));
|
||||||
MediaEncryption me=MediaEncryption.None;
|
MediaEncryption me=MediaEncryption.None;
|
||||||
if (pref.equals(getString(R.string.pref_media_encryption_key_srtp)))
|
if (pref.equals(getString(R.string.pref_media_encryption_key_srtp)))
|
||||||
|
@ -530,23 +530,23 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
boolean isVideoEnabled = isVideoEnabled();
|
boolean isVideoEnabled = isVideoEnabled();
|
||||||
mLc.enableVideo(isVideoEnabled, isVideoEnabled);
|
mLc.enableVideo(isVideoEnabled, isVideoEnabled);
|
||||||
//1 read proxy config from preferences
|
//1 read proxy config from preferences
|
||||||
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
String lUserName = getPrefString(R.string.pref_username_key, null);
|
||||||
if (lUserName == null || lUserName.length()==0) {
|
if (lUserName == null || lUserName.length()==0) {
|
||||||
throw new LinphoneConfigException(getString(R.string.wrong_username));
|
throw new LinphoneConfigException(getString(R.string.wrong_username));
|
||||||
}
|
}
|
||||||
|
|
||||||
String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null);
|
String lPasswd = getPrefString(R.string.pref_passwd_key, null);
|
||||||
// we have the right of having no password
|
// we have the right of having no password
|
||||||
//if (lPasswd == null || lPasswd.length()==0) {
|
//if (lPasswd == null || lPasswd.length()==0) {
|
||||||
// throw new LinphoneConfigException(getString(R.string.wrong_passwd));
|
// throw new LinphoneConfigException(getString(R.string.wrong_passwd));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
String lDomain = mPref.getString(getString(R.string.pref_domain_key), null);
|
String lDomain = getPrefString(R.string.pref_domain_key, null);
|
||||||
if (lDomain == null || lDomain.length()==0) {
|
if (lDomain == null || lDomain.length()==0) {
|
||||||
throw new LinphoneConfigException(getString(R.string.wrong_domain));
|
throw new LinphoneConfigException(getString(R.string.wrong_domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
String lStun = mPref.getString(getString(R.string.pref_stun_server_key), null);
|
String lStun = getPrefString(R.string.pref_stun_server_key, null);
|
||||||
|
|
||||||
//stun server
|
//stun server
|
||||||
mLc.setStunServer(lStun);
|
mLc.setStunServer(lStun);
|
||||||
|
@ -562,7 +562,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
//proxy
|
//proxy
|
||||||
mLc.clearProxyConfigs();
|
mLc.clearProxyConfigs();
|
||||||
String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null);
|
String lProxy = getPrefString(R.string.pref_proxy_key,null);
|
||||||
if (lProxy == null || lProxy.length() == 0) {
|
if (lProxy == null || lProxy.length() == 0) {
|
||||||
lProxy = "sip:"+lDomain;
|
lProxy = "sip:"+lDomain;
|
||||||
}
|
}
|
||||||
|
@ -589,14 +589,14 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
if (lDefaultProxyConfig !=null) {
|
if (lDefaultProxyConfig !=null) {
|
||||||
//prefix
|
//prefix
|
||||||
String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null);
|
String lPrefix = getPrefString(R.string.pref_prefix_key, null);
|
||||||
if (lPrefix != null) {
|
if (lPrefix != null) {
|
||||||
lDefaultProxyConfig.setDialPrefix(lPrefix);
|
lDefaultProxyConfig.setDialPrefix(lPrefix);
|
||||||
}
|
}
|
||||||
//escape +
|
//escape +
|
||||||
lDefaultProxyConfig.setDialEscapePlus(mPref.getBoolean(getString(R.string.pref_escape_plus_key),false));
|
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key,false));
|
||||||
//outbound proxy
|
//outbound proxy
|
||||||
if (mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key), false)) {
|
if (getPrefBoolean(R.string.pref_enable_outbound_proxy_key, false)) {
|
||||||
lDefaultProxyConfig.setRoute(lProxy);
|
lDefaultProxyConfig.setRoute(lProxy);
|
||||||
} else {
|
} else {
|
||||||
lDefaultProxyConfig.setRoute(null);
|
lDefaultProxyConfig.setRoute(null);
|
||||||
|
@ -611,16 +611,12 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getBool(int key, boolean defValue) {
|
|
||||||
return mPref.getBoolean(getString(key), defValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSignalingTransportsFromConfiguration(Transports t) {
|
private void setSignalingTransportsFromConfiguration(Transports t) {
|
||||||
Transports ports = new Transports(t);
|
Transports ports = new Transports(t);
|
||||||
boolean useStandardPort = getBool(R.string.pref_transport_use_standard_ports_key, false);
|
boolean useStandardPort = getPrefBoolean(R.string.pref_transport_use_standard_ports_key, false);
|
||||||
int lPreviousPort = ports.tcp +ports.udp +ports.tls; // assume only one port is active
|
int lPreviousPort = ports.tcp +ports.udp +ports.tls; // assume only one port is active
|
||||||
|
|
||||||
if (!getBool(R.string.pref_transport_tcp_key, false)) {
|
if (!getPrefBoolean(R.string.pref_transport_tcp_key, false)) {
|
||||||
ports.tcp = 0;
|
ports.tcp = 0;
|
||||||
} else if (useStandardPort) {
|
} else if (useStandardPort) {
|
||||||
ports.tcp = 5060;
|
ports.tcp = 5060;
|
||||||
|
@ -628,7 +624,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
ports.tcp=lPreviousPort;
|
ports.tcp=lPreviousPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getBool(R.string.pref_transport_udp_key, false)) {
|
if (!getPrefBoolean(R.string.pref_transport_udp_key, false)) {
|
||||||
ports.udp = 0;
|
ports.udp = 0;
|
||||||
} else if (useStandardPort) {
|
} else if (useStandardPort) {
|
||||||
ports.udp = 5060;
|
ports.udp = 5060;
|
||||||
|
@ -636,7 +632,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
ports.udp = lPreviousPort;
|
ports.udp = lPreviousPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getBool(R.string.pref_transport_tls_key, false)) {
|
if (!getPrefBoolean(R.string.pref_transport_tls_key, false)) {
|
||||||
ports.tls = 0;
|
ports.tls = 0;
|
||||||
} else if (useStandardPort) {
|
} else if (useStandardPort) {
|
||||||
ports.tls = 5061;
|
ports.tls = 5061;
|
||||||
|
@ -650,7 +646,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
private void enableDisableAudioCodec(String codec, int rate, int key) throws LinphoneCoreException {
|
private void enableDisableAudioCodec(String codec, int rate, int key) throws LinphoneCoreException {
|
||||||
PayloadType pt = mLc.findPayloadType(codec, rate);
|
PayloadType pt = mLc.findPayloadType(codec, rate);
|
||||||
if (pt !=null) {
|
if (pt !=null) {
|
||||||
boolean enable= mPref.getBoolean(getString(key),false);
|
boolean enable= getPrefBoolean(key,false);
|
||||||
mLc.enablePayloadType(pt, enable);
|
mLc.enablePayloadType(pt, enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -679,7 +675,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enable= mPref.getBoolean(getString(key),false);
|
boolean enable= getPrefBoolean(key,false);
|
||||||
mLc.enablePayloadType(videoCodec, enable);
|
mLc.enablePayloadType(videoCodec, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,6 +699,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
private String getString(int key) {
|
private String getString(int key) {
|
||||||
return mR.getString(key);
|
return mR.getString(key);
|
||||||
}
|
}
|
||||||
|
private boolean getPrefBoolean(int key, boolean value) {
|
||||||
|
return mPref.getBoolean(mR.getString(key), value);
|
||||||
|
}
|
||||||
|
private String getPrefString(int key, String value) {
|
||||||
|
return mPref.getString(mR.getString(key), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -951,11 +954,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVideoEnabled() {
|
public boolean isVideoEnabled() {
|
||||||
return mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
|
return getPrefBoolean(R.string.pref_video_enable_key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shareMyCamera() {
|
public boolean shareMyCamera() {
|
||||||
return isVideoEnabled() && mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
|
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_automatically_share_my_video_key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioModeIncallForGalaxyS() {
|
public void setAudioModeIncallForGalaxyS() {
|
||||||
|
|
Loading…
Reference in a new issue