mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
made hard coded choice for encryptions more flexible and disable parsing
This commit is contained in:
parent
ddafa65849
commit
d1a456f3e3
@ -6,13 +6,43 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||
|
||||
public final class Config {
|
||||
|
||||
|
||||
private static final int UNENCRYPTED = 1;
|
||||
private static final int OPENPGP = 2;
|
||||
private static final int OTR = 4;
|
||||
private static final int OMEMO = 8;
|
||||
|
||||
private static final int ENCRYPTION_MASK = UNENCRYPTED | OPENPGP | OTR | OMEMO;
|
||||
|
||||
public static boolean supportUnencrypted() {
|
||||
return (ENCRYPTION_MASK & UNENCRYPTED) != 0;
|
||||
}
|
||||
|
||||
public static boolean supportOpenPgp() {
|
||||
return (ENCRYPTION_MASK & OPENPGP) != 0;
|
||||
}
|
||||
|
||||
public static boolean supportOpenPgpOnly() {
|
||||
return supportOpenPgp() && !multipleEncryptionChoices();
|
||||
}
|
||||
|
||||
public static boolean supportOtr() {
|
||||
return (ENCRYPTION_MASK & OTR) != 0;
|
||||
}
|
||||
|
||||
public static boolean supportOmemo() {
|
||||
return (ENCRYPTION_MASK & OMEMO) != 0;
|
||||
}
|
||||
|
||||
public static boolean multipleEncryptionChoices() {
|
||||
return (ENCRYPTION_MASK & (ENCRYPTION_MASK - 1)) != 0;
|
||||
}
|
||||
|
||||
public static final String LOGTAG = "conversations";
|
||||
|
||||
|
||||
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
||||
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 FORCE_E2E_ENCRYPTION = false; //disables ability to send unencrypted 1-on-1
|
||||
public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true
|
||||
public static final boolean FORCE_ORBOT = false; // always use TOR
|
||||
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
|
||||
|
@ -673,11 +673,15 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||
next = outgoing;
|
||||
}
|
||||
}
|
||||
if (Config.FORCE_E2E_ENCRYPTION && mode == MODE_SINGLE && next <= 0) {
|
||||
if (axolotlService != null && axolotlService.isContactAxolotlCapable(getContact())) {
|
||||
if (!Config.supportUnencrypted()
|
||||
&& (mode == MODE_SINGLE || Config.supportOpenPgpOnly())
|
||||
&& next <= 0) {
|
||||
if (Config.supportOmemo() && (axolotlService != null && axolotlService.isContactAxolotlCapable(getContact()) || !Config.multipleEncryptionChoices())) {
|
||||
return Message.ENCRYPTION_AXOLOTL;
|
||||
} else {
|
||||
} else if (Config.supportOtr()) {
|
||||
return Message.ENCRYPTION_OTR;
|
||||
} else if (Config.supportOpenPgp()) {
|
||||
return Message.ENCRYPTION_PGP;
|
||||
}
|
||||
}
|
||||
return next;
|
||||
|
@ -3,7 +3,6 @@ package eu.siacs.conversations.parser;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import eu.siacs.conversations.crypto.PgpDecryptionService;
|
||||
import net.java.otr4j.session.Session;
|
||||
import net.java.otr4j.session.SessionStatus;
|
||||
|
||||
@ -345,7 +344,7 @@ public class MessageParser extends AbstractParser implements
|
||||
}
|
||||
}
|
||||
Message message;
|
||||
if (body != null && body.startsWith("?OTR")) {
|
||||
if (body != null && body.startsWith("?OTR") && Config.supportOtr()) {
|
||||
if (!isForwarded && !isTypeGroupChat && isProperlyAddressed) {
|
||||
message = parseOtrChat(body, from, remoteMsgId, conversation);
|
||||
if (message == null) {
|
||||
@ -355,9 +354,9 @@ public class MessageParser extends AbstractParser implements
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": ignoring OTR message from "+from+" isForwarded="+Boolean.toString(isForwarded)+", isProperlyAddressed="+Boolean.valueOf(isProperlyAddressed));
|
||||
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
|
||||
}
|
||||
} else if (pgpEncrypted != null) {
|
||||
} else if (pgpEncrypted != null && Config.supportOpenPgp()) {
|
||||
message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
|
||||
} else if (axolotlEncrypted != null) {
|
||||
} else if (axolotlEncrypted != null && Config.supportOmemo()) {
|
||||
message = parseAxolotlChat(axolotlEncrypted, from, remoteMsgId, conversation, status);
|
||||
if (message == null) {
|
||||
return;
|
||||
|
@ -351,7 +351,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||
}
|
||||
|
||||
public PgpEngine getPgpEngine() {
|
||||
if (pgpServiceConnection != null && pgpServiceConnection.isBound()) {
|
||||
if (!Config.supportOpenPgp()) {
|
||||
return null;
|
||||
} else if (pgpServiceConnection != null && pgpServiceConnection.isBound()) {
|
||||
if (this.mPgpEngine == null) {
|
||||
this.mPgpEngine = new PgpEngine(new OpenPgpApi(
|
||||
getApplicationContext(),
|
||||
@ -689,6 +691,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver);
|
||||
this.fileObserver.startWatching();
|
||||
|
||||
if (Config.supportOpenPgp()) {
|
||||
this.pgpServiceConnection = new OpenPgpServiceConnection(getApplicationContext(), "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() {
|
||||
@Override
|
||||
public void onBound(IOpenPgpService2 service) {
|
||||
@ -700,9 +703,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) { }
|
||||
public void onError(Exception e) {
|
||||
}
|
||||
});
|
||||
this.pgpServiceConnection.bindToService();
|
||||
}
|
||||
|
||||
this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "XmppConnectionService");
|
||||
|
@ -408,9 +408,10 @@ public class ConversationActivity extends XmppActivity
|
||||
menuContactDetails.setVisible(false);
|
||||
menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating());
|
||||
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
|
||||
menuSecure.setVisible(!Config.HIDE_PGP_IN_UI && !Config.X509_VERIFICATION); //if pgp is hidden conferences have no choice of encryption
|
||||
menuSecure.setVisible(Config.supportOpenPgp() && Config.multipleEncryptionChoices()); //only if pgp is supported we have a choice
|
||||
} else {
|
||||
menuMucDetails.setVisible(false);
|
||||
menuSecure.setVisible(Config.multipleEncryptionChoices());
|
||||
}
|
||||
if (this.getSelectedConversation().isMuted()) {
|
||||
menuMute.setVisible(false);
|
||||
@ -849,9 +850,10 @@ public class ConversationActivity extends XmppActivity
|
||||
MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none);
|
||||
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 && !Config.X509_VERIFICATION);
|
||||
none.setVisible(!Config.FORCE_E2E_ENCRYPTION || conversation.getMode() == Conversation.MODE_MULTI);
|
||||
otr.setVisible(!Config.X509_VERIFICATION);
|
||||
pgp.setVisible(Config.supportOpenPgp());
|
||||
none.setVisible(Config.supportUnencrypted() || conversation.getMode() == Conversation.MODE_MULTI);
|
||||
otr.setVisible(Config.supportOtr());
|
||||
axolotl.setVisible(Config.supportOmemo());
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
otr.setVisible(false);
|
||||
axolotl.setVisible(false);
|
||||
|
@ -123,7 +123,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
||||
menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
|
||||
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(!Config.HIDE_PGP_IN_UI);
|
||||
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
|
||||
}
|
||||
menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user