pare body in type=normal messages as well

This commit is contained in:
iNPUTmice 2014-09-11 13:18:29 +02:00
parent 7fd4f13ff8
commit fef41ba2a2
2 changed files with 6 additions and 15 deletions

View File

@ -202,7 +202,7 @@ public class MessageParser extends AbstractParser implements
if ((message == null) || (!message.hasChild("body"))) { if ((message == null) || (!message.hasChild("body"))) {
if (status == Message.STATUS_RECEIVED if (status == Message.STATUS_RECEIVED
&& message.getAttribute("from") != null) { && message.getAttribute("from") != null) {
parseNormal(message, account); parseNonMessage(message, account);
} }
return null; return null;
} }
@ -256,13 +256,12 @@ public class MessageParser extends AbstractParser implements
packet.getId(), Message.STATUS_SEND_FAILED); packet.getId(), Message.STATUS_SEND_FAILED);
} }
private void parseNormal(Element packet, Account account) { private void parseNonMessage(Element packet, Account account) {
if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) { if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) {
Element event = packet.findChild("event", Element event = packet.findChild("event",
"http://jabber.org/protocol/pubsub#event"); "http://jabber.org/protocol/pubsub#event");
parseEvent(event, packet.getAttribute("from"), account); parseEvent(event, packet.getAttribute("from"), account);
} } else if (packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
if (packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
String id = packet String id = packet
.findChild("displayed", "urn:xmpp:chat-markers:0") .findChild("displayed", "urn:xmpp:chat-markers:0")
.getAttribute("id"); .getAttribute("id");
@ -294,7 +293,6 @@ public class MessageParser extends AbstractParser implements
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} }
} }
} else if (packet.hasChild("x", "jabber:x:conference")) { } else if (packet.hasChild("x", "jabber:x:conference")) {
Element x = packet.findChild("x", "jabber:x:conference"); Element x = packet.findChild("x", "jabber:x:conference");
String jid = x.getAttribute("jid"); String jid = x.getAttribute("jid");
@ -382,7 +380,7 @@ public class MessageParser extends AbstractParser implements
this.parseNick(packet, account); this.parseNick(packet, account);
if ((packet.getType() == MessagePacket.TYPE_CHAT)) { if ((packet.getType() == MessagePacket.TYPE_CHAT || packet.getType() == MessagePacket.TYPE_NORMAL)) {
if ((packet.getBody() != null) if ((packet.getBody() != null)
&& (packet.getBody().startsWith("?OTR"))) { && (packet.getBody().startsWith("?OTR"))) {
message = this.parseOtrChat(packet, account); message = this.parseOtrChat(packet, account);
@ -407,9 +405,8 @@ public class MessageParser extends AbstractParser implements
} }
} }
} else { } else {
parseNormal(packet, account); parseNonMessage(packet, account);
} }
} else if (packet.getType() == MessagePacket.TYPE_GROUPCHAT) { } else if (packet.getType() == MessagePacket.TYPE_GROUPCHAT) {
message = this.parseGroupchat(packet, account); message = this.parseGroupchat(packet, account);
if (message != null) { if (message != null) {
@ -424,9 +421,6 @@ public class MessageParser extends AbstractParser implements
} else if (packet.getType() == MessagePacket.TYPE_ERROR) { } else if (packet.getType() == MessagePacket.TYPE_ERROR) {
this.parseError(packet, account); this.parseError(packet, account);
return; return;
} else if (packet.getType() == MessagePacket.TYPE_NORMAL) {
this.parseNormal(packet, account);
return;
} else if (packet.getType() == MessagePacket.TYPE_HEADLINE) { } else if (packet.getType() == MessagePacket.TYPE_HEADLINE) {
this.parseHeadline(packet, account); this.parseHeadline(packet, account);
return; return;

View File

@ -4,7 +4,6 @@ import eu.siacs.conversations.xml.Element;
public class MessagePacket extends AbstractStanza { public class MessagePacket extends AbstractStanza {
public static final int TYPE_CHAT = 0; public static final int TYPE_CHAT = 0;
public static final int TYPE_UNKNOWN = 1;
public static final int TYPE_NORMAL = 2; public static final int TYPE_NORMAL = 2;
public static final int TYPE_GROUPCHAT = 3; public static final int TYPE_GROUPCHAT = 3;
public static final int TYPE_ERROR = 4; public static final int TYPE_ERROR = 4;
@ -38,8 +37,6 @@ public class MessagePacket extends AbstractStanza {
case TYPE_GROUPCHAT: case TYPE_GROUPCHAT:
this.setAttribute("type", "groupchat"); this.setAttribute("type", "groupchat");
break; break;
case TYPE_UNKNOWN:
break;
case TYPE_NORMAL: case TYPE_NORMAL:
break; break;
default: default:
@ -63,7 +60,7 @@ public class MessagePacket extends AbstractStanza {
} else if (type.equals("headline")) { } else if (type.equals("headline")) {
return TYPE_HEADLINE; return TYPE_HEADLINE;
} else { } else {
return TYPE_UNKNOWN; return TYPE_NORMAL;
} }
} }
} }