aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-11 12:08:30 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-11 20:14:57 +0100
commit3e932930713e1dfaf141878dfb6dea8fea23ab7a (patch)
treecf69f4ef2f0c364624f58216f11d8a7af00de328 /src/main/java/de/pixart/messenger/entities
parent4980a39d8c8c250e3559926ee4f0034ec9d86e6f (diff)
send and parse Chat States to and from conferences
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java2
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java35
2 files changed, 36 insertions, 1 deletions
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<User> getUsersWithChatState(ChatState state) {
+ synchronized (users) {
+ ArrayList<User> list = new ArrayList<>();
+ for (User user : users) {
+ if (user.chatState == state) {
+ list.add(user);
+ }
+ }
+ return list;
+ }
+ }
+
public List<User> getUsers(int max) {
ArrayList<User> subset = new ArrayList<>();
HashSet<Jid> jids = new HashSet<>();