diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser/AbstractParser.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/AbstractParser.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 7370465c8..c14a7eb0d 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -8,8 +8,11 @@ import java.util.Locale; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; +import eu.siacs.conversations.entities.Conversation; +import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.stanzas.AbstractStanza; @@ -70,4 +73,24 @@ public abstract class AbstractParser { } return item.findChildContent("data", "urn:xmpp:avatar:data"); } + + public static MucOptions.User parseItem(Conversation conference, Element item) { + final String local = conference.getJid().getLocalpart(); + final String domain = conference.getJid().getDomainpart(); + String affiliation = item.getAttribute("affiliation"); + String role = item.getAttribute("role"); + String nick = item.getAttribute("nick"); + Jid fullJid; + try { + fullJid = nick != null ? Jid.fromParts(local, domain, nick) : null; + } catch (InvalidJidException e) { + fullJid = null; + } + Jid realJid = item.getAttributeAsJid("jid"); + MucOptions.User user = new MucOptions.User(conference.getMucOptions(), nick == null ? null : fullJid); + user.setRealJid(realJid); + user.setAffiliation(affiliation); + user.setRole(role); + return user; + } } |