From 5cb11396f662252ff294f6cda719877e0473bac4 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 8 Sep 2014 14:08:59 +0200 Subject: [PATCH] fixed sending offline pgp messages --- res/values/strings.xml | 2 +- src/eu/siacs/conversations/entities/Message.java | 2 ++ .../conversations/generator/MessageGenerator.java | 3 ++- .../ui/adapter/ConversationAdapter.java | 14 +++++++------- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 3aa30e40e..b62530606 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -240,7 +240,7 @@ 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 + 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/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java index 2b76773b8..d70374a93 100644 --- a/src/eu/siacs/conversations/entities/Message.java +++ b/src/eu/siacs/conversations/entities/Message.java @@ -151,6 +151,8 @@ 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) { diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java index ea53432cd..ecfb4744b 100644 --- a/src/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/eu/siacs/conversations/generator/MessageGenerator.java @@ -87,7 +87,8 @@ public class MessageGenerator { packet.addChild("x", "jabber:x:encrypted").setContent( message.getEncryptedBody()); } else if (message.getEncryption() == Message.ENCRYPTION_PGP) { - packet.setBody(message.getBody()); + packet.addChild("x", "jabber:x:encrypted").setContent( + message.getBody()); } return packet; } diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 6eb9846ad..648c6620d 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -62,15 +62,17 @@ public class ConversationAdapter extends ArrayAdapter { if (latestMessage.getType() == Message.TYPE_TEXT || latestMessage.getType() == Message.TYPE_PRIVATE) { - if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP) + 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) && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) { String body = Config.PARSE_EMOTICONS ? UIHelper .transformAsciiEmoticons(latestMessage.getBody()) : latestMessage.getBody(); convLastMsg.setText(body); } else { - convLastMsg.setText(activity - .getText(R.string.encrypted_message_received)); + convLastMsg.setText(R.string.encrypted_message_received); } convLastMsg.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.GONE); @@ -83,11 +85,9 @@ public class ConversationAdapter extends ArrayAdapter { convLastMsg.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.GONE); if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) { - convLastMsg.setText(activity - .getText(R.string.image_offered_for_download)); + convLastMsg.setText(R.string.image_offered_for_download); } else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) { - convLastMsg.setText(activity - .getText(R.string.receiving_image)); + convLastMsg.setText(R.string.receiving_image); } else { convLastMsg.setText(""); }