diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-04 10:50:06 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-04 10:50:06 +0200 |
commit | 7a3bc5dc4563e14ef1b60961abe60404baed9e81 (patch) | |
tree | 1316a39fa64328b789453cc8d22cf619ec7f139c | |
parent | 1d6c09e8ffd68bca5c3a51ea21684f1c91bde7de (diff) |
nick parsing (xep 0172) also enabled for messages and for pep
-rw-r--r-- | src/eu/siacs/conversations/parser/MessageParser.java | 32 |
1 files changed, 27 insertions, 5 deletions
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()); + } + } + } } |