diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-22 19:05:15 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-22 19:05:15 +0200 |
commit | d04afe453a277dfe7d7018c55068d2b4fed6c387 (patch) | |
tree | eb7b2944ec615e0b3b07b3260e420e5cd00eebc9 | |
parent | c067bf96b032e1bef3b021df246dadccbb1b5fd7 (diff) |
ability to download pgp encrypted files over http as well
-rw-r--r-- | src/eu/siacs/conversations/http/HttpConnection.java | 8 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/http/HttpConnection.java b/src/eu/siacs/conversations/http/HttpConnection.java index 407a13d9..b8ce5ed2 100644 --- a/src/eu/siacs/conversations/http/HttpConnection.java +++ b/src/eu/siacs/conversations/http/HttpConnection.java @@ -20,9 +20,7 @@ import org.apache.http.conn.ssl.StrictHostnameVerifier; import android.content.Intent; import android.graphics.BitmapFactory; import android.net.Uri; -import android.util.Log; -import eu.siacs.conversations.Config; import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; @@ -63,12 +61,17 @@ public class HttpConnection implements Downloadable { this.message.setDownloadable(this); try { mUrl = new URL(message.getBody()); + String path = mUrl.getPath(); + if (path != null && (path.endsWith(".pgp") || path.endsWith(".gpg"))) { + this.message.setEncryption(Message.ENCRYPTION_PGP); + } this.file = mXmppConnectionService.getFileBackend().getFile( message, false); String reference = mUrl.getRef(); if (reference != null && reference.length() == 96) { this.file.setKey(CryptoHelper.hexToBytes(reference)); } + if (this.message.getEncryption() == Message.ENCRYPTION_OTR && this.file.getKey() == null) { this.message.setEncryption(Message.ENCRYPTION_NONE); @@ -95,6 +98,7 @@ public class HttpConnection implements Downloadable { mXmppConnectionService.sendBroadcast(intent); message.setDownloadable(null); mHttpConnectionManager.finishConnection(this); + mXmppConnectionService.updateConversationUi(); } private void changeStatus(int status) { diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 0e71801b..580fa2d2 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -435,9 +435,9 @@ public class ConversationFragment extends Fragment { }); } for (Message message : this.conversation.getMessages()) { - if ((message.getEncryption() == Message.ENCRYPTION_PGP) - && ((message.getStatus() == Message.STATUS_RECEIVED) || (message - .getStatus() == Message.STATUS_SEND))) { + if (message.getEncryption() == Message.ENCRYPTION_PGP + && (message.getStatus() == Message.STATUS_RECEIVED || message + .getStatus() >= Message.STATUS_SEND) && message.getDownloadable() == null) { if (!mEncryptedMessages.contains(message)) { mEncryptedMessages.add(message); } |