From ec6220969d362195630c17ec472bcb225838e9ae Mon Sep 17 00:00:00 2001 From: Gayaz Yusipov Date: Sat, 30 Aug 2014 14:26:46 +0400 Subject: [PATCH 1/2] XEP-0172 --- src/eu/siacs/conversations/parser/PresenceParser.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index ea19df6f7..5e5501dda 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -49,7 +49,7 @@ public class PresenceParser extends AbstractParser implements if (packet.getFrom() == null) { return; } - String[] fromParts = packet.getFrom().split("/"); + String[] fromParts = packet.getFrom().split("/", 2); String type = packet.getAttribute("type"); if (fromParts[0].equals(account.getJid())) { if (fromParts.length == 2) { @@ -60,7 +60,6 @@ public class PresenceParser extends AbstractParser implements account.removePresence(fromParts[1]); } } - } else { Contact contact = account.getRoster().getContact(packet.getFrom()); if (type == null) { @@ -108,6 +107,10 @@ public class PresenceParser extends AbstractParser implements contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST); } } + Element nick = packet.findChild("nick", "http://jabber.org/protocol/nick"); + if (nick != null) { + contact.setSystemName(nick.getContent()); + } } mXmppConnectionService.updateRosterUi(); } From 5b24534ab6a0ee6ff0d54ccfd9c16b795ead44a3 Mon Sep 17 00:00:00 2001 From: Gayaz Yusipov Date: Sun, 31 Aug 2014 23:14:05 +0400 Subject: [PATCH 2/2] Contact presenceName property --- src/eu/siacs/conversations/entities/Contact.java | 7 +++++++ src/eu/siacs/conversations/parser/PresenceParser.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java index ab05b9d10..5892563d5 100644 --- a/src/eu/siacs/conversations/entities/Contact.java +++ b/src/eu/siacs/conversations/entities/Contact.java @@ -32,6 +32,7 @@ public class Contact implements ListItem { protected String accountUuid; protected String systemName; protected String serverName; + protected String presenceName; protected String jid; protected int subscription = 0; protected String systemAccount; @@ -76,6 +77,8 @@ public class Contact implements ListItem { return this.systemName; } else if (this.serverName != null) { return this.serverName; + } else if (this.presenceName != null) { + return this.presenceName; } else { return this.jid.split("@")[0]; } @@ -175,6 +178,10 @@ public class Contact implements ListItem { this.systemName = systemName; } + public void setPresenceName(String presenceName) { + this.presenceName = presenceName; + } + public String getSystemAccount() { return systemAccount; } diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index 5e5501dda..9188924fe 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -109,7 +109,7 @@ public class PresenceParser extends AbstractParser implements } Element nick = packet.findChild("nick", "http://jabber.org/protocol/nick"); if (nick != null) { - contact.setSystemName(nick.getContent()); + contact.setPresenceName(nick.getContent()); } } mXmppConnectionService.updateRosterUi();