diff options
Diffstat (limited to 'src')
5 files changed, 23 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java index 7e2c770cd..4817f4bae 100644 --- a/src/main/java/de/pixart/messenger/entities/MucOptions.java +++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java @@ -408,7 +408,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); diff --git a/src/main/java/de/pixart/messenger/parser/AbstractParser.java b/src/main/java/de/pixart/messenger/parser/AbstractParser.java index f67a00a76..3ad20783b 100644 --- a/src/main/java/de/pixart/messenger/parser/AbstractParser.java +++ b/src/main/java/de/pixart/messenger/parser/AbstractParser.java @@ -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); diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index adc5fcdff..d506c3fa2 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -606,7 +606,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece MucOptions.User user = AbstractParser.parseItem(conversation,child); Log.d(Config.LOGTAG,account.getJid()+": changing affiliation for " + 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(); diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java index 477aff0ba..50f13150b 100644 --- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java +++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java @@ -37,7 +37,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); @@ -50,7 +50,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"); @@ -62,10 +63,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); @@ -76,7 +74,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() @@ -130,6 +128,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); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index a21bd3a9f..114b737c2 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2261,7 +2261,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); } } } |