From 5cfc35d618aa19578821122abaa3bb08657eafe7 Mon Sep 17 00:00:00 2001 From: alision <alexandre.lision@savoirfairelinux.com> Date: Thu, 11 Jul 2013 15:11:39 -0400 Subject: [PATCH] * #27064 New creation process (faster), lightened parameters Refactoring on accounts --- AndroidManifest.xml | 9 + bin/AndroidManifest.xml | 9 + res/layout/activity_sflphone_home.xml | 2 +- res/layout/activity_wizard.xml | 12 + res/layout/frag_account_creation.xml | 64 ++++ res/values/strings_activity_login.xml | 17 + res/values/styles.xml | 6 + res/xml/account_creation_preferences.xml | 16 +- .../account/AccountDetailAdvanced.java | 10 +- .../sflphone/account/AccountDetailBasic.java | 14 +- .../sflphone/account/AccountDetailSrtp.java | 3 +- .../sflphone/account/AccountDetailTls.java | 15 +- .../account/AccountDetailsHandler.java | 309 +++++++++--------- .../adapters/SectionsPagerAdapter.java | 22 -- .../client/AccountPreferenceActivity.java | 80 +---- .../sflphone/client/AccountWizard.java | 190 +++++++++++ .../sflphone/client/SFLPhoneHomeActivity.java | 3 - .../fragments/AccountCreationFragment.java | 221 +++++++++++++ .../fragments/AccountManagementFragment.java | 66 ++-- .../sflphone/fragments/DialingFragment.java | 13 +- .../sflphone/loaders/AccountsLoader.java | 23 +- .../sflphone/model/Account.java | 112 +++---- .../sflphone/service/ServiceConstants.java | 66 ---- .../sflphone/service/SipService.java | 15 +- 24 files changed, 831 insertions(+), 466 deletions(-) create mode 100644 res/layout/activity_wizard.xml create mode 100644 res/layout/frag_account_creation.xml create mode 100644 res/values/strings_activity_login.xml create mode 100644 src/com/savoirfairelinux/sflphone/client/AccountWizard.java create mode 100644 src/com/savoirfairelinux/sflphone/fragments/AccountCreationFragment.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index feb878942..a15ee9743 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -76,6 +76,15 @@ as that of the covered work. android:name="android.support.PARENT_ACTIVITY" android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" /> </activity> + + <activity + android:name="com.savoirfairelinux.sflphone.client.AccountWizard" + android:screenOrientation="portrait" > + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" /> + </activity> + <activity android:name="com.savoirfairelinux.sflphone.client.AccountPreferenceActivity" android:label="@string/app_name" diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml index feb878942..a15ee9743 100644 --- a/bin/AndroidManifest.xml +++ b/bin/AndroidManifest.xml @@ -76,6 +76,15 @@ as that of the covered work. android:name="android.support.PARENT_ACTIVITY" android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" /> </activity> + + <activity + android:name="com.savoirfairelinux.sflphone.client.AccountWizard" + android:screenOrientation="portrait" > + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" /> + </activity> + <activity android:name="com.savoirfairelinux.sflphone.client.AccountPreferenceActivity" android:label="@string/app_name" diff --git a/res/layout/activity_sflphone_home.xml b/res/layout/activity_sflphone_home.xml index 263a65bd3..cabd173d0 100644 --- a/res/layout/activity_sflphone_home.xml +++ b/res/layout/activity_sflphone_home.xml @@ -68,7 +68,7 @@ as that of the covered work. <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" - android:background="#000000" + android:background="#FFFFFF" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> diff --git a/res/layout/activity_wizard.xml b/res/layout/activity_wizard.xml new file mode 100644 index 000000000..c0d71edbd --- /dev/null +++ b/res/layout/activity_wizard.xml @@ -0,0 +1,12 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <android.support.v4.view.ViewPager + android:id="@+id/pager" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="#000000" /> + +</RelativeLayout> \ No newline at end of file diff --git a/res/layout/frag_account_creation.xml b/res/layout/frag_account_creation.xml new file mode 100644 index 000000000..48dbe0c82 --- /dev/null +++ b/res/layout/frag_account_creation.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/login_form" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/light" > + + <LinearLayout + style="@style/LoginFormContainer" + android:orientation="vertical" > + + <EditText + android:id="@+id/alias" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_alias" + android:inputType="textEmailAddress" + android:maxLines="1" + android:singleLine="true" > + + <requestFocus /> + </EditText> + + <EditText + android:id="@+id/hostname" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_hostname" + android:maxLines="1" + android:singleLine="true" > + </EditText> + + <EditText + android:id="@+id/username" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_username" + android:maxLines="1" + android:singleLine="true" /> + + <EditText + android:id="@+id/password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_password" + android:imeActionId="@+id/login" + android:imeActionLabel="@string/action_create_short" + android:imeOptions="actionUnspecified" + android:inputType="textPassword" + android:maxLines="1" + android:singleLine="true" /> + + <Button + android:id="@+id/create_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:layout_marginTop="16dp" + android:paddingLeft="32dp" + android:paddingRight="32dp" + android:text="@string/action_create" /> + </LinearLayout> + +</ScrollView> \ No newline at end of file diff --git a/res/values/strings_activity_login.xml b/res/values/strings_activity_login.xml new file mode 100644 index 000000000..c21eab232 --- /dev/null +++ b/res/values/strings_activity_login.xml @@ -0,0 +1,17 @@ +<resources> + + <!-- Strings related to login --> + <string name="prompt_alias">Alias</string> + <string name="prompt_hostname">Hostname</string> + <string name="prompt_username">Username</string> + <string name="prompt_password">Password</string> + <string name="action_create"><b>Create Account</b></string> + <string name="action_create_short">Create</string> + <string name="action_forgot_password">Recover lost password</string> + <string name="login_progress_signing_in">Signing in…</string> + <string name="error_invalid_email">This email address is invalid</string> + <string name="error_invalid_password">This password is too short</string> + <string name="error_incorrect_password">This password is incorrect</string> + <string name="error_field_required">This field is required</string> + +</resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index 4842a6cb2..55345e21b 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -39,4 +39,10 @@ as that of the covered work. <item name="android:dividerHeight">5dp</item> </style> + <style name="LoginFormContainer"> + <item name="android:layout_width">match_parent</item> + <item name="android:layout_height">wrap_content</item> + <item name="android:padding">16dp</item> + </style> + </resources> \ No newline at end of file diff --git a/res/xml/account_creation_preferences.xml b/res/xml/account_creation_preferences.xml index 5424dc463..e6853c040 100644 --- a/res/xml/account_creation_preferences.xml +++ b/res/xml/account_creation_preferences.xml @@ -33,14 +33,14 @@ as that of the covered work. <PreferenceCategory android:id="@+id/account_basic_category" android:title="Basic settings"> - <CheckBoxPreference - android:id="@+id/account_creation_enable" - android:key="Account.enable" - android:persistent="false" - android:defaultValue="true" - android:title="Account enabled" - android:summaryOn="enabled" - android:summaryOff="disabled"/> +<!-- <CheckBoxPreference --> +<!-- android:id="@+id/account_creation_enable" --> +<!-- android:key="Account.enable" --> +<!-- android:persistent="false" --> +<!-- android:defaultValue="true" --> +<!-- android:title="Account enabled" --> +<!-- android:summaryOn="enabled" --> +<!-- android:summaryOff="disabled"/> --> <!-- <EditTextPreference --> <!-- android:id="@+id/account_creation_type" --> <!-- android:key="Account.type" --> diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java index 57d1d265d..892598f62 100644 --- a/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java +++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java @@ -54,10 +54,14 @@ public class AccountDetailAdvanced implements AccountDetail { 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_LOCAL_PORT = "5070"; + public static final String CONFIG_DEFAULT_PUBLISHED_PORT = "5070"; public static final String CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL = "true"; - public static final String CONFIG_DEFAULT_INTERFACE = "default"; + public static final String CONFIG_DEFAULT_INTERFACE = "wlan0"; + public static final String CONFIG_DEFAULT_REGISTRATION_EXPIRE = "60"; public static final String CONFIG_DISPLAY_NAME = "Account.displayName"; public static final String CONFIG_DEFAULT_ADDRESS = "0.0.0.0"; diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java index 3694ec519..4f9137d42 100644 --- a/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java +++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java @@ -23,6 +23,7 @@ package com.savoirfairelinux.sflphone.account; import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.account.AccountDetail; +import com.savoirfairelinux.sflphone.service.ServiceConstants; import android.util.Log; @@ -36,15 +37,22 @@ 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_USERAGENT = "Account.useragent"; + public static final String CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer"; + public static final String CONFIG_ACCOUNT_TYPE = "Account.type"; + public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias"; + public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable"; + + + public static final String CONFIG_ACCOUNT_DEFAULT_TYPE = "SIP"; + public static final String CONFIG_ACCOUNT_DEFAULT_ENABLE = "true"; + public static final String CONFIG_ACCOUNT_DEFAULT_REALM = "*"; + public static final String CONFIG_ACCOUNT_DEFAULT_USERAGENT = "SFLphone"; private ArrayList<AccountDetail.PreferenceEntry> privateArray; diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java index 2585ffa23..a193f8511 100644 --- a/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java +++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java @@ -24,6 +24,7 @@ package com.savoirfairelinux.sflphone.account; import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.account.AccountDetail; import com.savoirfairelinux.sflphone.account.AccountDetail.PreferenceEntry; +import com.savoirfairelinux.sflphone.service.ServiceConstants; import android.util.Log; @@ -36,7 +37,7 @@ 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 diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java index 92864b0b2..079474953 100644 --- a/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java +++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java @@ -21,22 +21,19 @@ */ package com.savoirfairelinux.sflphone.account; -import com.savoirfairelinux.sflphone.R; -import com.savoirfairelinux.sflphone.account.AccountDetail; -import com.savoirfairelinux.sflphone.account.AccountDetail.PreferenceEntry; +import java.util.ArrayList; +import java.util.HashMap; import android.util.Log; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; -import java.util.HashMap; +import com.savoirfairelinux.sflphone.R; +import com.savoirfairelinux.sflphone.service.ServiceConstants; 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"; @@ -51,7 +48,7 @@ public class AccountDetailTls implements AccountDetail { 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() diff --git a/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java index 726fffcd9..fb6c5cc40 100644 --- a/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java +++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java @@ -44,16 +44,16 @@ public class AccountDetailsHandler { 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)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, R.string.account_type_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, R.string.account_alias_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE, R.string.account_enabled_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, R.string.account_hostname_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, R.string.account_username_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET, R.string.account_routeset_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, R.string.account_password_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_REALM, R.string.account_realm_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_REALM, R.string.account_useragent_label)); + basicDetailKeys.add(new PreferenceEntry(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT, R.string.account_autoanswer_label)); return basicDetailKeys; } @@ -61,50 +61,50 @@ public class AccountDetailsHandler { 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(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, R.string.account_registration_exp_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.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)); + .add(new PreferenceEntry(AccountDetailAdvanced.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_autoanswer_label)); - advancedDetailKeys.add(new PreferenceEntry(ServiceConstants.CONFIG_LOCAL_INTERFACE, R.string.account_local_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, + .add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, R.string.account_registration_state_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_CREDENTIAL_NUMBER, R.string.account_credential_count_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE, R.string.account_config_dtmf_type_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_RINGTONE_PATH, R.string.account_ringtone_path_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED, R.string.account_ringtone_enabled_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED, R.string.account_keep_alive_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER, R.string.account_autoanswer_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE, R.string.account_local_interface_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL, R.string.account_published_same_as_local_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_LOCAL_PORT, R.string.account_local_port_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT, R.string.account_published_port_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS, R.string.account_published_address_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_DISPLAY_NAME, R.string.account_displayname_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_STUN_SERVER, R.string.account_stun_server_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailAdvanced.CONFIG_STUN_ENABLE, R.string.account_stun_enable_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_SRTP_ENABLE, R.string.account_srtp_enabled_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, R.string.account_srtp_exchange_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_SRTP_ENCRYPTION_ALGO, R.string.account_encryption_algo_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, R.string.account_srtp_fallback_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH, R.string.account_hello_hash_enable_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS, R.string.account_display_sas_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING, R.string.account_not_supported_warning_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE, R.string.account_display_sas_once_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, R.string.account_listener_port_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_ENABLE, R.string.account_tls_enabled_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE, R.string.account_tls_certificate_list_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE, R.string.account_tls_certificate_file_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE, R.string.account_tls_private_key_file_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_PASSWORD, R.string.account_tls_password_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_METHOD, R.string.account_tls_method_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_CIPHERS, R.string.account_tls_ciphers_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_SERVER_NAME, R.string.account_tls_server_name_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER, R.string.account_tls_verify_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT, R.string.account_tls_verify_client_label)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.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, + .add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, R.string.account_tls_negotiation_timeout_sec)); + advancedDetailKeys.add(new PreferenceEntry(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, R.string.account_tls_negotiation_timeout_msec)); return advancedDetailKeys; @@ -113,61 +113,60 @@ public class AccountDetailsHandler { 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)); - System.out.println(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(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_TYPE)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE)); + swigmap.set(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT, nativemap.get(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT)); + + + swigmap.set(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE)); + swigmap.set(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE, nativemap.get(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE)); + swigmap.set(AccountDetailAdvanced.CONFIG_STUN_SERVER, nativemap.get(AccountDetailAdvanced.CONFIG_STUN_SERVER)); + // 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(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS)); + swigmap.set(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE)); + swigmap.set(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC)); + swigmap.set(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER)); + swigmap.set(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE, nativemap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE)); + swigmap.set(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED, nativemap.get(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED)); + swigmap.set(AccountDetailAdvanced.CONFIG_LOCAL_PORT, nativemap.get(AccountDetailAdvanced.CONFIG_LOCAL_PORT)); + swigmap.set(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS, nativemap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS)); + swigmap.set(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT, nativemap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT)); + swigmap.set(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL, nativemap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL)); + swigmap.set(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED, nativemap.get(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED)); + swigmap.set(AccountDetailAdvanced.CONFIG_RINGTONE_PATH, nativemap.get(AccountDetailAdvanced.CONFIG_RINGTONE_PATH)); + swigmap.set(AccountDetailAdvanced.CONFIG_STUN_ENABLE, nativemap.get(AccountDetailAdvanced.CONFIG_STUN_ENABLE)); + + + swigmap.set(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, nativemap.get(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE)); + swigmap.set(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, nativemap.get(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK)); + swigmap.set(AccountDetailSrtp.CONFIG_SRTP_ENABLE, nativemap.get(AccountDetailSrtp.CONFIG_SRTP_ENABLE)); + swigmap.set(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS, nativemap.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); + swigmap.set(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE, nativemap.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE)); + swigmap.set(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH, nativemap.get(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH)); + swigmap.set(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING, nativemap.get(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING)); + + swigmap.set(AccountDetailTls.CONFIG_TLS_CIPHERS, nativemap.get(AccountDetailTls.CONFIG_TLS_CIPHERS)); + swigmap.set(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, nativemap.get(AccountDetailTls.CONFIG_TLS_LISTENER_PORT)); + swigmap.set(AccountDetailTls.CONFIG_TLS_METHOD, nativemap.get(AccountDetailTls.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)); + swigmap.set(AccountDetailTls.CONFIG_TLS_ENABLE, nativemap.get(AccountDetailTls.CONFIG_TLS_ENABLE)); + swigmap.set(AccountDetailTls.CONFIG_TLS_PASSWORD, nativemap.get(AccountDetailTls.CONFIG_TLS_PASSWORD)); + swigmap.set(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE, nativemap.get(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE)); + swigmap.set(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, nativemap.get(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE)); + swigmap.set(AccountDetailTls.CONFIG_TLS_SERVER_NAME, nativemap.get(AccountDetailTls.CONFIG_TLS_SERVER_NAME)); + swigmap.set(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT, nativemap.get(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT)); + swigmap.set(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE, nativemap.get(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE)); + swigmap.set(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE, nativemap.get(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE)); + swigmap.set(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER, nativemap.get(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER)); + return swigmap; } @@ -176,61 +175,57 @@ public class AccountDetailsHandler { 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_PASSWORD)); - 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(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_TYPE)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE)); + nativemap.put(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT, swigmap.get(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT)); + + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE)); + nativemap.put(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE, swigmap.get(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE)); + nativemap.put(AccountDetailAdvanced.CONFIG_STUN_SERVER, swigmap.get(AccountDetailAdvanced.CONFIG_STUN_SERVER)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_MAILBOX, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_MAILBOX)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER)); + nativemap.put(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE, swigmap.get(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE)); + nativemap.put(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED, swigmap.get(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED)); + nativemap.put(AccountDetailAdvanced.CONFIG_LOCAL_PORT, swigmap.get(AccountDetailAdvanced.CONFIG_LOCAL_PORT)); + nativemap.put(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS, swigmap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS)); + nativemap.put(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT, swigmap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT)); + nativemap.put(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL, swigmap.get(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL)); + nativemap.put(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED, swigmap.get(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED)); + nativemap.put(AccountDetailAdvanced.CONFIG_RINGTONE_PATH, swigmap.get(AccountDetailAdvanced.CONFIG_RINGTONE_PATH)); + nativemap.put(AccountDetailAdvanced.CONFIG_STUN_ENABLE, swigmap.get(AccountDetailAdvanced.CONFIG_STUN_ENABLE)); + + + nativemap.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, swigmap.get(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE)); + nativemap.put(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, swigmap.get(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK)); + nativemap.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS, swigmap.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); + nativemap.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE, swigmap.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE)); + nativemap.put(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH, swigmap.get(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH)); + nativemap.put(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING, swigmap.get(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING)); + nativemap.put(AccountDetailSrtp.CONFIG_SRTP_ENABLE, swigmap.get(AccountDetailSrtp.CONFIG_SRTP_ENABLE)); + + nativemap.put(AccountDetailTls.CONFIG_TLS_CIPHERS, swigmap.get(AccountDetailTls.CONFIG_TLS_CIPHERS)); + nativemap.put(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, swigmap.get(AccountDetailTls.CONFIG_TLS_LISTENER_PORT)); + nativemap.put(AccountDetailTls.CONFIG_TLS_METHOD, swigmap.get(AccountDetailTls.CONFIG_TLS_METHOD)); + nativemap.put(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, swigmap.get(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC)); + nativemap.put(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, swigmap.get(AccountDetailTls.CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC)); + nativemap.put(AccountDetailTls.CONFIG_TLS_PASSWORD, swigmap.get(AccountDetailTls.CONFIG_TLS_PASSWORD)); + nativemap.put(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE, swigmap.get(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE)); + nativemap.put(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, swigmap.get(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE)); + nativemap.put(AccountDetailTls.CONFIG_TLS_SERVER_NAME, swigmap.get(AccountDetailTls.CONFIG_TLS_SERVER_NAME)); + nativemap.put(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT, swigmap.get(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT)); + nativemap.put(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER, swigmap.get(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER)); + nativemap.put(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE, swigmap.get(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE)); + nativemap.put(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE, swigmap.get(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE)); + nativemap.put(AccountDetailTls.CONFIG_TLS_ENABLE, swigmap.get(AccountDetailTls.CONFIG_TLS_ENABLE)); + /* * nativemap.put(ServiceConstants.CONFIG_CREDENTIAL_NUMBER, swigmap.get(ServiceConstants.CONFIG_CREDENTIAL_NUMBER)); * nativemap.put(ServiceConstants.CONFIG_ACCOUNT_PASSWORD, swigmap.get(ServiceConstants.CONFIG_ACCOUNT_PASSWORD)); diff --git a/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java index 9dfeca77e..154dc6127 100644 --- a/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java +++ b/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java @@ -36,28 +36,6 @@ public class SectionsPagerAdapter extends FragmentStatePagerAdapter { return fragments.get(i); } -// public Fragment getFragment(int i) { -// Fragment fragment; -// -// switch (i) { -// case 0: -// fragment = new DialingFragment(); -// break; -// case 1: -// fragment = new CallElementListFragment(); -// break; -// case 2: -// fragment = new HistoryFragment(); -// break; -// default: -// Log.e(TAG, "getClassName: unknown fragment position " + i); -// fragment = null; -// } - - // Log.w(TAG, "getFragment: fragment=" + fragment); -// return fragment; -// } - public String getClassName(int i) { String name; diff --git a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java index f3cf3f49d..9970015fc 100644 --- a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java +++ b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java @@ -62,19 +62,14 @@ import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced; import com.savoirfairelinux.sflphone.account.AccountDetailBasic; import com.savoirfairelinux.sflphone.account.AccountDetailSrtp; import com.savoirfairelinux.sflphone.account.AccountDetailTls; +import com.savoirfairelinux.sflphone.service.ServiceConstants; public class AccountPreferenceActivity extends PreferenceActivity { private static final String TAG = "AccoutPreferenceActivity"; public static final String KEY_MODE = "mode"; - public interface mode { - static final int CREATION_MODE = 0; - static final int EDITION_MODE = 1; - } - public interface result { - static final int ACCOUNT_CREATED = Activity.RESULT_FIRST_USER + 0; static final int ACCOUNT_MODIFIED = Activity.RESULT_FIRST_USER + 1; static final int ACCOUNT_DELETED = Activity.RESULT_FIRST_USER + 2; } @@ -93,18 +88,7 @@ public class AccountPreferenceActivity extends PreferenceActivity { addPreferencesFromResource(R.xml.account_creation_preferences); mPreferenceManager = getPreferenceManager(); - Bundle b = getIntent().getExtras(); - - switch (b.getInt(KEY_MODE)) { - case mode.CREATION_MODE: - Log.i(TAG, "CREATION"); - initCreation(); - break; - case mode.EDITION_MODE: - Log.i(TAG, "EDITION"); - initEdition(); - break; - } + initEdition(); getActionBar().setDisplayHomeAsUpEnabled(true); @@ -116,19 +100,6 @@ public class AccountPreferenceActivity extends PreferenceActivity { } - private void initCreation() { - basicDetails = new AccountDetailBasic(); - advancedDetails = new AccountDetailAdvanced(); - srtpDetails = new AccountDetailSrtp(); - tlsDetails = new AccountDetailTls(); - - addPreferenceListener(basicDetails, changeBasicPreferenceListener); - // addPreferenceListener(advancedDetails, changeAdvancedPreferenceListener); - // addPreferenceListener(srtpDetails, changeSrtpPreferenceListener); - // addPreferenceListener(tlsDetails, changeTlsPreferenceListener); - - } - private void initEdition() { Bundle b = getIntent().getExtras(); @@ -158,38 +129,18 @@ public class AccountPreferenceActivity extends PreferenceActivity { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); - Bundle b = getIntent().getExtras(); - - switch (b.getInt(KEY_MODE)) { - case mode.CREATION_MODE: - Log.i(TAG, "CREATION"); - inflater.inflate(R.menu.account_creation, menu); - break; - case mode.EDITION_MODE: - Log.i(TAG, "onCreateOptionsMenu: " + mAccountID); - - if (mAccountID.equals("IP2IP")) - return true; + Log.i(TAG, "onCreateOptionsMenu: " + mAccountID); - inflater.inflate(R.menu.account_edition, menu); - break; - } + inflater.inflate(R.menu.account_edition, menu); return true; } @Override public void onBackPressed() { - Bundle b = getIntent().getExtras(); - switch (b.getInt(KEY_MODE)) { - case mode.CREATION_MODE: - Log.i(TAG, "CREATION"); - AlertDialog dialog = createCancelDialog(); - dialog.show(); - break; - case mode.EDITION_MODE: - finish(); - } + + AlertDialog dialog = createCancelDialog(); + dialog.show(); } @@ -204,10 +155,6 @@ public class AccountPreferenceActivity extends PreferenceActivity { AlertDialog dialog = createDeleteDialog(); dialog.show(); break; - case R.id.menuitem_create: - Toast.makeText(this, "ACCOUNT_CREATED", Toast.LENGTH_LONG).show(); - processAccount(result.ACCOUNT_CREATED); - break; case R.id.menuitem_edit: processAccount(result.ACCOUNT_MODIFIED); break; @@ -230,9 +177,8 @@ public class AccountPreferenceActivity extends PreferenceActivity { updateAccountDetails(accountDetails, advancedDetails); updateAccountDetails(accountDetails, srtpDetails); updateAccountDetails(accountDetails, tlsDetails); - + accountDetails.put("Account.type", "SIP"); - Toast.makeText(this, "updateAccountDetails", Toast.LENGTH_LONG).show(); bundle.putSerializable(AccountDetail.TAG, accountDetails); Intent resultIntent = new Intent(); resultIntent.putExtras(bundle); @@ -269,11 +215,11 @@ public class AccountPreferenceActivity extends PreferenceActivity { if (p.isTwoState) { accountDetails.put(p.mKey, det.getDetailString(p.mKey)); } else { -// if (p.mKey == AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE) { -// accountDetails.put(p.mKey, det.getDetailString(p.mKey)); -// } else { - accountDetails.put(p.mKey, det.getDetailString(p.mKey)); -// } + // if (p.mKey == AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE) { + // accountDetails.put(p.mKey, det.getDetailString(p.mKey)); + // } else { + accountDetails.put(p.mKey, det.getDetailString(p.mKey)); + // } } // Preference pref = mPreferenceManager.findPreference(p.mKey); diff --git a/src/com/savoirfairelinux/sflphone/client/AccountWizard.java b/src/com/savoirfairelinux/sflphone/client/AccountWizard.java new file mode 100644 index 000000000..6218ab98e --- /dev/null +++ b/src/com/savoirfairelinux/sflphone/client/AccountWizard.java @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. + * + * Author: Alexandre Lision <alexandre.lision@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.client; + +import java.util.ArrayList; + +import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.IBinder; +import android.support.v13.app.FragmentStatePagerAdapter; +import android.support.v4.view.ViewPager; +import android.util.Log; +import android.view.MenuItem; + +import com.savoirfairelinux.sflphone.R; +import com.savoirfairelinux.sflphone.fragments.AccountCreationFragment; +import com.savoirfairelinux.sflphone.interfaces.AccountsInterface; +import com.savoirfairelinux.sflphone.service.ISipService; +import com.savoirfairelinux.sflphone.service.SipService; + +public class AccountWizard extends Activity implements AccountsInterface { + static final String TAG = "AccountWizard"; + + public static final int ACCOUNT_CREATED = Activity.RESULT_OK; + + ViewPager mViewPager; + private ISipService service; + private SectionsPagerAdapter mSectionsPagerAdapter; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_wizard); + mViewPager = (ViewPager) findViewById(R.id.pager); + + getActionBar().setDisplayHomeAsUpEnabled(true); + getActionBar().setHomeButtonEnabled(true); + + Intent intent = new Intent(this, SipService.class); + bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + + } + + /* activity finishes itself or is being killed by the system */ + @Override + protected void onDestroy() { + /* stop the service, if no other bound user, no need to check if it is running */ + + unbindService(mConnection); + + super.onDestroy(); + } + + /** Defines callbacks for service binding, passed to bindService() */ + private ServiceConnection mConnection = new ServiceConnection() { + + @Override + public void onServiceConnected(ComponentName className, IBinder binder) { + service = ISipService.Stub.asInterface(binder); + + mSectionsPagerAdapter = new SectionsPagerAdapter(AccountWizard.this, getFragmentManager()); + mViewPager.setAdapter(mSectionsPagerAdapter); + + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + + } + }; + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return true; + } + } + + @Override + public void accountsChanged() { + // TODO Auto-generated method stub + + } + + @Override + public void accountStateChanged(Intent accountState) { + // TODO Auto-generated method stub + + } + + public class SectionsPagerAdapter extends FragmentStatePagerAdapter { + + Context mContext; + final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history }; + ArrayList<Fragment> fragments; + + public SectionsPagerAdapter(Context c, FragmentManager fm) { + super(fm); + mContext = c; + fragments = new ArrayList<Fragment>(); + fragments.add(new AccountCreationFragment()); + + } + + @Override + public Fragment getItem(int i) { + + return fragments.get(i); + } + + public String getClassName(int i) { + String name; + + switch (i) { + case 0: + name = AccountCreationFragment.class.getName(); + break; + + default: + Log.e(TAG, "getClassName: unknown fragment position " + i); + return null; + } + + // Log.w(TAG, "getClassName: name=" + name); + return name; + } + + @Override + public int getCount() { + return 1; + } + + public int getIconOf(int pos) { + return icon_res_id[pos]; + } + + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case 0: + return mContext.getString(R.string.title_section0).toUpperCase(); + default: + Log.e(TAG, "getPageTitle: unknown tab position " + position); + break; + } + return null; + } + } + +} diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java index cac929641..903873948 100644 --- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java +++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java @@ -100,9 +100,6 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca private CharSequence mDrawerTitle; private CharSequence mTitle; - // AccountSelectionAdapter mAdapter; - // private Spinner spinnerAccounts; - public static final int REQUEST_CODE_PREFERENCES = 1; private static final int REQUEST_CODE_CALL = 2; diff --git a/src/com/savoirfairelinux/sflphone/fragments/AccountCreationFragment.java b/src/com/savoirfairelinux/sflphone/fragments/AccountCreationFragment.java new file mode 100644 index 000000000..69ec50cd8 --- /dev/null +++ b/src/com/savoirfairelinux/sflphone/fragments/AccountCreationFragment.java @@ -0,0 +1,221 @@ +package com.savoirfairelinux.sflphone.fragments; + +import java.util.HashMap; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.Fragment; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.savoirfairelinux.sflphone.R; +import com.savoirfairelinux.sflphone.account.AccountDetail; +import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced; +import com.savoirfairelinux.sflphone.account.AccountDetailBasic; +import com.savoirfairelinux.sflphone.account.AccountDetailSrtp; +import com.savoirfairelinux.sflphone.account.AccountDetailTls; + +public class AccountCreationFragment extends Fragment { + + // Values for email and password at the time of the login attempt. + private String mAlias; + private String mHostname; + private String mUsername; + private String mPassword; + + // UI references. + private EditText mAliasView; + private EditText mHostnameView; + private EditText mUsernameView; + private EditText mPasswordView; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // mAdapter = new HistoryAdapter(getActivity(),new ArrayList<HashMap<String, String>>()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { + View inflatedView = inflater.inflate(R.layout.frag_account_creation, parent, false); + + mAliasView = (EditText) inflatedView.findViewById(R.id.alias); + mHostnameView = (EditText) inflatedView.findViewById(R.id.hostname); + mUsernameView = (EditText) inflatedView.findViewById(R.id.username); + mPasswordView = (EditText) inflatedView.findViewById(R.id.password); + inflatedView.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + attemptCreation(); + } + }); + + return inflatedView; + } + + @Override + public void onResume() { + super.onResume(); + } + + @Override + public void onStart() { + super.onStart(); + + } + + /** + * Attempts to sign in or register the account specified by the login form. If there are form errors (invalid email, missing fields, etc.), the + * errors are presented and no actual login attempt is made. + */ + public void attemptCreation() { + + // Reset errors. + mAliasView.setError(null); + mPasswordView.setError(null); + + // Store values at the time of the login attempt. + mAlias = mAliasView.getText().toString(); + mHostname = mHostnameView.getText().toString(); + mUsername = mUsernameView.getText().toString(); + mPassword = mPasswordView.getText().toString(); + + boolean cancel = false; + View focusView = null; + + // Check for a valid password. + if (TextUtils.isEmpty(mPassword)) { + mPasswordView.setError(getString(R.string.error_field_required)); + focusView = mPasswordView; + cancel = true; + } + + if (TextUtils.isEmpty(mUsername)) { + mUsernameView.setError(getString(R.string.error_field_required)); + focusView = mUsernameView; + cancel = true; + } + + if (TextUtils.isEmpty(mHostname)) { + mHostnameView.setError(getString(R.string.error_field_required)); + focusView = mHostnameView; + cancel = true; + } + + // Check for a valid email address. + if (TextUtils.isEmpty(mAlias)) { + mAliasView.setError(getString(R.string.error_field_required)); + focusView = mAliasView; + cancel = true; + } + + if (cancel) { + // There was an error; don't attempt login and focus the first + // form field with an error. + focusView.requestFocus(); + } else { + // Show a progress spinner, and kick off a background task to + // perform the user login attempt. + initCreation(); + + } + } + + private void initCreation() { + + HashMap<String, String> accountDetails = new HashMap<String, String>(); + + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_TYPE); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, mAlias); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, mHostname); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, mUsername); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, mPassword); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET, ""); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_REALM, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_REALM); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_ENABLE); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, mPassword); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_USERAGENT); + + accountDetails.put(AccountDetailAdvanced.CONFIG_LOCAL_PORT, AccountDetailAdvanced.CONFIG_DEFAULT_LOCAL_PORT); + accountDetails.put(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE, AccountDetailAdvanced.CONFIG_DEFAULT_INTERFACE); + accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT, AccountDetailAdvanced.CONFIG_DEFAULT_PUBLISHED_PORT); + accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS, AccountDetailAdvanced.CONFIG_DEFAULT_ADDRESS); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, AccountDetailAdvanced.CONFIG_DEFAULT_REGISTRATION_EXPIRE); + accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_SERVER, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_SERVER, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL, AccountDetailAdvanced.CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL); + accountDetails.put(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED, "false"); + accountDetails.put(AccountDetailAdvanced.CONFIG_RINGTONE_PATH, ""); + accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_ENABLE, "false"); + + accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_ENABLE, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH, ""); + accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING, ""); + + accountDetails.put(AccountDetailTls.CONFIG_TLS_CIPHERS, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_METHOD, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_ENABLE, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_PASSWORD, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE, ""); + + accountDetails.put(AccountDetailTls.CONFIG_TLS_SERVER_NAME, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, "false"); + accountDetails.put(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE, ""); + accountDetails.put(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER, ""); + + Bundle bundle = new Bundle(); + bundle.putSerializable(AccountDetail.TAG, accountDetails); + Intent resultIntent = new Intent(); + resultIntent.putExtras(bundle); + + getActivity().setResult(Activity.RESULT_OK, resultIntent); + getActivity().finish(); + + } + + private AlertDialog createCancelDialog() { + Activity ownerActivity = getActivity(); + AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity); + builder.setMessage("All parameters will be lost").setTitle("Account Creation").setPositiveButton("Ok", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + Activity activity = ((Dialog) dialog).getOwnerActivity(); + activity.finish(); + } + }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + /* Terminate with no action */ + } + }); + + AlertDialog alertDialog = builder.create(); + alertDialog.setOwnerActivity(ownerActivity); + + return alertDialog; + } + +} diff --git a/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java b/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java index 43c71917d..6ad55be04 100644 --- a/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java +++ b/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java @@ -1,7 +1,8 @@ /* - * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. + * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. * * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * Alexandre Lision <alexandre.lision@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 @@ -41,7 +42,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; -import android.os.Environment; import android.os.RemoteException; import android.preference.Preference; import android.preference.PreferenceCategory; @@ -49,6 +49,7 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; +import android.widget.Toast; import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.account.AccountDetail; @@ -57,8 +58,10 @@ import com.savoirfairelinux.sflphone.account.AccountDetailBasic; import com.savoirfairelinux.sflphone.account.AccountDetailSrtp; import com.savoirfairelinux.sflphone.account.AccountDetailTls; import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity; +import com.savoirfairelinux.sflphone.client.AccountWizard; import com.savoirfairelinux.sflphone.client.SFLPhonePreferenceActivity; import com.savoirfairelinux.sflphone.client.SFLphoneApplication; +import com.savoirfairelinux.sflphone.model.Account; import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback; import com.savoirfairelinux.sflphone.service.ISipService; import com.savoirfairelinux.sflphone.service.ServiceConstants; @@ -71,10 +74,10 @@ public class AccountManagementFragment extends PreferenceFragment { private SFLPhonePreferenceActivity sflphonePreferenceActivity; private ISipService service = null; - ArrayList<AccountDetail.PreferenceEntry> basicDetailKeys = null; -// ArrayList<AccountDetail.PreferenceEntry> advancedDetailKeys = null; -// ArrayList<AccountDetail.PreferenceEntry> srtpDetailKeys = null; -// ArrayList<AccountDetail.PreferenceEntry> tlsDetailKeys = null; + // ArrayList<AccountDetail.PreferenceEntry> basicDetailKeys = null; + // ArrayList<AccountDetail.PreferenceEntry> advancedDetailKeys = null; + // ArrayList<AccountDetail.PreferenceEntry> srtpDetailKeys = null; + // ArrayList<AccountDetail.PreferenceEntry> tlsDetailKeys = null; HashMap<String, Preference> accountPreferenceHashMap = null; PreferenceScreen mRoot = null; @@ -87,10 +90,10 @@ public class AccountManagementFragment extends PreferenceFragment { } public AccountManagementFragment() { - basicDetailKeys = AccountDetailBasic.getPreferenceEntries(); -// advancedDetailKeys = AccountDetailAdvanced.getPreferenceEntries(); -// srtpDetailKeys = AccountDetailSrtp.getPreferenceEntries(); -// tlsDetailKeys = AccountDetailTls.getPreferenceEntries(); + // basicDetailKeys = AccountDetailBasic.getPreferenceEntries(); + // advancedDetailKeys = AccountDetailAdvanced.getPreferenceEntries(); + // srtpDetailKeys = AccountDetailSrtp.getPreferenceEntries(); + // tlsDetailKeys = AccountDetailTls.getPreferenceEntries(); accountPreferenceHashMap = new HashMap<String, Preference>(); } @@ -111,7 +114,6 @@ public class AccountManagementFragment extends PreferenceFragment { Log.e(TAG, "onCreate() service=" + service); } } - Log.w(TAG, "onCreate() service=" + service); setPreferenceScreen(getAccountListPreferenceScreen()); @@ -136,11 +138,15 @@ public class AccountManagementFragment extends PreferenceFragment { public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ACCOUNT_CREATE_REQUEST: - if (resultCode == AccountPreferenceActivity.result.ACCOUNT_CREATED) { + if (resultCode == AccountWizard.ACCOUNT_CREATED) { Bundle bundle = data.getExtras(); Log.i(TAG, "Create account settings"); HashMap<String, String> accountDetails = new HashMap<String, String>(); accountDetails = (HashMap<String, String>) bundle.getSerializable(AccountDetail.TAG); +// if(accountDetails == null){ +// Toast.makeText(getActivity(), "NUUUUL", Toast.LENGTH_SHORT).show(); +// } else +// Toast.makeText(getActivity(), "OKKKK", Toast.LENGTH_SHORT).show(); createNewAccount(accountDetails); } break; @@ -152,7 +158,7 @@ public class AccountManagementFragment extends PreferenceFragment { HashMap<String, String> accountDetails = new HashMap<String, String>(); accountDetails = (HashMap<String, String>) bundle.getSerializable(AccountDetail.TAG); - + Preference accountScreen = accountPreferenceHashMap.get(accountID); mRoot.removePreference(accountScreen); accountPreferenceHashMap.remove(accountID); @@ -247,28 +253,23 @@ public class AccountManagementFragment extends PreferenceFragment { private void launchAccountCreationActivity(Preference preference) { Log.i(TAG, "Launch account creation activity"); Intent intent = preference.getIntent(); - intent.putExtra(AccountPreferenceActivity.KEY_MODE, AccountPreferenceActivity.mode.CREATION_MODE); startActivityForResult(intent, ACCOUNT_CREATE_REQUEST); } private void launchAccountEditActivity(Preference preference) { Log.i(TAG, "Launch account edit activity"); Intent intent = preference.getIntent(); - intent.putExtra(AccountPreferenceActivity.KEY_MODE, AccountPreferenceActivity.mode.EDITION_MODE); Bundle bundle = intent.getExtras(); String accountID = bundle.getString("AccountID"); HashMap<String, String> preferenceMap = getAccountDetails(accountID); - AccountDetailBasic basicDetails = new AccountDetailBasic(preferenceMap); - AccountDetailAdvanced advancedDetails = new AccountDetailAdvanced(preferenceMap); - AccountDetailSrtp srtpDetails = new AccountDetailSrtp(preferenceMap); - AccountDetailTls tlsDetails = new AccountDetailTls(preferenceMap); + Account d = new Account(accountID, preferenceMap); - bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, basicDetails.getValuesOnly()); - bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, advancedDetails.getValuesOnly()); - bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, srtpDetails.getValuesOnly()); - bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, tlsDetails.getValuesOnly()); + bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, d.getBasicDetails().getValuesOnly()); + bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, d.getAdvancedDetails().getValuesOnly()); + bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, d.getSrtpDetails().getValuesOnly()); + bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, d.getTlsDetails().getValuesOnly()); intent.putExtras(bundle); @@ -293,13 +294,6 @@ public class AccountManagementFragment extends PreferenceFragment { HashMap<String, String> accountDetails = null; try { accountDetails = (HashMap<String, String>) service.getAccountDetails(accountID); -// ArrayList<Integer> tmp = (ArrayList<Integer>) service.getAudioCodecList(accountID); -// for(Integer i : tmp){ -// Log.w(TAG,"Codec : "+i); -// } - -// if (accountDetails.containsKey("TLS.negotiationTimeoutSec")) -// Log.i(TAG, "localinterface existe"); } catch (RemoteException e) { Log.e(TAG, "Cannot call service method", e); } @@ -313,11 +307,11 @@ public class AccountManagementFragment extends PreferenceFragment { mRoot = getPreferenceManager().createPreferenceScreen(currentContext); // Default account category - PreferenceCategory defaultAccountCat = new PreferenceCategory(currentContext); - defaultAccountCat.setTitle(R.string.default_account_category); - mRoot.addPreference(defaultAccountCat); - - mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID)); + // PreferenceCategory defaultAccountCat = new PreferenceCategory(currentContext); + // defaultAccountCat.setTitle(R.string.default_account_category); + // mRoot.addPreference(defaultAccountCat); + // + // mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID)); // Account list category PreferenceCategory accountListCat = new PreferenceCategory(currentContext); @@ -327,7 +321,7 @@ public class AccountManagementFragment extends PreferenceFragment { Preference createNewAccount = new Preference(currentContext); createNewAccount.setTitle("Create New Account"); createNewAccount.setOnPreferenceClickListener(launchAccountCreationOnClick); - createNewAccount.setIntent(new Intent().setClass(getActivity(), AccountPreferenceActivity.class)); + createNewAccount.setIntent(new Intent().setClass(getActivity(), AccountWizard.class)); mRoot.addPreference(createNewAccount); ArrayList<String> accountList = getAccountList(); diff --git a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java index dedf36f9f..b96b92966 100644 --- a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java +++ b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java @@ -31,9 +31,12 @@ package com.savoirfairelinux.sflphone.fragments; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.app.Activity; import android.app.Fragment; import android.content.Context; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -54,15 +57,12 @@ public class DialingFragment extends Fragment { private static final String TAG = DialingFragment.class.getSimpleName(); public static final String ARG_SECTION_NUMBER = "section_number"; - ClearableEditText textField; // private AccountSelectionSpinner mAccountSelectionSpinner; -// AccountSelectionAdapter mAdapter; + // AccountSelectionAdapter mAdapter; private Callbacks mCallbacks = sDummyCallbacks; -// private Spinner spinnerAccounts; - - + // private Spinner spinnerAccounts; /** * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity. @@ -118,8 +118,6 @@ public class DialingFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View inflatedView = inflater.inflate(R.layout.frag_dialing, parent, false); - - textField = (ClearableEditText) inflatedView.findViewById(R.id.textField); ((ImageButton) inflatedView.findViewById(R.id.buttonCall)).setOnClickListener(new OnClickListener() { @Override @@ -157,6 +155,7 @@ public class DialingFragment extends Fragment { return inflatedView; } + @Override public void onResume() { super.onResume(); diff --git a/src/com/savoirfairelinux/sflphone/loaders/AccountsLoader.java b/src/com/savoirfairelinux/sflphone/loaders/AccountsLoader.java index be1448880..375a039b8 100644 --- a/src/com/savoirfairelinux/sflphone/loaders/AccountsLoader.java +++ b/src/com/savoirfairelinux/sflphone/loaders/AccountsLoader.java @@ -8,8 +8,6 @@ import android.content.Context; import android.os.RemoteException; import android.util.Log; -import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced; -import com.savoirfairelinux.sflphone.account.AccountDetailBasic; import com.savoirfairelinux.sflphone.model.Account; import com.savoirfairelinux.sflphone.service.ISipService; @@ -26,36 +24,25 @@ public class AccountsLoader extends AsyncTaskLoader<ArrayList<Account>> { @Override public ArrayList<Account> loadInBackground() { - - + ArrayList<Account> result = new ArrayList<Account>(); - Account.AccountBuilder builder = Account.AccountBuilder.getInstance(); ArrayList<String> accountIDs; HashMap<String, String> details; try { accountIDs = (ArrayList<String>) service.getAccountList(); for (String id : accountIDs) { - - if(id.contentEquals("IP2IP")){ + + if (id.contentEquals("IP2IP")) { continue; } details = (HashMap<String, String>) service.getAccountDetails(id); - - builder.setAccountID(id).setAlias(details.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS)) - .setHost(details.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME)) - .setRegisteredState(details.get(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS)); - - try { - result.add(builder.build()); - } catch (Exception e) { - Log.e(TAG, e.toString()); - } + result.add(new Account(id, details)); } } catch (RemoteException e) { Log.e(TAG, e.toString()); - } catch (NullPointerException e1){ + } catch (NullPointerException e1) { Log.e(TAG, e1.toString()); } diff --git a/src/com/savoirfairelinux/sflphone/model/Account.java b/src/com/savoirfairelinux/sflphone/model/Account.java index 13f5d1526..0ed30fa31 100644 --- a/src/com/savoirfairelinux/sflphone/model/Account.java +++ b/src/com/savoirfairelinux/sflphone/model/Account.java @@ -31,22 +31,31 @@ package com.savoirfairelinux.sflphone.model; +import java.util.HashMap; + import android.os.Parcel; import android.os.Parcelable; -import android.util.Log; + +import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced; +import com.savoirfairelinux.sflphone.account.AccountDetailBasic; +import com.savoirfairelinux.sflphone.account.AccountDetailSrtp; +import com.savoirfairelinux.sflphone.account.AccountDetailTls; +import com.savoirfairelinux.sflphone.service.ServiceConstants; public class Account implements Parcelable { String accountID; - String host; - String registered_state; - String alias; + private AccountDetailBasic basicDetails = null; + private AccountDetailAdvanced advancedDetails = null; + private AccountDetailSrtp srtpDetails = null; + private AccountDetailTls tlsDetails = null; - private Account(String bAccountID, String bHost, String bRegistered_state, String bAlias) { + public Account(String bAccountID, HashMap<String, String> details) { accountID = bAccountID; - host = bHost; - registered_state = bRegistered_state; - alias = bAlias; + basicDetails = new AccountDetailBasic(details); + advancedDetails = new AccountDetailAdvanced(details); + srtpDetails = new AccountDetailSrtp(details); + tlsDetails = new AccountDetailTls(details); } public String getAccountID() { @@ -58,27 +67,27 @@ public class Account implements Parcelable { } public String getHost() { - return host; + return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME); } public void setHost(String host) { - this.host = host; + basicDetails.setDetailString(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, host); } public String getRegistered_state() { - return registered_state; + return advancedDetails.getDetailString(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS); } public void setRegistered_state(String registered_state) { - this.registered_state = registered_state; + advancedDetails.setDetailString(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS, registered_state); } public String getAlias() { - return alias; + return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS); } public void setAlias(String alias) { - this.alias = alias; + basicDetails.setDetailString(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, alias); } public Account(Parcel in) { @@ -92,19 +101,19 @@ public class Account implements Parcelable { @Override public void writeToParcel(Parcel dest, int arg1) { - + dest.writeString(accountID); - dest.writeString(host); - dest.writeString(registered_state); - dest.writeString(alias); +// dest.writeString(host); +// dest.writeString(registered_state); +// dest.writeString(alias); } private void readFromParcel(Parcel in) { accountID = in.readString(); - host = in.readString(); - registered_state = in.readString(); - alias = in.readString(); +// host = in.readString(); +// registered_state = in.readString(); +// alias = in.readString(); } public static final Parcelable.Creator<Account> CREATOR = new Parcelable.Creator<Account>() { @@ -119,49 +128,36 @@ public class Account implements Parcelable { } }; - public static class AccountBuilder { + public AccountDetailBasic getBasicDetails() { + return basicDetails; + } - String bAccountID; - String bHost; - String bRegistered_state; - String bAlias; - - private static final String TAG = AccountBuilder.class.getSimpleName(); + public void setBasicDetails(AccountDetailBasic basicDetails) { + this.basicDetails = basicDetails; + } - public AccountBuilder setHost(String h) { - Log.i(TAG, "setHost" + h); - bHost = h; - return this; - } + public AccountDetailAdvanced getAdvancedDetails() { + return advancedDetails; + } - public AccountBuilder setAlias(String h) { - Log.i(TAG, "setAlias" + h); - bAlias = h; - return this; - } + public void setAdvancedDetails(AccountDetailAdvanced advancedDetails) { + this.advancedDetails = advancedDetails; + } - public AccountBuilder setRegisteredState(String h) { - Log.i(TAG, "setRegisteredState" + h); - bRegistered_state = h; - return this; - } + public AccountDetailSrtp getSrtpDetails() { + return srtpDetails; + } - public AccountBuilder setAccountID(String h) { - Log.i(TAG, "setAccountID" + h); - bAccountID = h; - return this; - } + public void setSrtpDetails(AccountDetailSrtp srtpDetails) { + this.srtpDetails = srtpDetails; + } - public Account build() throws Exception { - if (bHost.contentEquals("") || bAlias.contentEquals("") || bAccountID.contentEquals("") || bRegistered_state.contentEquals("")) { - throw new Exception("Builders parameters missing"); - } - return new Account(bAccountID, bHost, bRegistered_state, bAlias); - } - - public static AccountBuilder getInstance() { - return new AccountBuilder(); - } + public AccountDetailTls getTlsDetails() { + return tlsDetails; + } + + public void setTlsDetails(AccountDetailTls tlsDetails) { + this.tlsDetails = tlsDetails; } } diff --git a/src/com/savoirfairelinux/sflphone/service/ServiceConstants.java b/src/com/savoirfairelinux/sflphone/service/ServiceConstants.java index 7e82a0c3e..be47f3448 100644 --- a/src/com/savoirfairelinux/sflphone/service/ServiceConstants.java +++ b/src/com/savoirfairelinux/sflphone/service/ServiceConstants.java @@ -5,72 +5,6 @@ public final class ServiceConstants { public static final String INTENT_SIP_SERVICE = "com.savoirfairelinux.sflphone.service.SipService"; public static final String EXTRA_OUTGOING_ACTIVITY = "outgoing_activity"; - public static final String CONFIG_ACCOUNT_TYPE = "Account.type"; - public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias"; - public static final String CONFIG_ACCOUNT_MAILBOX = "Account.mailbox"; - public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable"; - 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_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"; - 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"; - - // SRTP specific parameters - 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"; - - 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"; - - public static final String HISTORY_ACCOUNT_ID_KEY = "accountid"; public static final String HISTORY_CALLID_KEY = "callid"; public static final String HISTORY_CONFID_KEY = "confid"; diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java index 80afd4e3e..21d73b236 100644 --- a/src/com/savoirfairelinux/sflphone/service/SipService.java +++ b/src/com/savoirfairelinux/sflphone/service/SipService.java @@ -53,6 +53,7 @@ import android.util.Log; import android.widget.Toast; import com.savoirfairelinux.sflphone.R; +import com.savoirfairelinux.sflphone.account.AccountDetailBasic; import com.savoirfairelinux.sflphone.account.AccountDetailsHandler; import com.savoirfairelinux.sflphone.account.HistoryHandler; import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity; @@ -515,12 +516,12 @@ public class SipService extends Service { private VectMap extractCredentials(Map map) { VectMap swigmap = new VectMap(); StringMap entry = new StringMap(); - entry.set(ServiceConstants.CONFIG_ACCOUNT_USERNAME, (String) map.get(ServiceConstants.CONFIG_ACCOUNT_USERNAME)); - if ((String) map.get(ServiceConstants.CONFIG_ACCOUNT_REALM) != null) - entry.set(ServiceConstants.CONFIG_ACCOUNT_REALM, (String) map.get(ServiceConstants.CONFIG_ACCOUNT_REALM)); + entry.set(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, (String) map.get(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME)); + if ((String) map.get(AccountDetailBasic.CONFIG_ACCOUNT_REALM) != null) + entry.set(AccountDetailBasic.CONFIG_ACCOUNT_REALM, (String) map.get(AccountDetailBasic.CONFIG_ACCOUNT_REALM)); else - entry.set(ServiceConstants.CONFIG_ACCOUNT_REALM, "*"); - entry.set(ServiceConstants.CONFIG_ACCOUNT_PASSWORD, (String) map.get(ServiceConstants.CONFIG_ACCOUNT_PASSWORD)); + entry.set(AccountDetailBasic.CONFIG_ACCOUNT_REALM, "*"); + entry.set(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, (String) map.get(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD)); swigmap.add(entry); return swigmap; @@ -535,9 +536,9 @@ public class SipService extends Service { for (int i = 0; i < swigmap.size(); ++i) { Log.i(TAG, "Entry " + i); StringMap tmp = swigmap.get(i); - Log.i(TAG, tmp.get(ServiceConstants.CONFIG_ACCOUNT_USERNAME)); + Log.i(TAG, tmp.get(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME)); // Log.i(TAG, tmp.get(ServiceConstants.CONFIG_ACCOUNT_REALM)); - Log.i(TAG, tmp.get(ServiceConstants.CONFIG_ACCOUNT_PASSWORD)); + Log.i(TAG, tmp.get(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD)); } return nativemap; -- GitLab