diff --git a/res/layout/file_explorer_dfrag.xml b/res/layout/file_explorer_dfrag.xml new file mode 100644 index 0000000000000000000000000000000000000000..6f9e6068266ac6916ffdb989ca1170066027bcee --- /dev/null +++ b/res/layout/file_explorer_dfrag.xml @@ -0,0 +1,43 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <Button + android:id="@+id/button_alphabetically" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="alphabetically" /> + + <Button + android:id="@+id/button_lastDateModified" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="lastDateModified" /> + </LinearLayout> + + <TextView + android:id="@+id/path" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + + <ListView + android:id="@android:id/list" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + + <TextView + android:id="@android:id/empty" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="No Data" /> + +</LinearLayout> \ No newline at end of file diff --git a/res/xml/account_sdes.xml b/res/xml/account_sdes.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce0b587e07433c66ad40db640412f87978c57faf --- /dev/null +++ b/res/xml/account_sdes.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +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. +--> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > + + <CheckBoxPreference + android:id="@+id/account_creation_srtp_rtp_fallback" + android:key="SRTP.rtpFallback" + android:persistent="false" + android:title="@string/account_srtp_fallback_label" /> + +</PreferenceScreen> \ No newline at end of file diff --git a/res/xml/account_tls.xml b/res/xml/account_tls.xml new file mode 100644 index 0000000000000000000000000000000000000000..3bc31398b9967d5e1957e29fdc65d7ba6f5a3972 --- /dev/null +++ b/res/xml/account_tls.xml @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +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. +--> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > + + <CheckBoxPreference + android:id="@+id/account_tls_verify_client" + android:defaultValue="false" + android:key="TLS.verifyClient" + android:persistent="false" + android:summaryOff="disabled" + android:summaryOn="enabled" + android:title="Use TLS Transport" /> + + <EditTextPreference + android:id="@+id/account_tls_listener_port" + android:key="TLS.listenerPort" + android:persistent="false" + android:title="Listener Port" /> + <Preference + android:id="@+id/account_tls_certificate_list_file" + android:key="TLS.certificateListFile" + android:persistent="false" + android:title="TLS Certificate List File" /> + <Preference + android:id="@+id/account_tls_certificate_file" + android:key="TLS.certificateFile" + android:persistent="false" + android:title="TLS Certificate File" /> + <Preference + android:id="@+id/account_tls_private_key_file" + android:key="TLS.privateKeyFile" + android:persistent="false" + android:title="TLS Private Key File" /> + <EditTextPreference + android:id="@+id/account_tls_password" + android:key="TLS.password" + android:persistent="false" + android:title="TLS Password" /> + <EditTextPreference + android:id="@+id/account_tls_method" + android:key="TLS.method" + android:persistent="false" + android:title="TLS Method" /> + <EditTextPreference + android:id="@+id/account_tls_ciphers" + android:key="TLS.ciphers" + android:persistent="false" + android:title="TLS Ciphers" /> + <EditTextPreference + android:id="@+id/account_tls_server_name" + android:key="TLS.serverName" + android:persistent="false" + android:title="TLS Server Name" /> + + <CheckBoxPreference + android:id="@+id/account_tls_verify_server" + android:key="TLS.verifyServer" + android:persistent="false" + android:title="TLS Verify Server" /> + <CheckBoxPreference + android:id="@+id/account_tls_verify_client" + android:key="TLS.verifyClient" + android:persistent="false" + android:title="TLS Verify Client" /> + <CheckBoxPreference + android:id="@+id/account_tls_require_client_cert" + android:key="TLS.requireClientCertificate" + android:persistent="false" + android:title="TLS Require Client Certificate" /> + + <EditTextPreference + android:id="@+id/account_tls_timeout_sec" + android:key="TLS.negotiationTimeoutSec" + android:persistent="false" + android:title="TLS Timeout Sec" /> + <EditTextPreference + android:id="@+id/account_tls_timeout_msec" + android:key="TLS.negotiationTimeoutMsec" + android:persistent="false" + android:title="TLS Timeout Msec" /> + +</PreferenceScreen> \ No newline at end of file diff --git a/res/xml/account_zrtp.xml b/res/xml/account_zrtp.xml new file mode 100644 index 0000000000000000000000000000000000000000..0ebcd88d5065f84913d0245ab691a8fdba0caf14 --- /dev/null +++ b/res/xml/account_zrtp.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +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. +--> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > + + <CheckBoxPreference + android:id="@+id/account_srtp_hello_hash" + android:defaultValue="disabled" + android:key="ZRTP.helloHashEnable" + android:persistent="false" + android:summaryOff="disabled" + android:summaryOn="enabled" + android:title="@string/account_hello_hash_enable_label" /> + <CheckBoxPreference + android:id="@+id/account_srtp_display_sas" + android:defaultValue="false" + android:key="ZRTP.displaySAS" + android:persistent="false" + android:summaryOff="disabled" + android:summaryOn="enabled" + android:title="@string/account_display_sas_label" /> + <CheckBoxPreference + android:id="@+id/account_srtp_supported_warning" + android:defaultValue="false" + android:key="ZRTP.notSuppWarning" + android:persistent="false" + android:summaryOff="disabled" + android:summaryOn="enabled" + android:title="@string/account_not_supported_warning_label" /> + <CheckBoxPreference + android:id="@+id/account_srtp_displaysas_once" + android:defaultValue="false" + android:key="ZRTP.displaySasOnce" + android:persistent="false" + android:summaryOff="disabled" + android:summaryOn="enabled" + android:title="@string/account_display_sas_once_label" /> + +</PreferenceScreen> \ No newline at end of file diff --git a/src/org/sflphone/account/SRTPManager.java b/src/org/sflphone/account/SRTPManager.java new file mode 100644 index 0000000000000000000000000000000000000000..14b2e165df58289425533b75a5e01c3a072869cf --- /dev/null +++ b/src/org/sflphone/account/SRTPManager.java @@ -0,0 +1,90 @@ +/* + * 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 org.sflphone.account; + +import org.sflphone.model.Account; + +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceScreen; +import android.util.Log; + +public class SRTPManager { + PreferenceScreen mScreen; + private Account mAccount; + + public void onCreate(PreferenceScreen preferenceScreen, Account acc) { + mScreen = preferenceScreen; + mAccount = acc; + + setDetails(); + } + + private void setDetails() { + for (int i = 0; i < mScreen.getPreferenceCount(); ++i) { + ((CheckBoxPreference) mScreen.getPreference(i)).setChecked(mAccount.getSrtpDetails().getDetailBoolean(mScreen.getPreference(i).getKey())); + } + } + + public void setSDESListener() { + mScreen.findPreference("SRTP.rtpFallback").setOnPreferenceChangeListener(toggleFallbackListener); + } + + private OnPreferenceChangeListener toggleFallbackListener = new OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + mAccount.getSrtpDetails().setDetailString(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, Boolean.toString((Boolean) newValue)); + mAccount.notifyObservers(); + return true; + } + }; + + public void setZRTPListener() { + for (int i = 0; i < mScreen.getPreferenceCount(); ++i) { + mScreen.getPreference(i).setOnPreferenceChangeListener(zrtpListener); + } + } + + private OnPreferenceChangeListener zrtpListener = new OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Log.i("SRTP", "Setting " + preference.getKey() + " to" + (Boolean) newValue); + mAccount.getSrtpDetails().setDetailString(preference.getKey(), Boolean.toString((Boolean) newValue)); + mAccount.notifyObservers(); + return true; + } + }; + +} diff --git a/src/org/sflphone/account/TLSManager.java b/src/org/sflphone/account/TLSManager.java new file mode 100644 index 0000000000000000000000000000000000000000..3f2a9140176c93ac83e0cb9b1798af0990b639bc --- /dev/null +++ b/src/org/sflphone/account/TLSManager.java @@ -0,0 +1,275 @@ +/* + * 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 org.sflphone.account; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import org.sflphone.R; +import org.sflphone.model.Account; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.os.Bundle; +import android.os.Environment; +import android.preference.EditTextPreference; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.Preference.OnPreferenceClickListener; +import android.preference.PreferenceScreen; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.TextView; + +public class TLSManager { + PreferenceScreen mScreen; + private Account mAccount; + static Activity mContext; + + public void onCreate(Activity con, PreferenceScreen preferenceScreen, Account acc) { + mContext = con; + mScreen = preferenceScreen; + mAccount = acc; + + setDetails(); + } + + private void setDetails() { + for (int i = 0; i < mScreen.getPreferenceCount(); ++i) { + + if (mScreen.getPreference(i) instanceof EditTextPreference) { + + } else { + + } + + // ((CheckBoxPreference) + // mScreen.getPreference(i)).setChecked(mAccount.getSrtpDetails().getDetailBoolean(mScreen.getPreference(i).getKey())); + mScreen.getPreference(i).setOnPreferenceClickListener(new OnPreferenceClickListener() { + + @Override + public boolean onPreferenceClick(Preference preference) { + if (preference.getKey().contentEquals(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE)) { + Dialogo dialog = Dialogo.newInstance(); + dialog.show(mContext.getFragmentManager(), "dialog"); + } else if (preference.getKey().contentEquals(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE)) { + + } else if (preference.getKey().contentEquals(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE)) { + + } + return false; + } + }); + } + } + + public void setTLSListener() { + for (int i = 0; i < mScreen.getPreferenceCount(); ++i) { + mScreen.getPreference(i).setOnPreferenceChangeListener(tlsListener); + } + } + + private OnPreferenceChangeListener tlsListener = new OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Log.i("TLS", "Setting " + preference.getKey() + " to" + (Boolean) newValue); + mAccount.getTlsDetails().setDetailString(preference.getKey(), Boolean.toString((Boolean) newValue)); + mAccount.notifyObservers(); + return true; + } + }; + + public static class Dialogo extends DialogFragment implements OnItemClickListener { + + /** + * Create a new instance of CallActionsDFragment + */ + public static Dialogo newInstance() { + Dialogo f = new Dialogo(); + return f; + } + + private List<String> item = null; + private List<String> path = null; + private String root; + private TextView myPath; + + private String currentPath; + Comparator<? super File> comparator; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + View rootView = inflater.inflate(R.layout.activity_browser, container); + myPath = (TextView) rootView.findViewById(R.id.path); + + comparator = filecomparatorByAlphabetically; + root = Environment.getExternalStorageDirectory().getPath(); + getDir(root, rootView); + + Button btnAlphabetically = (Button) rootView.findViewById(R.id.button_alphabetically); + btnAlphabetically.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + comparator = filecomparatorByAlphabetically; + getDir(currentPath, getView()); + + } + }); + + Button btnLastDateModified = (Button) rootView.findViewById(R.id.button_lastDateModified); + btnLastDateModified.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + comparator = filecomparatorByLastModified; + getDir(currentPath, getView()); + + } + }); + return rootView; + } + + private void getDir(String dirPath, View parent) { + currentPath = dirPath; + + myPath.setText("Location: " + dirPath); + item = new ArrayList<String>(); + path = new ArrayList<String>(); + File f = new File(dirPath); + File[] files = f.listFiles(); + + if (!dirPath.equals(root)) { + item.add(root); + path.add(root); + item.add("../"); + path.add(f.getParent()); + } + + Arrays.sort(files, comparator); + + for (int i = 0; i < files.length; i++) { + File file = files[i]; + + if (!file.isHidden() && file.canRead()) { + path.add(file.getPath()); + if (file.isDirectory()) { + item.add(file.getName() + "/"); + } else { + item.add(file.getName()); + } + } + } + + ArrayAdapter<String> fileList = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, item); + + ((ListView) parent.findViewById(android.R.id.list)).setAdapter(fileList); + ((ListView) parent.findViewById(android.R.id.list)).setOnItemClickListener(this); + } + + Comparator<? super File> filecomparatorByLastModified = new Comparator<File>() { + + public int compare(File file1, File file2) { + + if (file1.isDirectory()) { + if (file2.isDirectory()) { + return Long.valueOf(file1.lastModified()).compareTo(file2.lastModified()); + } else { + return -1; + } + } else { + if (file2.isDirectory()) { + return 1; + } else { + return Long.valueOf(file1.lastModified()).compareTo(file2.lastModified()); + } + } + + } + }; + + Comparator<? super File> filecomparatorByAlphabetically = new Comparator<File>() { + + public int compare(File file1, File file2) { + + if (file1.isDirectory()) { + if (file2.isDirectory()) { + return String.valueOf(file1.getName().toLowerCase()).compareTo(file2.getName().toLowerCase()); + } else { + return -1; + } + } else { + if (file2.isDirectory()) { + return 1; + } else { + return String.valueOf(file1.getName().toLowerCase()).compareTo(file2.getName().toLowerCase()); + } + } + + } + }; + + @Override + public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { + + // TODO Auto-generated method stub + File file = new File(path.get(position)); + + if (file.isDirectory()) { + if (file.canRead()) { + getDir(path.get(position), getView()); + } else { + new AlertDialog.Builder(mContext).setIcon(R.drawable.ic_launcher).setTitle("[" + file.getName() + "] folder can't be read!") + .setPositiveButton("OK", null).show(); + } + } else { + new AlertDialog.Builder(mContext).setIcon(R.drawable.ic_launcher).setTitle("[" + file.getName() + "]").setPositiveButton("OK", null) + .show(); + + } + } + + } +} \ No newline at end of file