diff --git a/res/values/strings.xml b/res/values/strings.xml index b62530606..dde45e06c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -240,7 +240,6 @@ Missing presence updates from contact Please request presence updates from your contact first.\n\nThis will be used to determine what client(s) your contact is using. Request now - Unable to decrypt OTR message Delete Fingerprint Are you sure you would like to delete this fingerprint? Ignore diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java index 074301407..46dd714f1 100644 --- a/src/eu/siacs/conversations/crypto/OtrEngine.java +++ b/src/eu/siacs/conversations/crypto/OtrEngine.java @@ -174,21 +174,7 @@ public class OtrEngine implements OtrEngineHost { @Override public void messageFromAnotherInstanceReceived(SessionID id) { - String jid = id.getAccountID(); - Conversation conversation = mXmppConnectionService - .findOrCreateConversation(account, jid, false); - Message error = new Message(conversation, null, Message.ENCRYPTION_OTR); - conversation.getMessages().add(error); - error.setStatus(Message.STATUS_RECEPTION_FAILED); - mXmppConnectionService.databaseBackend.createMessage(error); - SessionImpl session = conversation.getOtrSession(); - if (session != null - && session.getSessionStatus() != SessionStatus.ENCRYPTED) { - try { - session.startSession(); - } catch (OtrException e) { - } - } + Log.d(Config.LOGTAG,"unreadable message received from "+id.getAccountID()); } @Override diff --git a/src/eu/siacs/conversations/entities/Downloadable.java b/src/eu/siacs/conversations/entities/Downloadable.java new file mode 100644 index 000000000..8fb4977ef --- /dev/null +++ b/src/eu/siacs/conversations/entities/Downloadable.java @@ -0,0 +1,5 @@ +package eu.siacs.conversations.entities; + +public interface Downloadable { + public void start(); +} diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java index d70374a93..5cbd68dde 100644 --- a/src/eu/siacs/conversations/entities/Message.java +++ b/src/eu/siacs/conversations/entities/Message.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.entities; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; -import eu.siacs.conversations.xmpp.jingle.JingleConnection; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -60,7 +59,7 @@ public class Message extends AbstractEntity { protected transient Conversation conversation = null; - protected transient JingleConnection jingleConnection = null; + protected transient Downloadable downloadable = null; private Message() { @@ -151,8 +150,6 @@ public class Message extends AbstractEntity { public String getReadableBody(Context context) { if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) { return context.getText(R.string.encrypted_message_received).toString(); - } else if (encryption == ENCRYPTION_OTR && type == TYPE_TEXT && status == STATUS_RECEPTION_FAILED) { - return context.getText(R.string.unable_to_decrypt_otr_message).toString(); } else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) { return context.getText(R.string.encrypted_image_received).toString(); } else if (encryption == ENCRYPTION_DECRYPTION_FAILED) { @@ -270,12 +267,12 @@ public class Message extends AbstractEntity { } } - public void setJingleConnection(JingleConnection connection) { - this.jingleConnection = connection; + public void setDownloadable(Downloadable downloadable) { + this.downloadable = downloadable; } - public JingleConnection getJingleConnection() { - return this.jingleConnection; + public Downloadable getDownloadable() { + return this.downloadable; } public static Message createStatusMessage(Conversation conversation) { diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 648c6620d..bfcba135e 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -62,10 +62,7 @@ public class ConversationAdapter extends ArrayAdapter { if (latestMessage.getType() == Message.TYPE_TEXT || latestMessage.getType() == Message.TYPE_PRIVATE) { - if (latestMessage.getEncryption() == Message.ENCRYPTION_OTR - && latestMessage.getStatus() == Message.STATUS_RECEPTION_FAILED) { - convLastMsg.setText(R.string.unable_to_decrypt_otr_message); - } else if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP) + if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP) && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) { String body = Config.PARSE_EMOTICONS ? UIHelper .transformAsciiEmoticons(latestMessage.getBody()) diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 074e38fbb..1abd208d7 100644 --- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -7,6 +7,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; +import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.utils.UIHelper; @@ -461,10 +462,9 @@ public class MessageAdapter extends ArrayAdapter { @Override public void onClick(View v) { - JingleConnection connection = item - .getJingleConnection(); - if (connection != null) { - connection.accept(); + Downloadable downloadable = item.getDownloadable(); + if (downloadable != null) { + downloadable.start(); } } }); @@ -495,11 +495,6 @@ public class MessageAdapter extends ArrayAdapter { } } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { displayDecryptionFailed(viewHolder); - } else if (item.getEncryption() == Message.ENCRYPTION_OTR - && item.getStatus() == Message.STATUS_RECEPTION_FAILED - && item.getType() == Message.TYPE_TEXT) { - displayInfoMessage(viewHolder, - R.string.unable_to_decrypt_otr_message); } else { displayTextMessage(viewHolder, item); } diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index a5cc2c49c..e26fcad9e 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -15,6 +15,7 @@ import android.util.Log; import eu.siacs.conversations.Config; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; +import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; @@ -24,7 +25,7 @@ import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; import eu.siacs.conversations.xmpp.jingle.stanzas.Reason; import eu.siacs.conversations.xmpp.stanzas.IqPacket; -public class JingleConnection { +public class JingleConnection implements Downloadable { private final String[] extensions = { "webp", "jpeg", "jpg", "png" }; private final String[] cryptoExtensions = { "pgp", "gpg", "otr" }; @@ -259,7 +260,7 @@ public class JingleConnection { this.message = new Message(conversation, "", Message.ENCRYPTION_NONE); this.message.setType(Message.TYPE_IMAGE); this.message.setStatus(Message.STATUS_RECEIVED_OFFER); - this.message.setJingleConnection(this); + this.message.setDownloadable(this); String[] fromParts = packet.getFrom().split("/"); this.message.setPresence(fromParts[1]); this.account = account; @@ -866,7 +867,7 @@ public class JingleConnection { return this.transport; } - public void accept() { + public void start() { if (status == STATUS_INITIATED) { new Thread(new Runnable() {