From 7a3bc5dc4563e14ef1b60961abe60404baed9e81 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 4 Sep 2014 10:50:06 +0200 Subject: nick parsing (xep 0172) also enabled for messages and for pep --- .../siacs/conversations/parser/MessageParser.java | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/eu/siacs') diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index 10859345..0f95627d 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -328,12 +328,20 @@ public class MessageParser extends AbstractParser implements mXmppConnectionService.fetchAvatar(account, avatar); } } - } else { - Log.d(Config.LOGTAG, account.getJid() + ": " + node + " from " - + from); + } else if (node.equals("http://jabber.org/protocol/nick")) { + Element item = items.findChild("item"); + if (item != null) { + Element nick = item.findChild("nick", + "http://jabber.org/protocol/nick"); + if (nick != null) { + if (from != null) { + Contact contact = account.getRoster().getContact( + from); + contact.setPresenceName(nick.getContent()); + } + } + } } - } else { - Log.d(Config.LOGTAG, event.toString()); } } @@ -363,6 +371,8 @@ public class MessageParser extends AbstractParser implements notify = (SystemClock.elapsedRealtime() - lastCarbonMessageReceived) > (Config.CARBON_GRACE_PERIOD * 1000); } + this.parseNick(packet, account); + if ((packet.getType() == MessagePacket.TYPE_CHAT)) { if ((packet.getBody() != null) && (packet.getBody().startsWith("?OTR"))) { @@ -446,4 +456,16 @@ public class MessageParser extends AbstractParser implements parseEvent(event, packet.getFrom(), account); } } + + private void parseNick(MessagePacket packet, Account account) { + Element nick = packet.findChild("nick", + "http://jabber.org/protocol/nick"); + if (nick != null) { + if (packet.getFrom() != null) { + Contact contact = account.getRoster().getContact( + packet.getFrom()); + contact.setPresenceName(nick.getContent()); + } + } + } } -- cgit v1.2.3