From 3e932930713e1dfaf141878dfb6dea8fea23ab7a Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 11 Mar 2017 12:08:30 +0100 Subject: send and parse Chat States to and from conferences --- .../de/pixart/messenger/entities/Conversation.java | 2 +- .../de/pixart/messenger/entities/MucOptions.java | 35 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'src/main/java/de/pixart/messenger/entities') diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index fe8031b2a..082877ef7 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -209,7 +209,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } public boolean setOutgoingChatState(ChatState state) { - if (mode == MODE_MULTI) { + if (mode == MODE_MULTI && getNextCounterpart() != null) { return false; } if (this.mOutgoingChatState != state) { diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java index 5831a7da5..d3d0e3e9e 100644 --- a/src/main/java/de/pixart/messenger/entities/MucOptions.java +++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java @@ -7,8 +7,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.utils.Namespace; +import de.pixart.messenger.xmpp.chatstate.ChatState; import de.pixart.messenger.xmpp.forms.Data; import de.pixart.messenger.xmpp.forms.Field; import de.pixart.messenger.xmpp.jid.InvalidJidException; @@ -49,6 +51,18 @@ public class MucOptions { return mAutoPushConfiguration; } + public boolean isSelf(Jid counterpart) { + return counterpart.getResourcepart().equals(getActualNick()); + } + + public void resetChatState() { + synchronized (users) { + for (User user : users) { + user.chatState = Config.DEFAULT_CHATSTATE; + } + } + } + public enum Affiliation { OWNER("owner", 4, R.string.owner), ADMIN("admin", 3, R.string.admin), @@ -154,6 +168,7 @@ public class MucOptions { private long pgpKeyId = 0; private Avatar avatar; private MucOptions options; + private ChatState chatState = Config.DEFAULT_CHATSTATE; public User(MucOptions options, Jid from) { this.options = options; @@ -319,6 +334,14 @@ public class MucOptions { public Jid getRealJid() { return realJid; } + + public boolean setChatState(ChatState chatState) { + if (this.chatState == chatState) { + return false; + } + this.chatState = chatState; + return true; + } } private Account account; @@ -519,6 +542,18 @@ public class MucOptions { } } + public ArrayList getUsersWithChatState(ChatState state) { + synchronized (users) { + ArrayList list = new ArrayList<>(); + for (User user : users) { + if (user.chatState == state) { + list.add(user); + } + } + return list; + } + } + public List getUsers(int max) { ArrayList subset = new ArrayList<>(); HashSet jids = new HashSet<>(); -- cgit v1.2.3