extract affiliations from unavailable presence
This commit is contained in:
parent
035d0c7957
commit
1d3167b520
|
@ -409,7 +409,7 @@ public class MucOptions {
|
|||
return user;
|
||||
}
|
||||
|
||||
public void addUser(User user) {
|
||||
public void updateUser(User user) {
|
||||
User old;
|
||||
if (user.fullJid == null && user.realJid != null) {
|
||||
old = findUserByRealJid(user.realJid);
|
||||
|
|
|
@ -74,19 +74,24 @@ public abstract class AbstractParser {
|
|||
}
|
||||
|
||||
public static MucOptions.User parseItem(Conversation conference, Element item) {
|
||||
return parseItem(conference,item, null);
|
||||
}
|
||||
|
||||
public static MucOptions.User parseItem(Conversation conference, Element item, Jid fullJid) {
|
||||
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;
|
||||
if (nick != null && fullJid == null) {
|
||||
try {
|
||||
fullJid = Jid.fromParts(local, domain, nick);
|
||||
} catch (InvalidJidException e) {
|
||||
fullJid = null;
|
||||
}
|
||||
}
|
||||
Jid realJid = item.getAttributeAsJid("jid");
|
||||
MucOptions.User user = new MucOptions.User(conference.getMucOptions(), nick == null ? null : fullJid);
|
||||
MucOptions.User user = new MucOptions.User(conference.getMucOptions(), fullJid);
|
||||
user.setRealJid(realJid);
|
||||
user.setAffiliation(affiliation);
|
||||
user.setRole(role);
|
||||
|
|
|
@ -612,7 +612,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||
+user.getRealJid()+" to "+user.getAffiliation()+" in "
|
||||
+conversation.getJid().toBareJid());
|
||||
if (!user.realJidMatchesAccount()) {
|
||||
conversation.getMucOptions().addUser(user);
|
||||
conversation.getMucOptions().updateUser(user);
|
||||
mXmppConnectionService.getAvatarService().clear(conversation);
|
||||
mXmppConnectionService.updateMucRosterUi();
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
boolean before = mucOptions.online();
|
||||
int count = mucOptions.getUserCount();
|
||||
final List<MucOptions.User> tileUserBefore = mucOptions.getUsers(5);
|
||||
processConferencePresence(packet, mucOptions);
|
||||
processConferencePresence(packet, conversation);
|
||||
final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
|
||||
if (!tileUserAfter.equals(tileUserBefore)) {
|
||||
mXmppConnectionService.getAvatarService().clear(mucOptions);
|
||||
|
@ -51,7 +51,8 @@ public class PresenceParser extends AbstractParser implements
|
|||
}
|
||||
}
|
||||
|
||||
private void processConferencePresence(PresencePacket packet, MucOptions mucOptions) {
|
||||
private void processConferencePresence(PresencePacket packet, Conversation conversation) {
|
||||
MucOptions mucOptions = conversation.getMucOptions();
|
||||
final Jid from = packet.getFrom();
|
||||
if (!from.isBareJid()) {
|
||||
final String type = packet.getAttribute("type");
|
||||
|
@ -63,10 +64,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
Element item = x.findChild("item");
|
||||
if (item != null && !from.isBareJid()) {
|
||||
mucOptions.setError(MucOptions.Error.NONE);
|
||||
MucOptions.User user = new MucOptions.User(mucOptions, from);
|
||||
user.setAffiliation(item.getAttribute("affiliation"));
|
||||
user.setRole(item.getAttribute("role"));
|
||||
user.setRealJid(item.getAttributeAsJid("jid"));
|
||||
MucOptions.User user = parseItem(conversation, item, from);
|
||||
if (codes.contains(MucOptions.STATUS_CODE_SELF_PRESENCE) || packet.getFrom().equals(mucOptions.getConversation().getJid())) {
|
||||
mucOptions.setOnline();
|
||||
mucOptions.setSelf(user);
|
||||
|
@ -77,7 +75,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
mucOptions.mNickChangingInProgress = false;
|
||||
}
|
||||
} else {
|
||||
mucOptions.addUser(user);
|
||||
mucOptions.updateUser(user);
|
||||
}
|
||||
if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED) && mucOptions.autoPushConfiguration()) {
|
||||
Log.d(Config.LOGTAG,mucOptions.getAccount().getJid().toBareJid()
|
||||
|
@ -131,6 +129,10 @@ public class PresenceParser extends AbstractParser implements
|
|||
Log.d(Config.LOGTAG, "unknown error in conference: " + packet);
|
||||
}
|
||||
} else if (!from.isBareJid()){
|
||||
Element item = x.findChild("item");
|
||||
if (item != null) {
|
||||
mucOptions.updateUser(parseItem(conversation, item, from));
|
||||
}
|
||||
MucOptions.User user = mucOptions.deleteUser(from);
|
||||
if (user != null) {
|
||||
mXmppConnectionService.getAvatarService().clear(user);
|
||||
|
|
|
@ -2127,7 +2127,7 @@ public class XmppConnectionService extends Service {
|
|||
if ("item".equals(child.getName())) {
|
||||
MucOptions.User user = AbstractParser.parseItem(conversation,child);
|
||||
if (!user.realJidMatchesAccount()) {
|
||||
conversation.getMucOptions().addUser(user);
|
||||
conversation.getMucOptions().updateUser(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue