introduced build-time paranoia mode that disables unencrypted chats and forces TOR

This commit is contained in:
Daniel Gultsch 2015-12-01 22:41:58 +01:00
parent 65b5504e68
commit dc8967d8fc
6 changed files with 27 additions and 5 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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() {

View file

@ -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);

View file

@ -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

View file

@ -147,7 +147,9 @@
android:summary="@string/pref_remove_trusted_certificates_summary"
android:title="@string/pref_remove_trusted_certificates_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_connection_options">
<PreferenceCategory
android:title="@string/pref_connection_options"
android:key="connection_options">
<CheckBoxPreference
android:defaultValue="false"
android:key="use_tor"