use of com.xabber.xmpp.muc.Role in project xabber-android by redsolution.
the class RoomChat method createOccupant.
/**
* Warning: this method should be placed with packet provider.
*
* @return New occupant based on presence information.
*/
private Occupant createOccupant(String resource, Presence presence) {
Occupant occupant = new Occupant(resource);
String jid = null;
Affiliation affiliation = Affiliation.none;
Role role = Role.none;
StatusMode statusMode = StatusMode.unavailable;
String statusText = null;
MUCUser mucUser = MUC.getMUCUserExtension(presence);
if (mucUser != null) {
MUCItem item = mucUser.getItem();
if (item != null) {
jid = item.getJid();
try {
affiliation = Affiliation.fromString(item.getAffiliation().toString());
} catch (NoSuchElementException e) {
}
try {
role = Role.fromString(item.getRole().toString());
} catch (NoSuchElementException e) {
}
statusMode = StatusMode.createStatusMode(presence);
statusText = presence.getStatus();
}
}
if (statusText == null) {
statusText = "";
}
occupant.setJid(jid);
occupant.setAffiliation(affiliation);
occupant.setRole(role);
occupant.setStatusMode(statusMode);
occupant.setStatusText(statusText);
return occupant;
}
Aggregations