From dc8967d8fc09a5b7e515bb5005726d677a08c86b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 1 Dec 2015 22:41:58 +0100 Subject: introduced build-time paranoia mode that disables unencrypted chats and forces TOR --- src/main/java/eu/siacs/conversations/Config.java | 2 +- .../java/eu/siacs/conversations/entities/Conversation.java | 11 +++++++++-- .../siacs/conversations/services/XmppConnectionService.java | 2 +- .../java/eu/siacs/conversations/ui/ConversationActivity.java | 1 + .../java/eu/siacs/conversations/ui/SettingsActivity.java | 12 ++++++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/main/java/eu/siacs') diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index a53074687..0d51b4a19 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -17,7 +17,7 @@ public final class Config { public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox public static final boolean HIDE_PGP_IN_UI = false; //some more consumer focused clients might want to disable OpenPGP public static final boolean PARANOID_MODE = false; //disables ability to send unencrypted 1-on-1 chats and forces TOR - public static final boolean SHOW_CONNECTED_ACCOUNTS = true; //show number of connected accounts in foreground notification + public static final boolean SHOW_CONNECTED_ACCOUNTS = false; //show number of connected accounts in foreground notification public static final boolean LEGACY_NAMESPACE_HTTP_UPLOAD = false; diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 473ef0fe0..e93d5564b 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -612,9 +612,16 @@ public class Conversation extends AbstractEntity implements Blockable { if (next == -1) { int outgoing = this.getMostRecentlyUsedOutgoingEncryption(); if (outgoing == Message.ENCRYPTION_NONE) { - return this.getMostRecentlyUsedIncomingEncryption(); + next = this.getMostRecentlyUsedIncomingEncryption(); } else { - return outgoing; + next = outgoing; + } + } + if (Config.PARANOID_MODE && mode == MODE_SINGLE && next <= 0) { + if (getAccount().getAxolotlService().isContactAxolotlCapable(getContact())) { + return Message.ENCRYPTION_AXOLOTL; + } else { + return Message.ENCRYPTION_OTR; } } return next; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 30f8c687a..fff8a9848 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2550,7 +2550,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public boolean useTorToConnect() { - return getPreferences().getBoolean("use_tor", false); + return Config.PARANOID_MODE || getPreferences().getBoolean("use_tor", false); } public int unreadCount() { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 5ac2b1b4e..1f6e57a0a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -815,6 +815,7 @@ public class ConversationActivity extends XmppActivity MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp); MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl); pgp.setVisible(!Config.HIDE_PGP_IN_UI); + none.setVisible(!Config.PARANOID_MODE); if (conversation.getMode() == Conversation.MODE_MULTI) { otr.setVisible(false); axolotl.setVisible(false); diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 7118eb5a8..da9738ab5 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -9,7 +9,10 @@ import android.os.Build; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceCategory; import android.preference.PreferenceManager; +import android.preference.PreferenceScreen; +import android.util.Log; import android.widget.Toast; import java.security.KeyStoreException; @@ -19,6 +22,7 @@ import java.util.Collections; import java.util.Locale; import de.duenndns.ssl.MemorizingTrustManager; +import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.xmpp.XmppConnection; @@ -57,6 +61,14 @@ public class SettingsActivity extends XmppActivity implements } } + if (Config.PARANOID_MODE) { + PreferenceCategory connectionOptions = (PreferenceCategory) mSettingsFragment.findPreference("connection_options"); + PreferenceScreen expert = (PreferenceScreen) mSettingsFragment.findPreference("expert"); + if (connectionOptions != null) { + expert.removePreference(connectionOptions); + } + } + final Preference removeCertsPreference = mSettingsFragment.findPreference("remove_trusted_certificates"); removeCertsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override -- cgit v1.2.3