fixed sending offline pgp messages

This commit is contained in:
iNPUTmice 2014-09-08 14:08:59 +02:00
parent 58953e6193
commit 5cb11396f6
4 changed files with 12 additions and 9 deletions

View file

@ -240,7 +240,7 @@
<string name="missing_presence_updates">Missing presence updates from contact</string> <string name="missing_presence_updates">Missing presence updates from contact</string>
<string name="request_presence_updates">Please request presence updates from your contact first.\n\n<small>This will be used to determine what client(s) your contact is using.</small></string> <string name="request_presence_updates">Please request presence updates from your contact first.\n\n<small>This will be used to determine what client(s) your contact is using.</small></string>
<string name="request_now">Request now</string> <string name="request_now">Request now</string>
<string name="unable_to_decrypt_otr_message">Unable to decrypt OTR message</string> <string name="unable_to_decrypt_otr_message"><i>Unable to decrypt OTR message</i></string>
<string name="delete_fingerprint">Delete Fingerprint</string> <string name="delete_fingerprint">Delete Fingerprint</string>
<string name="sure_delete_fingerprint">Are you sure you would like to delete this fingerprint?</string> <string name="sure_delete_fingerprint">Are you sure you would like to delete this fingerprint?</string>
<string name="ignore">Ignore</string> <string name="ignore">Ignore</string>

View file

@ -151,6 +151,8 @@ public class Message extends AbstractEntity {
public String getReadableBody(Context context) { public String getReadableBody(Context context) {
if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) { if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) {
return context.getText(R.string.encrypted_message_received).toString(); 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)) { } else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) {
return context.getText(R.string.encrypted_image_received).toString(); return context.getText(R.string.encrypted_image_received).toString();
} else if (encryption == ENCRYPTION_DECRYPTION_FAILED) { } else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {

View file

@ -87,7 +87,8 @@ public class MessageGenerator {
packet.addChild("x", "jabber:x:encrypted").setContent( packet.addChild("x", "jabber:x:encrypted").setContent(
message.getEncryptedBody()); message.getEncryptedBody());
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) { } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
packet.setBody(message.getBody()); packet.addChild("x", "jabber:x:encrypted").setContent(
message.getBody());
} }
return packet; return packet;
} }

View file

@ -62,15 +62,17 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
if (latestMessage.getType() == Message.TYPE_TEXT if (latestMessage.getType() == Message.TYPE_TEXT
|| latestMessage.getType() == Message.TYPE_PRIVATE) { || 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)) { && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
String body = Config.PARSE_EMOTICONS ? UIHelper String body = Config.PARSE_EMOTICONS ? UIHelper
.transformAsciiEmoticons(latestMessage.getBody()) .transformAsciiEmoticons(latestMessage.getBody())
: latestMessage.getBody(); : latestMessage.getBody();
convLastMsg.setText(body); convLastMsg.setText(body);
} else { } else {
convLastMsg.setText(activity convLastMsg.setText(R.string.encrypted_message_received);
.getText(R.string.encrypted_message_received));
} }
convLastMsg.setVisibility(View.VISIBLE); convLastMsg.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE); imagePreview.setVisibility(View.GONE);
@ -83,11 +85,9 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
convLastMsg.setVisibility(View.VISIBLE); convLastMsg.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE); imagePreview.setVisibility(View.GONE);
if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) { if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
convLastMsg.setText(activity convLastMsg.setText(R.string.image_offered_for_download);
.getText(R.string.image_offered_for_download));
} else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) { } else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) {
convLastMsg.setText(activity convLastMsg.setText(R.string.receiving_image);
.getText(R.string.receiving_image));
} else { } else {
convLastMsg.setText(""); convLastMsg.setText("");
} }