Modified Hiearchy of packages (clean up)
Modified AccountSelectionButton to Spinner
Modified build instructions
Added make-glue.sh to generate interfaces (using dbusxx)
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetail.java b/src/com/savoirfairelinux/sflphone/account/AccountDetail.java
new file mode 100644
index 0000000..50a6257
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetail.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public interface AccountDetail {
+
+ public static class PreferenceEntry
+ {
+ public String mKey;
+ public int mLabelId;
+ public boolean isTwoState;
+ public String mValue;
+
+ public PreferenceEntry(String key, int labelId)
+ {
+ mKey = key;
+ mLabelId = labelId;
+ isTwoState = false;
+ mValue = "";
+ }
+
+ public PreferenceEntry(String key, int labelId, boolean twoState)
+ {
+ mKey = key;
+ mLabelId = labelId;
+ isTwoState = twoState;
+ mValue = "";
+ }
+
+ public PreferenceEntry(String key, int labelId, boolean twoState, String value)
+ {
+ mKey = key;
+ mLabelId = labelId;
+ isTwoState = twoState;
+ mValue = value;
+ }
+ }
+
+ public ArrayList<PreferenceEntry> getDetailValues();
+
+ public ArrayList<String> getValuesOnly();
+
+ public HashMap<String, String> getDetailsHashMap();
+
+ public String getDetailString(String key);
+
+ public void setDetailString(int position, String newValue);
+
+ public boolean getDetailBoolean();
+}
+
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java
new file mode 100644
index 0000000..04de9ff
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java
@@ -0,0 +1,177 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashMap;
+
+public class AccountDetailAdvanced implements AccountDetail {
+
+ private static final String TAG = "AccountDetailAdvanced";
+ public static final String BUNDLE_TAG = "AdvancedPreferenceArrayList";
+
+ public static final String CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
+ public static final String CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire";
+ public static final String CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
+ public static final String CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode";
+ public static final String CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.registrationDescription";
+ public static final String CONFIG_CREDENTIAL_NUMBER = "Credential.count";
+ public static final String CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfType";
+ public static final String CONFIG_RINGTONE_PATH = "Account.ringtonePath";
+ public static final String CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled";
+ public static final String CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled";
+
+ public static final String CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
+ public static final String CONFIG_LOCAL_INTERFACE = "Account.localInterface";
+ public static final String CONFIG_INTERFACE = "Account.interface";
+ public static final String CONFIG_PUBLISHED_SAMEAS_LOCAL = "Account.publishedSameAsLocal";
+ public static final String CONFIG_LOCAL_PORT = "Account.localPort";
+ public static final String CONFIG_PUBLISHED_PORT = "Account.publishedPort";
+ public static final String CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
+ public static final String CONFIG_DEFAULT_LOCAL_PORT = "5060";
+ public static final String CONFIG_DEFAULT_PUBLISHED_PORT = "5060";
+ public static final String CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL = "true";
+ public static final String CONFIG_DEFAULT_INTERFACE = "default";
+
+ public static final String CONFIG_DISPLAY_NAME = "Account.displayName";
+ public static final String CONFIG_DEFAULT_ADDRESS = "0.0.0.0";
+
+ public static final String CONFIG_STUN_SERVER = "STUN.server";
+ public static final String CONFIG_STUN_ENABLE = "STUN.enable";
+
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
+
+ public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
+ {
+ ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<AccountDetail.PreferenceEntry>();
+
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_EXPIRE, R.string.account_registration_exp_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATUS, R.string.account_registration_status_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, R.string.account_registration_code_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, R.string.account_registration_state_label));
+ preference.add(new PreferenceEntry(CONFIG_CREDENTIAL_NUMBER, R.string.account_credential_count_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_DTMF_TYPE, R.string.account_config_dtmf_type_label));
+ preference.add(new PreferenceEntry(CONFIG_RINGTONE_PATH, R.string.account_ringtone_path_label));
+ preference.add(new PreferenceEntry(CONFIG_RINGTONE_ENABLED, R.string.account_ringtone_enabled_label, true));
+ preference.add(new PreferenceEntry(CONFIG_KEEP_ALIVE_ENABLED, R.string.account_keep_alive_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_AUTOANSWER, R.string.account_account_interface_label, true));
+ preference.add(new PreferenceEntry(CONFIG_LOCAL_INTERFACE, R.string.account_local_interface_label));
+ preference.add(new PreferenceEntry(CONFIG_INTERFACE, R.string.account_account_interface_label));
+ preference.add(new PreferenceEntry(CONFIG_PUBLISHED_SAMEAS_LOCAL, R.string.account_published_same_as_local_label, true));
+ preference.add(new PreferenceEntry(CONFIG_LOCAL_PORT, R.string.account_local_port_label));
+ preference.add(new PreferenceEntry(CONFIG_PUBLISHED_PORT, R.string.account_published_port_label));
+ preference.add(new PreferenceEntry(CONFIG_PUBLISHED_ADDRESS, R.string.account_published_address_label));
+ preference.add(new PreferenceEntry(CONFIG_DISPLAY_NAME, R.string.account_displayname_label));
+ preference.add(new PreferenceEntry(CONFIG_STUN_SERVER, R.string.account_stun_server_label));
+ preference.add(new PreferenceEntry(CONFIG_STUN_ENABLE, R.string.account_stun_enable_label, true));
+
+ return preference;
+ }
+
+ public AccountDetailAdvanced()
+ {
+ privateArray = getPreferenceEntries();
+ }
+
+ public AccountDetailAdvanced(HashMap<String, String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
+ }
+
+ public AccountDetailAdvanced(ArrayList<String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public HashMap<String, String> getDetailsHashMap()
+ {
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ map.put(p.mKey, p.mValue);
+ }
+
+ return map;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public void setDetailString(int position, String newValue)
+ {
+ privateArray.get(position).mValue = newValue;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
+ }
+
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java
new file mode 100644
index 0000000..03a1354
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java
@@ -0,0 +1,151 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashMap;
+
+public class AccountDetailBasic implements AccountDetail {
+
+ private static final String TAG = "AccountDetailBasic";
+ public static final String BUNDLE_TAG = "BasicPreferenceArrayList";
+
+ public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable";
+ public static final String CONFIG_ACCOUNT_TYPE = "Account.type";
+ public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias";
+ public static final String CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
+ public static final String CONFIG_ACCOUNT_USERNAME = "Account.username";
+ public static final String CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
+ public static final String CONFIG_ACCOUNT_PASSWORD = "Account.password";
+ public static final String CONFIG_ACCOUNT_REALM = "Account.realm";
+ public static final String CONFIG_ACCOUNT_DEFAULT_REALM = "*";
+ public static final String CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
+
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
+
+ public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
+ {
+ ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<AccountDetail.PreferenceEntry>();
+
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ENABLE, R.string.account_enabled_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_TYPE, R.string.account_type_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ALIAS, R.string.account_alias_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_HOSTNAME, R.string.account_hostname_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_USERNAME, R.string.account_username_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_ROUTESET, R.string.account_routeset_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_PASSWORD, R.string.account_password_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_REALM, R.string.account_realm_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_DEFAULT_REALM, R.string.account_useragent_label));
+ preference.add(new PreferenceEntry(CONFIG_ACCOUNT_USERAGENT, R.string.account_autoanswer_label));
+
+ return preference;
+ }
+
+ public AccountDetailBasic()
+ {
+ privateArray = getPreferenceEntries();
+ }
+
+ public AccountDetailBasic(HashMap<String, String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
+ }
+
+ public AccountDetailBasic(ArrayList<String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public HashMap<String, String> getDetailsHashMap()
+ {
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ map.put(p.mKey, p.mValue);
+ }
+
+ return map;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public void setDetailString(int position, String newValue)
+ {
+ privateArray.get(position).mValue = newValue;
+ }
+
+
+ public boolean getDetailBoolean()
+ {
+ return true;
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java
new file mode 100644
index 0000000..d0b67ec
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashMap;
+
+public class AccountDetailSrtp implements AccountDetail{
+
+ private static final String TAG = "AccountDetailSrtp";
+ public static final String BUNDLE_TAG = "SrtpPreferenceArrayList";
+
+ public static final String CONFIG_SRTP_ENABLE = "SRTP.enable";
+ 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<AccountDetail.PreferenceEntry>();
+
+ preference.add(new PreferenceEntry(CONFIG_SRTP_ENABLE, R.string.account_srtp_enabled_label, true));
+ preference.add(new PreferenceEntry(CONFIG_SRTP_KEY_EXCHANGE, R.string.account_srtp_exchange_label, true));
+ preference.add(new PreferenceEntry(CONFIG_SRTP_ENCRYPTION_ALGO, R.string.account_encryption_algo_label, true));
+ preference.add(new PreferenceEntry(CONFIG_SRTP_RTP_FALLBACK, R.string.account_srtp_fallback_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ZRTP_HELLO_HASH, R.string.account_hello_hash_enable_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS, R.string.account_display_sas_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ZRTP_NOT_SUPP_WARNING, R.string.account_not_supported_warning_label, true));
+ preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS_ONCE, R.string.account_display_sas_once_label, true));
+
+ return preference;
+ }
+
+ public AccountDetailSrtp()
+ {
+ privateArray = getPreferenceEntries();
+ }
+
+ public AccountDetailSrtp(HashMap<String, String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
+ }
+
+ public AccountDetailSrtp(ArrayList<String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public HashMap<String, String> getDetailsHashMap()
+ {
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ map.put(p.mKey, p.mValue);
+ }
+
+ return map;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public void setDetailString(int position, String newValue)
+ {
+ privateArray.get(position).mValue = newValue;
+ }
+
+
+ public boolean getDetailBoolean()
+ {
+ return true;
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java
new file mode 100644
index 0000000..0db1640
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java
@@ -0,0 +1,158 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashMap;
+
+public class AccountDetailTls implements AccountDetail {
+
+ private static final String TAG = "AccountDetailTls";
+ public static final String BUNDLE_TAG = "TlsPreferenceArrayList";
+
+ public static final String CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort";
+ public static final String CONFIG_TLS_ENABLE = "TLS.enable";
+ public static final String CONFIG_TLS_CA_LIST_FILE = "TLS.certificateListFile";
+ public static final String CONFIG_TLS_CERTIFICATE_FILE = "TLS.certificateFile";
+ public static final String CONFIG_TLS_PRIVATE_KEY_FILE = "TLS.privateKeyFile";
+ public static final String CONFIG_TLS_PASSWORD = "TLS.password";
+ public static final String CONFIG_TLS_METHOD = "TLS.method";
+ public static final String CONFIG_TLS_CIPHERS = "TLS.ciphers";
+ public static final String CONFIG_TLS_SERVER_NAME = "TLS.serverName";
+ public static final String CONFIG_TLS_VERIFY_SERVER = "TLS.verifyServer";
+ public static final String CONFIG_TLS_VERIFY_CLIENT = "TLS.verifyClient";
+ public static final String CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate";
+ public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec";
+ public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC = "TLS.negotiationTimemoutMsec";
+
+ private ArrayList<AccountDetail.PreferenceEntry> privateArray;
+
+ public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
+ {
+ ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<AccountDetail.PreferenceEntry>();
+
+ preference.add(new PreferenceEntry(CONFIG_TLS_LISTENER_PORT, R.string.account_listener_port_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_ENABLE, R.string.account_tls_enabled_label, true));
+ preference.add(new PreferenceEntry(CONFIG_TLS_CA_LIST_FILE, R.string.account_tls_certificate_list_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_CERTIFICATE_FILE, R.string.account_tls_certificate_file_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_PRIVATE_KEY_FILE, R.string.account_tls_private_key_file_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_PASSWORD, R.string.account_tls_password_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_METHOD, R.string.account_tls_method_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_CIPHERS, R.string.account_tls_ciphers_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_SERVER_NAME, R.string.account_tls_server_name_label));
+ preference.add(new PreferenceEntry(CONFIG_TLS_VERIFY_SERVER, R.string.account_tls_verify_label, true));
+ preference.add(new PreferenceEntry(CONFIG_TLS_VERIFY_CLIENT, R.string.account_tls_verify_client_label, true));
+ preference.add(new PreferenceEntry(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, R.string.account_tls_require_client_certificat_label, true));
+ preference.add(new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, R.string.account_tls_negotiation_timeout_sec));
+ preference.add(new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, R.string.account_tls_negotiation_timeout_msec));
+
+ return preference;
+ }
+
+ public AccountDetailTls()
+ {
+ privateArray = getPreferenceEntries();
+ }
+
+ public AccountDetailTls(HashMap<String, String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ p.mValue = pref.get(p.mKey);
+ }
+ }
+
+ public AccountDetailTls(ArrayList<String> pref)
+ {
+ privateArray = getPreferenceEntries();
+
+ if(pref.size() != privateArray.size()) {
+ Log.i(TAG, "Error list are not of equal size");
+ }
+ else {
+ int index = 0;
+ for(String s : pref) {
+ privateArray.get(index).mValue = s;
+ index++;
+ }
+ }
+ }
+
+ public ArrayList<AccountDetail.PreferenceEntry> getDetailValues()
+ {
+ return privateArray;
+ }
+
+ public ArrayList<String> getValuesOnly()
+ {
+ ArrayList<String> valueList = new ArrayList<String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ valueList.add(p.mValue);
+ }
+
+ return valueList;
+ }
+
+ public HashMap<String, String> getDetailsHashMap()
+ {
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ map.put(p.mKey, p.mValue);
+ }
+
+ return map;
+ }
+
+ public String getDetailString(String key)
+ {
+ String value = "";
+
+ for(AccountDetail.PreferenceEntry p : privateArray) {
+ if(p.mKey.equals(key)) {
+ value = p.mValue;
+ return value;
+ }
+ }
+
+ return value;
+ }
+
+ public void setDetailString(int position, String newValue)
+ {
+ privateArray.get(position).mValue = newValue;
+ }
+
+ public boolean getDetailBoolean()
+ {
+ return true;
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java
new file mode 100644
index 0000000..3e71d72
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java
@@ -0,0 +1,305 @@
+/**
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * If you own a pjsip commercial license you can also redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License
+ * as an android library.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import android.util.Log;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.service.ServiceConstants;
+import com.savoirfairelinux.sflphone.service.StringMap;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+public class AccountDetailsHandler {
+ private static final String TAG = "AccountDetailsHandler";
+
+ public static class PreferenceEntry
+ {
+ public String mKey;
+ public int mLabelId;
+
+ public PreferenceEntry(String key, int labelId)
+ {
+ mKey = key;
+ mLabelId = labelId;
+ }
+ }
+
+ public static ArrayList<PreferenceEntry> getBasicDetailsKeys()
+ {
+ ArrayList<PreferenceEntry> basicDetailKeys = new ArrayList<PreferenceEntry>();
+
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_TYPE,
+ R.string.account_type_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_ALIAS,
+ R.string.account_alias_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_ENABLE,
+ R.string.account_enabled_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_HOSTNAME,
+ R.string.account_hostname_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_USERNAME,
+ R.string.account_username_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_ROUTESET,
+ R.string.account_routeset_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_PASSWORD,
+ R.string.account_password_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_REALM,
+ R.string.account_realm_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_DEFAULT_REALM,
+ R.string.account_useragent_label));
+ basicDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_USERAGENT,
+ R.string.account_autoanswer_label));
+
+ return basicDetailKeys;
+ }
+
+ public static ArrayList<PreferenceEntry> getAdvancedDetailsKeys()
+ {
+ ArrayList<PreferenceEntry> advancedDetailKeys = new ArrayList<PreferenceEntry>();
+
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_EXPIRE,
+ R.string.account_registration_exp_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATUS,
+ R.string.account_registration_status_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE,
+ R.string.account_registration_code_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC,
+ R.string.account_registration_state_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_CREDENTIAL_NUMBER,
+ R.string.account_credential_count_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_DTMF_TYPE,
+ R.string.account_config_dtmf_type_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_RINGTONE_PATH,
+ R.string.account_ringtone_path_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_RINGTONE_ENABLED,
+ R.string.account_ringtone_enabled_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_KEEP_ALIVE_ENABLED,
+ R.string.account_keep_alive_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ACCOUNT_AUTOANSWER,
+ R.string.account_account_interface_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_LOCAL_INTERFACE,
+ R.string.account_local_interface_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_INTERFACE,
+ R.string.account_account_interface_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_PUBLISHED_SAMEAS_LOCAL,
+ R.string.account_published_same_as_local_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_LOCAL_PORT,
+ R.string.account_local_port_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_PUBLISHED_PORT,
+ R.string.account_published_port_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_PUBLISHED_ADDRESS,
+ R.string.account_published_address_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_DISPLAY_NAME,
+ R.string.account_displayname_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_STUN_SERVER,
+ R.string.account_stun_server_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_STUN_ENABLE,
+ R.string.account_stun_enable_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_SRTP_ENABLE,
+ R.string.account_srtp_enabled_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_SRTP_KEY_EXCHANGE,
+ R.string.account_srtp_exchange_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_SRTP_ENCRYPTION_ALGO,
+ R.string.account_encryption_algo_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_SRTP_RTP_FALLBACK,
+ R.string.account_srtp_fallback_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ZRTP_HELLO_HASH,
+ R.string.account_hello_hash_enable_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS,
+ R.string.account_display_sas_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ZRTP_NOT_SUPP_WARNING,
+ R.string.account_not_supported_warning_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS_ONCE,
+ R.string.account_display_sas_once_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_LISTENER_PORT,
+ R.string.account_listener_port_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_ENABLE,
+ R.string.account_tls_enabled_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_CA_LIST_FILE,
+ R.string.account_tls_certificate_list_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_CERTIFICATE_FILE,
+ R.string.account_tls_certificate_file_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_PRIVATE_KEY_FILE,
+ R.string.account_tls_private_key_file_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_PASSWORD,
+ R.string.account_tls_password_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_METHOD,
+ R.string.account_tls_method_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_CIPHERS,
+ R.string.account_tls_ciphers_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_SERVER_NAME,
+ R.string.account_tls_server_name_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_VERIFY_SERVER,
+ R.string.account_tls_verify_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_VERIFY_CLIENT,
+ R.string.account_tls_verify_client_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE,
+ R.string.account_tls_require_client_certificat_label));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC,
+ R.string.account_tls_negotiation_timeout_sec));
+ advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC,
+ R.string.account_tls_negotiation_timeout_msec));
+
+ return advancedDetailKeys;
+ }
+
+ public static StringMap convertFromNativeToSwig(HashMap<String, String> nativemap)
+ {
+ StringMap swigmap = new StringMap();
+
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_ALIAS, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_ALIAS));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_HOSTNAME, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_HOSTNAME));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_USERNAME, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_USERNAME));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_PASSWORD, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_PASSWORD));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_ROUTESET, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_ROUTESET));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_EXPIRE));
+
+ swigmap.set(ServiceConstants.CONFIG_LOCAL_INTERFACE, nativemap.get(ServiceConstants.CONFIG_LOCAL_INTERFACE));
+ swigmap.set(ServiceConstants.CONFIG_STUN_SERVER, nativemap.get(ServiceConstants.CONFIG_STUN_SERVER));
+ swigmap.set(ServiceConstants.CONFIG_TLS_ENABLE, nativemap.get(ServiceConstants.CONFIG_TLS_ENABLE));
+ swigmap.set(ServiceConstants.CONFIG_SRTP_ENABLE, nativemap.get(ServiceConstants.CONFIG_SRTP_ENABLE));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_TYPE, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_TYPE));
+
+ // swigmap.set(ServiceConstants.CONFIG_ACCOUNT_MAILBOX, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_MAILBOX));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_ENABLE, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_ENABLE));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATUS, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATUS));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC));
+
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_AUTOANSWER, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_AUTOANSWER));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_DTMF_TYPE, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_DTMF_TYPE));
+ swigmap.set(ServiceConstants.CONFIG_KEEP_ALIVE_ENABLED, nativemap.get(ServiceConstants.CONFIG_KEEP_ALIVE_ENABLED));
+ swigmap.set(ServiceConstants.CONFIG_LOCAL_PORT, nativemap.get(ServiceConstants.CONFIG_LOCAL_PORT));
+ swigmap.set(ServiceConstants.CONFIG_PUBLISHED_ADDRESS, nativemap.get(ServiceConstants.CONFIG_PUBLISHED_ADDRESS));
+
+ swigmap.set(ServiceConstants.CONFIG_PUBLISHED_PORT, nativemap.get(ServiceConstants.CONFIG_PUBLISHED_PORT));
+ swigmap.set(ServiceConstants.CONFIG_PUBLISHED_SAMEAS_LOCAL, nativemap.get(ServiceConstants.CONFIG_PUBLISHED_SAMEAS_LOCAL));
+ swigmap.set(ServiceConstants.CONFIG_RINGTONE_ENABLED, nativemap.get(ServiceConstants.CONFIG_RINGTONE_ENABLED));
+ swigmap.set(ServiceConstants.CONFIG_RINGTONE_PATH, nativemap.get(ServiceConstants.CONFIG_RINGTONE_PATH));
+ swigmap.set(ServiceConstants.CONFIG_ACCOUNT_USERAGENT, nativemap.get(ServiceConstants.CONFIG_ACCOUNT_USERAGENT));
+
+ swigmap.set(ServiceConstants.CONFIG_SRTP_KEY_EXCHANGE, nativemap.get(ServiceConstants.CONFIG_SRTP_KEY_EXCHANGE));
+ swigmap.set(ServiceConstants.CONFIG_SRTP_RTP_FALLBACK, nativemap.get(ServiceConstants.CONFIG_SRTP_RTP_FALLBACK));
+ swigmap.set(ServiceConstants.CONFIG_STUN_ENABLE, nativemap.get(ServiceConstants.CONFIG_STUN_ENABLE));
+ swigmap.set(ServiceConstants.CONFIG_TLS_CERTIFICATE_FILE, nativemap.get(ServiceConstants.CONFIG_TLS_CERTIFICATE_FILE));
+ swigmap.set(ServiceConstants.CONFIG_TLS_CA_LIST_FILE, nativemap.get(ServiceConstants.CONFIG_TLS_CA_LIST_FILE));
+
+ swigmap.set(ServiceConstants.CONFIG_TLS_CIPHERS, nativemap.get(ServiceConstants.CONFIG_TLS_CIPHERS));
+ swigmap.set(ServiceConstants.CONFIG_TLS_LISTENER_PORT, nativemap.get(ServiceConstants.CONFIG_TLS_LISTENER_PORT));
+ swigmap.set(ServiceConstants.CONFIG_TLS_METHOD, nativemap.get(ServiceConstants.CONFIG_TLS_METHOD));
+ // swigmap.set(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, nativemap.get(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC));
+ // swigmap.set(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, nativemap.get(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC));
+
+ swigmap.set(ServiceConstants.CONFIG_TLS_PASSWORD, nativemap.get(ServiceConstants.CONFIG_TLS_PASSWORD));
+ swigmap.set(ServiceConstants.CONFIG_TLS_PRIVATE_KEY_FILE, nativemap.get(ServiceConstants.CONFIG_TLS_PRIVATE_KEY_FILE));
+ swigmap.set(ServiceConstants.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, nativemap.get(ServiceConstants.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE));
+ swigmap.set(ServiceConstants.CONFIG_TLS_SERVER_NAME, nativemap.get(ServiceConstants.CONFIG_TLS_SERVER_NAME));
+ swigmap.set(ServiceConstants.CONFIG_TLS_VERIFY_CLIENT, nativemap.get(ServiceConstants.CONFIG_TLS_VERIFY_CLIENT));
+
+ swigmap.set(ServiceConstants.CONFIG_TLS_VERIFY_SERVER, nativemap.get(ServiceConstants.CONFIG_TLS_VERIFY_SERVER));
+ swigmap.set(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS, nativemap.get(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS));
+ swigmap.set(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS_ONCE, nativemap.get(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS_ONCE));
+ swigmap.set(ServiceConstants.CONFIG_ZRTP_HELLO_HASH, nativemap.get(ServiceConstants.CONFIG_ZRTP_HELLO_HASH));
+ swigmap.set(ServiceConstants.CONFIG_ZRTP_NOT_SUPP_WARNING, nativemap.get(ServiceConstants.CONFIG_ZRTP_NOT_SUPP_WARNING));
+
+ return swigmap;
+ }
+
+ public static HashMap<String, String> convertSwigToNative(StringMap swigmap) {
+
+ HashMap<String, String> nativemap = new HashMap<String, String>();
+
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ALIAS, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ALIAS));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_HOSTNAME, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_HOSTNAME));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_USERNAME, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_USERNAME));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_PASSWORD, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_USERNAME));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ROUTESET, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ROUTESET));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_EXPIRE));
+
+ nativemap.put(ServiceConstants.CONFIG_LOCAL_INTERFACE, swigmap.get(ServiceConstants.CONFIG_LOCAL_INTERFACE));
+ nativemap.put(ServiceConstants.CONFIG_STUN_SERVER, swigmap.get(ServiceConstants.CONFIG_STUN_SERVER));
+ nativemap.put(ServiceConstants.CONFIG_TLS_ENABLE, swigmap.get(ServiceConstants.CONFIG_TLS_ENABLE));
+ nativemap.put(ServiceConstants.CONFIG_SRTP_ENABLE, swigmap.get(ServiceConstants.CONFIG_SRTP_ENABLE));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_TYPE, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_TYPE));
+
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_MAILBOX, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_MAILBOX));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_ENABLE, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_ENABLE));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATUS, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATUS));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC));
+
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_AUTOANSWER, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_AUTOANSWER));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_DTMF_TYPE, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_DTMF_TYPE));
+ nativemap.put(ServiceConstants.CONFIG_KEEP_ALIVE_ENABLED, swigmap.get(ServiceConstants.CONFIG_KEEP_ALIVE_ENABLED));
+ nativemap.put(ServiceConstants.CONFIG_LOCAL_PORT, swigmap.get(ServiceConstants.CONFIG_LOCAL_PORT));
+ nativemap.put(ServiceConstants.CONFIG_PUBLISHED_ADDRESS, swigmap.get(ServiceConstants.CONFIG_PUBLISHED_ADDRESS));
+
+ nativemap.put(ServiceConstants.CONFIG_PUBLISHED_PORT, swigmap.get(ServiceConstants.CONFIG_PUBLISHED_PORT));
+ nativemap.put(ServiceConstants.CONFIG_PUBLISHED_SAMEAS_LOCAL, swigmap.get(ServiceConstants.CONFIG_PUBLISHED_SAMEAS_LOCAL));
+ nativemap.put(ServiceConstants.CONFIG_RINGTONE_ENABLED, swigmap.get(ServiceConstants.CONFIG_RINGTONE_ENABLED));
+ nativemap.put(ServiceConstants.CONFIG_RINGTONE_PATH, swigmap.get(ServiceConstants.CONFIG_RINGTONE_PATH));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_USERAGENT, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_USERAGENT));
+
+ nativemap.put(ServiceConstants.CONFIG_SRTP_KEY_EXCHANGE, swigmap.get(ServiceConstants.CONFIG_SRTP_KEY_EXCHANGE));
+ nativemap.put(ServiceConstants.CONFIG_SRTP_RTP_FALLBACK, swigmap.get(ServiceConstants.CONFIG_SRTP_RTP_FALLBACK));
+ nativemap.put(ServiceConstants.CONFIG_STUN_ENABLE, swigmap.get(ServiceConstants.CONFIG_STUN_ENABLE));
+ nativemap.put(ServiceConstants.CONFIG_TLS_CERTIFICATE_FILE, swigmap.get(ServiceConstants.CONFIG_TLS_CERTIFICATE_FILE));
+ nativemap.put(ServiceConstants.CONFIG_TLS_CA_LIST_FILE, swigmap.get(ServiceConstants.CONFIG_TLS_CA_LIST_FILE));
+
+ nativemap.put(ServiceConstants.CONFIG_TLS_CIPHERS, swigmap.get(ServiceConstants.CONFIG_TLS_CIPHERS));
+ nativemap.put(ServiceConstants.CONFIG_TLS_LISTENER_PORT, swigmap.get(ServiceConstants.CONFIG_TLS_LISTENER_PORT));
+ nativemap.put(ServiceConstants.CONFIG_TLS_METHOD, swigmap.get(ServiceConstants.CONFIG_TLS_METHOD));
+ nativemap.put(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, swigmap.get(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC));
+ nativemap.put(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, swigmap.get(ServiceConstants.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC));
+
+ nativemap.put(ServiceConstants.CONFIG_TLS_PASSWORD, swigmap.get(ServiceConstants.CONFIG_TLS_PASSWORD));
+ nativemap.put(ServiceConstants.CONFIG_TLS_PRIVATE_KEY_FILE, swigmap.get(ServiceConstants.CONFIG_TLS_PRIVATE_KEY_FILE));
+ nativemap.put(ServiceConstants.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, swigmap.get(ServiceConstants.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE));
+ nativemap.put(ServiceConstants.CONFIG_TLS_SERVER_NAME, swigmap.get(ServiceConstants.CONFIG_TLS_SERVER_NAME));
+ nativemap.put(ServiceConstants.CONFIG_TLS_VERIFY_CLIENT, swigmap.get(ServiceConstants.CONFIG_TLS_VERIFY_CLIENT));
+
+ nativemap.put(ServiceConstants.CONFIG_TLS_VERIFY_SERVER, swigmap.get(ServiceConstants.CONFIG_TLS_VERIFY_SERVER));
+ nativemap.put(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS, swigmap.get(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS));
+ nativemap.put(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS_ONCE, swigmap.get(ServiceConstants.CONFIG_ZRTP_DISPLAY_SAS_ONCE));
+ nativemap.put(ServiceConstants.CONFIG_ZRTP_HELLO_HASH, swigmap.get(ServiceConstants.CONFIG_ZRTP_HELLO_HASH));
+ nativemap.put(ServiceConstants.CONFIG_ZRTP_NOT_SUPP_WARNING, swigmap.get(ServiceConstants.CONFIG_ZRTP_NOT_SUPP_WARNING));
+
+ /*
+ nativemap.put(ServiceConstants.CONFIG_CREDENTIAL_NUMBER, swigmap.get(ServiceConstants.CONFIG_CREDENTIAL_NUMBER));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_PASSWORD, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_PASSWORD));
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_REALM, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_REALM));
+ */
+
+ /*
+ nativemap.put(ServiceConstants.CONFIG_ACCOUNT_DEFAULT_REALM, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_DEFAULT_REALM));
+ nativemap.put(ServiceConstants.CONFIG_INTERFACE, swigmap.get(ServiceConstants.CONFIG_INTERFACE));
+ nativemap.put(ServiceConstants.CONFIG_DEFAULT_INTERFACE, swigmap.get(ServiceConstants.CONFIG_DEFAULT_INTERFACE));
+ nativemap.put(ServiceConstants.CONFIG_DISPLAY_NAME, swigmap.get(ServiceConstants.CONFIG_DISPLAY_NAME));
+ nativemap.put(ServiceConstants.CONFIG_DEFAULT_ADDRESS, swigmap.get(ServiceConstants.CONFIG_DEFAULT_ADDRESS));
+ nativemap.put(ServiceConstants.CONFIG_SRTP_ENCRYPTION_ALGO, swigmap.get(ServiceConstants.CONFIG_SRTP_ENCRYPTION_ALGO));
+ */
+
+ return nativemap;
+ }
+};
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java b/src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java
new file mode 100644
index 0000000..d78db6f
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Additional permission under GNU GPL version 3 section 7:
+ *
+ * If you modify this program, or any covered work, by linking or
+ * combining it with the OpenSSL project's OpenSSL library (or a
+ * modified version of that library), containing parts covered by the
+ * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ * grants you additional permission to convey the resulting work.
+ * Corresponding Source for a non-source form of such a combination
+ * shall include the source code for the parts of OpenSSL used as well
+ * as that of the covered work.
+ */
+
+package com.savoirfairelinux.sflphone.account;
+
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.Context;
+import android.os.RemoteException;
+import android.util.Log;
+
+import java.util.ArrayList;
+
+import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
+import com.savoirfairelinux.sflphone.service.ISipService;
+
+public class AccountListReceiver extends BroadcastReceiver
+{
+ private static final long serialVersionUID = -9178386308804218835L;
+ static final String TAG = "AccountList";
+ private String currentAccountID = "";
+ private ArrayList<String> mList = new ArrayList<String>();
+ private ArrayList<AccountManagementUI> mUserInterfaceList = new ArrayList<AccountManagementUI>();
+ private static ISipService mService = null;
+ // private HashMap<String, AccountPreferenceScreen> mAccountList = new HashMap<String, AccountPreferenceScreen>();
+
+ public static final String DEFAULT_ACCOUNT_ID = "IP2IP";
+
+ public AccountListReceiver() {
+ }
+
+ public void setSipService(ISipService service) {
+ mService = service;
+ mList = getAccountListFromService();
+ }
+
+
+ public void addManagementUI(AccountManagementUI ui) {
+ mUserInterfaceList.add(ui);
+ }
+
+ public void accountSelected(String accountID, AccountManagementUI userInterface) {
+ if(!mUserInterfaceList.isEmpty()) {
+ for(AccountManagementUI ui : mUserInterfaceList) {
+ ui.setSelectedAccount(accountID);
+ }
+ }
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ String signalName = intent.getStringExtra(ConfigurationManagerCallback.SIGNAL_NAME);
+ Log.d(TAG, "Signal received: " + signalName);
+
+ if(signalName.equals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
+ processAccountsChangedSignal(intent);
+ } else if(signalName.equals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) {
+ processAccountStateChanged(intent);
+ }
+ }
+
+ private ArrayList<String> getAccountListFromService() {
+ ArrayList<String> list = null;
+
+ try {
+ list = (ArrayList<String>)mService.getAccountList();
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "Remote exception", e);
+ }
+
+ list.remove(DEFAULT_ACCOUNT_ID);
+
+ return list;
+ }
+
+
+ private void processAccountsChangedSignal(Intent intent) {
+ ArrayList<String> newList = getAccountListFromService();
+
+ Log.i(TAG, "Process AccountsChanged signal in AccountList");
+
+ newList.remove(DEFAULT_ACCOUNT_ID);
+
+ if(!mUserInterfaceList.isEmpty()) {
+
+ if(newList.size() > mList.size()) {
+ for(AccountManagementUI ui : mUserInterfaceList) {
+ ui.accountAdded(newList);
+ }
+ }
+ }
+
+ mList = newList;
+ }
+
+ private void processAccountStateChanged(Intent intent) {
+ if(!mUserInterfaceList.isEmpty()) {
+ }
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java b/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
new file mode 100644
index 0000000..6401d5b
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Additional permission under GNU GPL version 3 section 7:
+ *
+ * If you modify this program, or any covered work, by linking or
+ * combining it with the OpenSSL project's OpenSSL library (or a
+ * modified version of that library), containing parts covered by the
+ * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ * grants you additional permission to convey the resulting work.
+ * Corresponding Source for a non-source form of such a combination
+ * shall include the source code for the parts of OpenSSL used as well
+ * as that of the covered work.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import java.util.ArrayList;
+
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
+
+public interface AccountManagementUI
+{
+ public void setAccountList(AccountListReceiver accountList);
+
+ public void accountSelectedNotifyAccountList(String accountID);
+
+ public void setSelectedAccount(String accountID);
+
+ public void accountAdded(ArrayList<String> newList);
+
+ public void accountRemoved();
+
+ public void accountUpdated();
+}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
new file mode 100644
index 0000000..ef23f35
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Additional permission under GNU GPL version 3 section 7:
+ *
+ * If you modify this program, or any covered work, by linking or
+ * combining it with the OpenSSL project's OpenSSL library (or a
+ * modified version of that library), containing parts covered by the
+ * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ * grants you additional permission to convey the resulting work.
+ * Corresponding Source for a non-source form of such a combination
+ * shall include the source code for the parts of OpenSSL used as well
+ * as that of the covered work.
+ */
+package com.savoirfairelinux.sflphone.account;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+public class AccountSelectionSpinner extends Spinner implements AccountManagementUI {
+ private static final String TAG = "AccountSelectionButton";
+ private Context mContext;
+ private ArrayList<String> mList = new ArrayList<String>();
+ private AccountListReceiver mAccountList = null;
+ ArrayAdapter mListAdapter;
+
+ public AccountSelectionSpinner(Context context) {
+ super(context);
+ mContext = context;
+
+ }
+
+ public AccountSelectionSpinner(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+
+
+ }
+
+ public AccountSelectionSpinner(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mContext = context;
+ mListAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1, mList.toArray());
+
+ setOnItemSelectedListener(onClick);
+ setAdapter(mListAdapter);
+ }
+
+ private AdapterView.OnItemSelectedListener onClick = new AdapterView.OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) {
+ // public void onClick(DialogInterface dialog, int which) {
+
+ Log.i(TAG, "Selected Account: " + ((TextView) view).getText());
+ // mButton.setText(((TextView)view).getText());
+ accountSelectedNotifyAccountList(((TextView) view).getText().toString());
+ // setSelection(cursor.getPosition(),true);
+
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+
+ public void setAccountList(AccountListReceiver accountList) {
+ Log.i(TAG,"setAccountList");
+ mAccountList = accountList;
+
+ }
+
+ public void accountSelectedNotifyAccountList(String accountID) {
+ Log.i(TAG, "->accountSelectedNotifyAccountList");
+ if (mAccountList != null) {
+ mAccountList.accountSelected(accountID, this);
+ }
+ }
+
+ public void setSelectedAccount(String accountID) {
+ Log.i(TAG,"Account Selected");
+ // setText(accountID);
+ }
+
+ public void accountAdded(ArrayList<String> newList) {
+ mListAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1, newList.toArray());
+
+ setOnItemSelectedListener(onClick);
+ setAdapter(mListAdapter);
+ // Log.i(TAG, "Account added");
+ // mList = newList;
+ //
+ // if(newList.size() == 1) {
+ // setText(newList.get(0));
+ // }
+ }
+
+ public void accountRemoved() {
+ Log.i(TAG,"Account Removed");
+ }
+
+ public void accountUpdated() {
+ Log.i(TAG,"Account Updated");
+ }
+}