use of org.jivesoftware.smackx.muc.MUCRole in project Smack by igniterealtime.
the class MUCParserUtils method parseItem.
public static MUCItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
int initialDepth = parser.getDepth();
MUCAffiliation affiliation = MUCAffiliation.fromString(parser.getAttributeValue("", "affiliation"));
Resourcepart nick = ParserUtils.getResourcepartAttribute(parser, "nick");
MUCRole role = MUCRole.fromString(parser.getAttributeValue("", "role"));
Jid jid = ParserUtils.getJidAttribute(parser);
Jid actor = null;
Resourcepart actorNick = null;
String reason = null;
outerloop: while (true) {
int eventType = parser.next();
switch(eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch(name) {
case "actor":
actor = ParserUtils.getJidAttribute(parser);
// TODO change to
// actorNick = Resourcepart.from(parser.getAttributeValue("", "nick"));
// once a newer version of JXMPP is used that supports from(null).
String actorNickString = parser.getAttributeValue("", "nick");
if (actorNickString != null) {
actorNick = Resourcepart.from(actorNickString);
}
break;
case "reason":
reason = parser.nextText();
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new MUCItem(affiliation, role, actor, reason, jid, nick, actorNick);
}
Aggregations