aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/parser
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-15 22:53:27 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-15 22:53:27 +0100
commit120c1d903b670f1621d9eea8cdbe94e6ec002ef1 (patch)
tree1d6b789d348801701aa9da7c34cb9abdaed03e3d /src/main/java/de/pixart/messenger/parser
parentfae03f7b0b4c9491fb7ce57e94ab8148fb580b0d (diff)
extract affiliations from unavailable presence
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser')
-rw-r--r--src/main/java/de/pixart/messenger/parser/AbstractParser.java17
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java2
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java16
3 files changed, 21 insertions, 14 deletions
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);