From 4db32cdc8f44382c8768c4057851116cae07bf30 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Tue, 19 Apr 2016 20:14:04 +0200 Subject: Related to FS#134: Set Message flags according to httpupload hint --- src/main/java/de/thedevstack/conversationsplus/entities/Message.java | 4 ++++ .../de/thedevstack/conversationsplus/http/HttpUploadConnection.java | 2 ++ .../java/de/thedevstack/conversationsplus/parser/MessageParser.java | 3 +++ 3 files changed, 9 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java index 0cb390e7..37147b31 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java @@ -537,6 +537,10 @@ public class Message extends AbstractEntity { mTreatAsDownloadAble = Decision.NEVER; } + public void setTreatAsDownloadable(Decision downloadable) { + this.mTreatAsDownloadAble = downloadable; + } + public Decision treatAsDownloadable() { // only test this ones, body will not change if (mTreatAsDownloadAble != Decision.NOT_DECIDED) { diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java index 6c546fee..da24f5ab 100644 --- a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java +++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java @@ -97,6 +97,8 @@ public class HttpUploadConnection implements Transferable { public void init(Message message, boolean delay) { this.message = message; + this.message.setHttpUploaded(true); + this.message.setNoDownloadable(); this.account = message.getConversation().getAccount(); this.file = FileBackend.getFile(message, false); this.mime = this.file.getMimeType(); diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java index 4e70ab65..a89adb23 100644 --- a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java +++ b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java @@ -392,6 +392,9 @@ public class MessageParser extends AbstractParser implements serverMsgId = extractStanzaId(packet, isTypeGroupChat ? conversation.getJid().toBareJid() : account.getServer()); } message.setHttpUploaded(packet.hasChild(HttpUploadHint.ELEMENT_NAME, HttpUploadHint.NAMESPACE)); + if (message.isHttpUploaded()) { + message.setTreatAsDownloadable(Message.Decision.MUST); + } message.setCounterpart(counterpart); message.setRemoteMsgId(remoteMsgId); -- cgit v1.2.3