aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-07 12:08:25 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-07 12:08:25 +0200
commit043e19dd65b127d0672e5be70086696521e301d2 (patch)
tree3083b84f694bc44978eff6b42a300dbc74f39b78 /src/main/java/eu
parent8f066d00e0ae10dda5123caaf001d2b34309ec1d (diff)
add xhtml image tag to unencrypted image urls. add oob tag to all files that are on remote hosts
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/MessageGenerator.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
index 11aa96068..5ae41a0fd 100644
--- a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
@@ -68,6 +68,15 @@ public class MessageGenerator extends AbstractGenerator {
return packet;
}
+ public static void addXhtmlImImage(MessagePacket packet, Message.FileParams params) {
+ Element html = packet.addChild("html","http://jabber.org/protocol/xhtml-im");
+ Element body = html.addChild("body","http://www.w3.org/1999/xhtml");
+ Element img = body.addChild("img");
+ img.setAttribute("src",params.url.toString());
+ img.setAttribute("height",params.height);
+ img.setAttribute("width",params.width);
+ }
+
public static void addMessageHints(MessagePacket packet) {
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
@@ -98,11 +107,18 @@ public class MessageGenerator extends AbstractGenerator {
public MessagePacket generateChat(Message message) {
MessagePacket packet = preparePacket(message);
+ String content;
if (message.hasFileOnRemoteHost()) {
- packet.setBody(message.getFileParams().url.toString());
+ Message.FileParams fileParams = message.getFileParams();
+ content = fileParams.url.toString();
+ if (fileParams.width > 0 && fileParams.height > 0) {
+ addXhtmlImImage(packet,fileParams);
+ }
+ packet.addChild("x","jabber:x:oob").addChild("url").setContent(fileParams.url.toString());
} else {
- packet.setBody(message.getBody());
+ content = message.getBody();
}
+ packet.setBody(content);
return packet;
}