From 52135625d85dddccddf9731c51ab0e783358ce68 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 7 Mar 2018 20:21:13 +0100 Subject: [PATCH] do not enable encryption for bug reports --- .../java/eu/siacs/conversations/Config.java | 7 +--- .../conversations/entities/Conversation.java | 16 ++------ .../siacs/conversations/entities/Message.java | 2 +- .../conversations/utils/ExceptionHelper.java | 40 ++++--------------- src/main/res/values/colors.xml | 1 + src/main/res/values/themes.xml | 2 +- 6 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 0e1801f84..8c598225f 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -3,6 +3,7 @@ package eu.siacs.conversations; import android.graphics.Bitmap; import eu.siacs.conversations.xmpp.chatstate.ChatState; +import rocks.xmpp.addr.Jid; public final class Config { @@ -22,10 +23,6 @@ public final class Config { return (ENCRYPTION_MASK & OPENPGP) != 0; } - public static boolean supportOtr() { - return (ENCRYPTION_MASK & OTR) != 0; - } - public static boolean supportOmemo() { return (ENCRYPTION_MASK & OMEMO) != 0; } @@ -36,7 +33,7 @@ public final class Config { public static final String LOGTAG = "conversations"; - public static final String BUG_REPORTS = "bugs@conversations.im"; + public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im"); public static final String DOMAIN_LOCK = null; //only allow account creation for this domain diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index e0c212be5..d229c221b 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -600,7 +600,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public int getNextEncryption() { final int defaultEncryption; AxolotlService axolotlService = account.getAxolotlService(); - if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) { + if (contactJid.asBareJid().equals(Config.BUG_REPORTS)) { + defaultEncryption = Message.ENCRYPTION_NONE; + } else if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) { defaultEncryption = Message.ENCRYPTION_AXOLOTL; } else { defaultEncryption = Message.ENCRYPTION_NONE; @@ -882,16 +884,4 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl && !getContact().showInRoster() && sentMessagesCount() == 0; } - - public class Smp { - public static final int STATUS_NONE = 0; - public static final int STATUS_CONTACT_REQUESTED = 1; - public static final int STATUS_WE_REQUESTED = 2; - public static final int STATUS_FAILED = 3; - public static final int STATUS_VERIFIED = 4; - - public String secret = null; - public String hint = null; - public int status = 0; - } } diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index fa0d9649f..5d9f92609 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -564,7 +564,7 @@ public class Message extends AbstractEntity { ((this.axolotlFingerprint == null && message.axolotlFingerprint == null) || this.axolotlFingerprint.equals(message.getFingerprint())) && UIHelper.sameDay(message.getTimeSent(),this.getTimeSent()) && this.getReadByMarkers().equals(message.getReadByMarkers()) && - !this.conversation.getJid().asBareJid().toString().equals(Config.BUG_REPORTS) + !this.conversation.getJid().asBareJid().equals(Config.BUG_REPORTS) ); } diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java index 1774e4c24..f36397199 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java @@ -2,8 +2,6 @@ package eu.siacs.conversations.utils; import android.support.v7.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -28,7 +26,6 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.XmppActivity; -import rocks.xmpp.addr.Jid; public class ExceptionHelper { @@ -94,35 +91,14 @@ public class ExceptionHelper { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(activity.getString(R.string.crash_report_title)); builder.setMessage(activity.getText(R.string.crash_report_message)); - builder.setPositiveButton(activity.getText(R.string.send_now), - new OnClickListener() { + builder.setPositiveButton(activity.getText(R.string.send_now), (dialog, which) -> { - @Override - public void onClick(DialogInterface dialog, int which) { - - Log.d(Config.LOGTAG, "using account=" - + finalAccount.getJid().asBareJid() - + " to send in stack trace"); - Conversation conversation = null; - try { - conversation = service.findOrCreateConversation(finalAccount, - Jid.of(Config.BUG_REPORTS), false, true); - } catch (final IllegalArgumentException ignored) { - } - Message message = new Message(conversation, report - .toString(), Message.ENCRYPTION_NONE); - service.sendMessage(message); - } - }); - builder.setNegativeButton(activity.getText(R.string.send_never), - new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - preferences.edit().putBoolean("never_send", true) - .apply(); - } - }); + Log.d(Config.LOGTAG, "using account=" + finalAccount.getJid().asBareJid() + " to send in stack trace"); + Conversation conversation = service.findOrCreateConversation(finalAccount, Config.BUG_REPORTS, false, true); + Message message = new Message(conversation, report.toString(), Message.ENCRYPTION_NONE); + service.sendMessage(message); + }); + builder.setNegativeButton(activity.getText(R.string.send_never), (dialog, which) -> preferences.edit().putBoolean("never_send", true).apply()); builder.create().show(); return true; } catch (final IOException ignored) { @@ -130,7 +106,7 @@ public class ExceptionHelper { } } - public static void writeToStacktraceFile(Context context, String msg) { + static void writeToStacktraceFile(Context context, String msg) { try { OutputStream os = context.openFileOutput(FILENAME, Context.MODE_PRIVATE); os.write(msg.getBytes()); diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index 94bd49c68..8e6ffe7f6 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -14,6 +14,7 @@ #1fffffff #fffafafa #ffeeeeee + #ffe0e0e0 #ff9e9e9e #ff424242 #ff282828 diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 2039bfc64..d3f662e60 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -161,7 +161,7 @@ \ No newline at end of file