diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-10-26 22:43:04 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-10-26 22:43:04 +0200 |
commit | 844d59566c5ee3b84ab240cab14119490e7eec2b (patch) | |
tree | db71961d882eaa197a1512d75d889768db767b3e /src/main/java/de/pixart/messenger/parser | |
parent | fae5a658b9ea3c637c2158e60a1cd369ef4f912a (diff) |
add error message to failed messages. accessible via context menu
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/AbstractParser.java | 14 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/MessageParser.java | 16 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/AbstractParser.java b/src/main/java/de/pixart/messenger/parser/AbstractParser.java index 937327261..f67a00a76 100644 --- a/src/main/java/de/pixart/messenger/parser/AbstractParser.java +++ b/src/main/java/de/pixart/messenger/parser/AbstractParser.java @@ -92,4 +92,18 @@ public abstract class AbstractParser { user.setRole(role); return user; } + + public static String extractErrorMessage(Element packet) { + final Element error = packet.findChild("error"); + if (error != null && error.getChildren().size() > 0) { + final String text = error.findChildContent("text"); + if (text != null && !text.trim().isEmpty()) { + return text; + } else { + return error.getChildren().get(0).getName().replace("-"," "); + } + } else { + return null; + } + } } diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index 4b6428514..d03638f85 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -266,19 +266,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece if (packet.getType() == MessagePacket.TYPE_ERROR) { Jid from = packet.getFrom(); if (from != null) { - Element error = packet.findChild("error"); - String text = error == null ? null : error.findChildContent("text"); - if (text != null) { - Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending message to "+ from+ " failed - " + text); - } else if (error != null) { - Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending message to "+ from+ " failed - " + error); - } Message message = mXmppConnectionService.markMessage(account, from.toBareJid(), packet.getId(), - Message.STATUS_SEND_FAILED); - if (message != null && message.getEncryption() == Message.ENCRYPTION_OTR) { - message.getConversation().endOtrIfNeeded(); + Message.STATUS_SEND_FAILED, + extractErrorMessage(packet)); + if (message != null) { + if (message.getEncryption() == Message.ENCRYPTION_OTR) { + message.getConversation().endOtrIfNeeded(); + } } } return true; |