nick parsing (xep 0172) also enabled for messages and for pep

This commit is contained in:
iNPUTmice 2014-09-04 10:50:06 +02:00
parent 1d6c09e8ff
commit 7a3bc5dc45
1 changed files with 27 additions and 5 deletions

View File

@ -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());
}
}
}
}