Commit 12f9bd6d authored by Alexandre Lision's avatar Alexandre Lision
Browse files

account: enable upnp by default for ring account

UPnP is set to false by default in the account template retrieved from
the daemon. It is enable manually in the other clients, but it was not
in the Android client.

This patch force unpn at ring account creation, and also provides a way
to turn it off in the account settings

Tuleap: #698
Change-Id: I453e59e73a124caa1d48e17de763bd4ef46cade9
parent cc28fb92
......@@ -59,6 +59,7 @@ import android.widget.Toast;
import java.util.HashMap;
import cx.ring.R;
import cx.ring.model.account.AccountDetail;
import cx.ring.model.account.AccountDetailAdvanced;
import cx.ring.model.account.AccountDetailBasic;
import cx.ring.service.LocalService;
......@@ -508,6 +509,8 @@ public class AccountCreationFragment extends Fragment {
if (mAccountType.equals(AccountDetailBasic.ACCOUNT_TYPE_RING)) {
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, "Ring");
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, "bootstrap.ring.cx");
// Enable UPNP by default for Ring accounts
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_UPNP_ENABLE, AccountDetail.TRUE_STR);
} else {
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, mAlias);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, mHostname);
......@@ -521,7 +524,6 @@ public class AccountCreationFragment extends Fragment {
getString(R.string.account_sip_dtmf_type_sipinfo));
createNewAccount(accountDetails);
} catch (RemoteException e) {
Toast.makeText(getActivity(), "Error creating account", Toast.LENGTH_SHORT).show();
e.printStackTrace();
......
......@@ -19,13 +19,6 @@
*/
package cx.ring.fragments;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import cx.ring.R;
import android.app.Activity;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
......@@ -37,9 +30,15 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import cx.ring.R;
import cx.ring.model.account.Account;
import cx.ring.model.account.AccountDetail;
import cx.ring.model.account.AccountDetailAdvanced;
import cx.ring.model.account.Account;
import cx.ring.views.EditTextIntegerPreference;
import cx.ring.views.EditTextPreferenceDialog;
import cx.ring.views.PasswordPreference;
......@@ -126,7 +125,7 @@ public class AdvancedAccountFragment extends PreferenceFragment {
if (pref instanceof EditTextPreference)
((EditTextPreference) pref).setText(p.mValue);
} else {
((TwoStatePreference) pref).setChecked(p.mValue.contentEquals("true"));
((TwoStatePreference) pref).setChecked(p.mValue.contentEquals(AccountDetail.TRUE_STR));
}
}
}
......
......@@ -268,7 +268,7 @@ public class MediaPreferenceFragment extends PreferenceFragment implements Fragm
Preference pref = findPreference(p.mKey);
if (pref != null) {
if (pref instanceof TwoStatePreference) {
((TwoStatePreference) pref).setChecked(p.mValue.contentEquals("true"));
((TwoStatePreference) pref).setChecked(p.mValue.contentEquals(AccountDetail.TRUE_STR));
} else if (p.mKey.contentEquals(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE)) {
pref.setDefaultValue(p.mValue.contentEquals("overrtp") ? "RTP" : "SIP");
pref.setSummary(p.mValue.contentEquals("overrtp") ? "RTP" : "SIP");
......
......@@ -21,14 +21,14 @@
package cx.ring.model.account;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.text.TextUtils;
import android.util.Log;
public class Account extends java.util.Observable {
private static final String TAG = "Account";
......@@ -94,9 +94,9 @@ public class Account extends java.util.Observable {
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS);
}
public Boolean isSip() {
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_TYPE).equals("SIP");
}
public Boolean isSip() {
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_TYPE).equals("SIP");
}
public Boolean isRing() {
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_TYPE).equals("RING");
......@@ -164,6 +164,7 @@ public class Account extends java.util.Observable {
public boolean isRegistered() {
return (getRegistered_state().contentEquals(AccountDetailVolatile.STATE_READY) || getRegistered_state().contentEquals(AccountDetailVolatile.STATE_REGISTERED));
}
public boolean isInError() {
String state = getRegistered_state();
return (state.contentEquals(AccountDetailVolatile.STATE_ERROR)
......@@ -183,7 +184,7 @@ public class Account extends java.util.Observable {
}
public boolean isAutoanswerEnabled() {
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_AUTOANSWER).contentEquals("true");
return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_AUTOANSWER).contentEquals(AccountDetail.TRUE_STR);
}
public ArrayList<AccountCredentials> getCredentials() {
......@@ -219,7 +220,7 @@ public class Account extends java.util.Observable {
return getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_SRTP_ENABLE) || getTlsDetails().getDetailBoolean(AccountDetailTls.CONFIG_TLS_ENABLE);
}
public String getShareURI(){
public String getShareURI() {
String share_uri;
if (isRing()) {
share_uri = getBasicDetails().getUsername();
......
......@@ -21,6 +21,8 @@
*/
package cx.ring.model.account;
import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -28,8 +30,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import android.util.Log;
public class AccountDetailBasic implements AccountDetail {
private static final String TAG = AccountDetailBasic.class.getSimpleName();
......@@ -40,6 +40,7 @@ public class AccountDetailBasic implements AccountDetail {
public static final String CONFIG_ACCOUNT_PASSWORD = "Account.password";
public static final String CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
public static final String CONFIG_ACCOUNT_UPNP_ENABLE = "Account.upnpEnabled";
public static final String CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
public static final String CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
......@@ -57,6 +58,7 @@ public class AccountDetailBasic implements AccountDetail {
private static final Set<String> TWO_STATES = new HashSet<>(Arrays.asList(
CONFIG_ACCOUNT_ENABLE,
CONFIG_ACCOUNT_AUTOANSWER,
CONFIG_ACCOUNT_UPNP_ENABLE,
CONFIG_VIDEO_ENABLED));
private ArrayList<AccountDetail.PreferenceEntry> privateArray;
......@@ -64,9 +66,11 @@ public class AccountDetailBasic implements AccountDetail {
public String getAlias() {
return getDetailString(CONFIG_ACCOUNT_ALIAS);
}
public String getUsername() {
return getDetailString(CONFIG_ACCOUNT_USERNAME);
}
public String getHostname() {
return getDetailString(CONFIG_ACCOUNT_HOSTNAME);
}
......
......@@ -33,25 +33,15 @@ public class AccountDetailSrtp implements AccountDetail {
public static final String CONFIG_SRTP_KEY_EXCHANGE = "SRTP.keyExchange";
public static final String CONFIG_SRTP_ENCRYPTION_ALGO = "SRTP.encryptionAlgorithm"; // Provided by ccRTP,0=NULL,1=AESCM,2=AESF8
public static final String CONFIG_SRTP_RTP_FALLBACK = "SRTP.rtpFallback";
/*public static final String CONFIG_ZRTP_HELLO_HASH = "ZRTP.helloHashEnable";
public static final String CONFIG_ZRTP_DISPLAY_SAS = "ZRTP.displaySAS";
public static final String CONFIG_ZRTP_NOT_SUPP_WARNING = "ZRTP.notSuppWarning";
public static final String CONFIG_ZRTP_DISPLAY_SAS_ONCE = "ZRTP.displaySasOnce";*/
private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries() {
ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<>();
preference.add(new PreferenceEntry(CONFIG_SRTP_ENABLE, true));
preference.add(new PreferenceEntry(CONFIG_SRTP_KEY_EXCHANGE, false));
preference.add(new PreferenceEntry(CONFIG_SRTP_ENCRYPTION_ALGO, true));
preference.add(new PreferenceEntry(CONFIG_SRTP_RTP_FALLBACK, true));
/*preference.add(new PreferenceEntry(CONFIG_ZRTP_HELLO_HASH, true));
preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS, true));
preference.add(new PreferenceEntry(CONFIG_ZRTP_NOT_SUPP_WARNING, true));
preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS_ONCE, true));*/
return preference;
}
......@@ -67,8 +57,7 @@ public class AccountDetailSrtp implements AccountDetail {
}
public ArrayList<String> getValuesOnly() {
ArrayList<String> valueList = new ArrayList<String>();
ArrayList<String> valueList = new ArrayList<>();
for (AccountDetail.PreferenceEntry p : privateArray) {
valueList.add(p.mValue);
}
......@@ -77,8 +66,7 @@ public class AccountDetailSrtp implements AccountDetail {
}
public HashMap<String, String> getDetailsHashMap() {
HashMap<String, String> map = new HashMap<String, String>();
HashMap<String, String> map = new HashMap<>();
for (AccountDetail.PreferenceEntry p : privateArray) {
if (p.mValue == null) {
map.put(p.mKey, "");
......@@ -92,14 +80,12 @@ public class AccountDetailSrtp implements AccountDetail {
public String getDetailString(String key) {
String value = "";
for (AccountDetail.PreferenceEntry p : privateArray) {
if (p.mKey.equals(key)) {
value = p.mValue;
return value;
}
}
return value;
}
......@@ -110,13 +96,12 @@ public class AccountDetailSrtp implements AccountDetail {
privateArray.get(i).mValue = newValue;
}
}
}
public boolean getDetailBoolean(String srtpParam) {
for (AccountDetail.PreferenceEntry p : privateArray) {
if (p.mKey.equals(srtpParam)) {
return p.mValue.contentEquals("true");
return p.mValue.contentEquals(AccountDetail.TRUE_STR);
}
}
return false;
......
......@@ -78,7 +78,7 @@ public class AccountDetailTls implements AccountDetail {
}
public ArrayList<String> getValuesOnly() {
ArrayList<String> valueList = new ArrayList<String>();
ArrayList<String> valueList = new ArrayList<>();
for (AccountDetail.PreferenceEntry p : privateArray) {
valueList.add(p.mValue);
......@@ -88,7 +88,7 @@ public class AccountDetailTls implements AccountDetail {
}
public HashMap<String, String> getDetailsHashMap() {
HashMap<String, String> map = new HashMap<String, String>();
HashMap<String, String> map = new HashMap<>();
for (AccountDetail.PreferenceEntry p : privateArray) {
if (p.mValue == null) {
......@@ -127,7 +127,7 @@ public class AccountDetailTls implements AccountDetail {
public boolean getDetailBoolean(String key) {
for (AccountDetail.PreferenceEntry p : privateArray) {
if (p.mKey.equals(key)) {
return p.mValue.contentEquals("true");
return p.mValue.contentEquals(AccountDetail.TRUE_STR);
}
}
return false;
......
......@@ -68,6 +68,7 @@ along with this program; if not, write to the Free Software
<string name="account_optionnal_category">Optional Settings</string>
<string name="account_useragent_label">User Agent</string>
<string name="account_autoanswer_label">Auto Answer</string>
<string name="account_upnp_label">Enable UPnP</string>
<string name="account_proxy_field">Proxy</string>
<!-- Audio Details -->
......
......@@ -52,6 +52,12 @@ along with this program; if not, write to the Free Software
android:key="Account.autoAnswer"
android:persistent="false"
android:title="@string/account_autoanswer_label" />
<android.support.v14.preference.SwitchPreference
android:id="@+id/account_upnp"
android:key="Account.upnpEnabled"
android:persistent="false"
android:title="@string/account_upnp_label" />
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment